mirror of
https://github.com/jwetzell/showbridge-go.git
synced 2026-04-26 21:05:30 +00:00
type Modules property of WrappedPayload
This commit is contained in:
@@ -18,19 +18,12 @@ type DbQuery struct {
|
||||
}
|
||||
|
||||
func (dq *DbQuery) Process(ctx context.Context, wrappedPayload common.WrappedPayload) (common.WrappedPayload, error) {
|
||||
ctxModules := ctx.Value(common.ModulesContextKey)
|
||||
if ctxModules == nil {
|
||||
if wrappedPayload.Modules == nil {
|
||||
wrappedPayload.End = true
|
||||
return wrappedPayload, errors.New("db.query unable to get modules from context")
|
||||
return wrappedPayload, errors.New("db.query wrapped payload has no modules")
|
||||
}
|
||||
|
||||
moduleMap, ok := ctxModules.(map[string]common.Module)
|
||||
if !ok {
|
||||
wrappedPayload.End = true
|
||||
return wrappedPayload, errors.New("db.query modules from context has wrong type")
|
||||
}
|
||||
|
||||
module, ok := moduleMap[dq.ModuleId]
|
||||
module, ok := wrappedPayload.Modules[dq.ModuleId]
|
||||
if !ok {
|
||||
wrappedPayload.End = true
|
||||
return wrappedPayload, fmt.Errorf("db.query unable to find module with id: %s", dq.ModuleId)
|
||||
|
||||
@@ -18,19 +18,12 @@ type KVGet struct {
|
||||
}
|
||||
|
||||
func (kvg *KVGet) Process(ctx context.Context, wrappedPayload common.WrappedPayload) (common.WrappedPayload, error) {
|
||||
ctxModules := ctx.Value(common.ModulesContextKey)
|
||||
if ctxModules == nil {
|
||||
if wrappedPayload.Modules == nil {
|
||||
wrappedPayload.End = true
|
||||
return wrappedPayload, errors.New("kv.get unable to get modules from context")
|
||||
return wrappedPayload, errors.New("kv.get wrapped payload has no modules")
|
||||
}
|
||||
|
||||
moduleMap, ok := ctxModules.(map[string]common.Module)
|
||||
if !ok {
|
||||
wrappedPayload.End = true
|
||||
return wrappedPayload, errors.New("kv.get modules from context has wrong type")
|
||||
}
|
||||
|
||||
module, ok := moduleMap[kvg.ModuleId]
|
||||
module, ok := wrappedPayload.Modules[kvg.ModuleId]
|
||||
if !ok {
|
||||
wrappedPayload.End = true
|
||||
return wrappedPayload, fmt.Errorf("kv.get unable to find module with id: %s", kvg.ModuleId)
|
||||
|
||||
@@ -20,19 +20,13 @@ type KVSet struct {
|
||||
}
|
||||
|
||||
func (kvs *KVSet) Process(ctx context.Context, wrappedPayload common.WrappedPayload) (common.WrappedPayload, error) {
|
||||
ctxModules := ctx.Value(common.ModulesContextKey)
|
||||
if ctxModules == nil {
|
||||
|
||||
if wrappedPayload.Modules == nil {
|
||||
wrappedPayload.End = true
|
||||
return wrappedPayload, errors.New("kv.set unable to get modules from context")
|
||||
return wrappedPayload, errors.New("kv.set wrapped payload has no modules")
|
||||
}
|
||||
|
||||
moduleMap, ok := ctxModules.(map[string]common.Module)
|
||||
if !ok {
|
||||
wrappedPayload.End = true
|
||||
return wrappedPayload, errors.New("kv.set modules from context has wrong type")
|
||||
}
|
||||
|
||||
module, ok := moduleMap[kvs.ModuleId]
|
||||
module, ok := wrappedPayload.Modules[kvs.ModuleId]
|
||||
if !ok {
|
||||
wrappedPayload.End = true
|
||||
return wrappedPayload, fmt.Errorf("kv.set unable to find module with id: %s", kvs.ModuleId)
|
||||
|
||||
Reference in New Issue
Block a user