diff options
author | Valery Piashchynski <[email protected]> | 2021-09-10 19:05:37 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2021-09-10 19:05:37 +0300 |
commit | e94a80d4586d5a5fedc2edab850c5c8bad93395f (patch) | |
tree | 4272054647725274abb5ee69e355c1e4262760ea /plugins/broadcast | |
parent | 8fa86886bd5b3c12cf161fb2c1cdd9a2cd53d1bf (diff) |
fix issue with incorrectly parsing local and global configuration
Signed-off-by: Valery Piashchynski <[email protected]>
Diffstat (limited to 'plugins/broadcast')
-rw-r--r-- | plugins/broadcast/config.go | 2 | ||||
-rw-r--r-- | plugins/broadcast/plugin.go | 17 |
2 files changed, 13 insertions, 6 deletions
diff --git a/plugins/broadcast/config.go b/plugins/broadcast/config.go index 4f1e5213..9531025b 100644 --- a/plugins/broadcast/config.go +++ b/plugins/broadcast/config.go @@ -3,6 +3,8 @@ package broadcast /* # Global redis config (priority - 2) +default: + # redis configuration here websockets: # <----- one of possible subscribers path: /ws diff --git a/plugins/broadcast/plugin.go b/plugins/broadcast/plugin.go index a2390df5..47b68fe7 100644 --- a/plugins/broadcast/plugin.go +++ b/plugins/broadcast/plugin.go @@ -15,6 +15,9 @@ const ( PluginName string = "broadcast" // driver is the mandatory field which should present in every storage driver string = "driver" + + // every driver should have config section for the local configuration + conf string = "config" ) type Plugin struct { @@ -130,8 +133,8 @@ func (p *Plugin) GetDriver(key string) (pubsub.SubReader, error) { return nil, errors.E(op, errors.Str("wrong type detected in the configuration, please, check yaml indentation")) } - // config key for the particular sub-driver kv.memcached - configKey := fmt.Sprintf("%s.%s", PluginName, key) + // config key for the particular sub-driver broadcast.memcached.config + configKey := fmt.Sprintf("%s.%s.%s", PluginName, key, conf) drName := val.(map[string]interface{})[driver] @@ -141,8 +144,10 @@ func (p *Plugin) GetDriver(key string) (pubsub.SubReader, error) { return nil, errors.E(op, errors.Errorf("no drivers with the requested name registered, registered: %s, requested: %s", p.publishers, drStr)) } + switch { // try local config first - if p.cfgPlugin.Has(configKey) { + case p.cfgPlugin.Has(configKey): + // we found a local configuration ps, err := p.constructors[drStr].PSConstruct(configKey) if err != nil { return nil, errors.E(op, err) @@ -153,9 +158,9 @@ func (p *Plugin) GetDriver(key string) (pubsub.SubReader, error) { p.publishers[configKey] = ps return ps, nil - } else { - // try global driver section - ps, err := p.constructors[drStr].PSConstruct(drStr) + default: + // try global driver section after local + ps, err := p.constructors[drStr].PSConstruct(key) if err != nil { return nil, errors.E(op, err) } |