summaryrefslogtreecommitdiff
path: root/plugins/broadcast/root/config.go
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/broadcast/root/config.go')
-rw-r--r--plugins/broadcast/root/config.go61
1 files changed, 61 insertions, 0 deletions
diff --git a/plugins/broadcast/root/config.go b/plugins/broadcast/root/config.go
new file mode 100644
index 00000000..8c732441
--- /dev/null
+++ b/plugins/broadcast/root/config.go
@@ -0,0 +1,61 @@
+package broadcast
+
+import (
+ "errors"
+
+ "github.com/go-redis/redis/v8"
+)
+
+// Config configures the broadcast extension.
+type Config struct {
+ // RedisConfig configures redis broker.
+ Redis *RedisConfig
+}
+
+// Hydrate reads the configuration values from the source configuration.
+//func (c *Config) Hydrate(cfg service.Config) error {
+// if err := cfg.Unmarshal(c); err != nil {
+// return err
+// }
+//
+// if c.Redis != nil {
+// return c.Redis.isValid()
+// }
+//
+// return nil
+//}
+
+// InitDefaults enables in memory broadcast configuration.
+func (c *Config) InitDefaults() error {
+ return nil
+}
+
+// RedisConfig configures redis broker.
+type RedisConfig struct {
+ // Addr of the redis server.
+ Addr string
+
+ // Password to redis server.
+ Password string
+
+ // DB index.
+ DB int
+}
+
+// clusterOptions
+func (cfg *RedisConfig) redisClient() redis.UniversalClient {
+ return redis.NewClient(&redis.Options{
+ Addr: cfg.Addr,
+ Password: cfg.Password,
+ PoolSize: 2,
+ })
+}
+
+// check if redis config is valid.
+func (cfg *RedisConfig) isValid() error {
+ if cfg.Addr == "" {
+ return errors.New("redis addr is required")
+ }
+
+ return nil
+}