summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2021-09-10 19:05:37 +0300
committerValery Piashchynski <[email protected]>2021-09-10 19:05:37 +0300
commite94a80d4586d5a5fedc2edab850c5c8bad93395f (patch)
tree4272054647725274abb5ee69e355c1e4262760ea
parent8fa86886bd5b3c12cf161fb2c1cdd9a2cd53d1bf (diff)
fix issue with incorrectly parsing local and global configuration
Signed-off-by: Valery Piashchynski <[email protected]>
-rw-r--r--.vscode/settings.json9
-rw-r--r--plugins/broadcast/config.go2
-rw-r--r--plugins/broadcast/plugin.go17
-rw-r--r--plugins/kv/plugin.go54
-rw-r--r--plugins/memcached/memcachedkv/driver.go4
-rw-r--r--plugins/memory/memoryjobs/consumer.go4
-rw-r--r--plugins/memory/memorykv/kv.go4
-rw-r--r--plugins/memory/plugin.go2
-rw-r--r--plugins/redis/jobs/config.go34
-rw-r--r--plugins/redis/jobs/consumer.go1
-rw-r--r--plugins/redis/jobs/item.go1
-rw-r--r--plugins/redis/kv/config.go4
-rw-r--r--plugins/redis/kv/kv.go7
-rw-r--r--plugins/redis/pubsub/pubsub.go6
-rw-r--r--tests/plugins/broadcast/configs/.rr-broadcast-config-error.yaml1
-rw-r--r--tests/plugins/broadcast/configs/.rr-broadcast-global.yaml72
-rw-r--r--tests/plugins/broadcast/configs/.rr-broadcast-init.yaml5
-rw-r--r--tests/plugins/broadcast/configs/.rr-broadcast-same-section.yaml69
-rw-r--r--tests/plugins/kv/configs/.rr-boltdb.yaml21
-rw-r--r--tests/plugins/kv/configs/.rr-in-memory.yaml13
-rw-r--r--tests/plugins/kv/configs/.rr-kv-bolt-no-interval.yaml24
-rw-r--r--tests/plugins/kv/configs/.rr-kv-bolt-perms.yaml22
-rw-r--r--tests/plugins/kv/configs/.rr-kv-init.yaml49
-rw-r--r--tests/plugins/kv/configs/.rr-memcached.yaml15
-rw-r--r--tests/plugins/kv/configs/.rr-redis-global.yaml14
-rw-r--r--tests/plugins/kv/configs/.rr-redis-no-config.yaml10
-rw-r--r--tests/plugins/kv/configs/.rr-redis.yaml15
-rw-r--r--tests/plugins/kv/storage_plugin_test.go44
-rw-r--r--tests/plugins/websockets/configs/.rr-websockets-allow.yaml65
-rw-r--r--tests/plugins/websockets/configs/.rr-websockets-allow2.yaml70
-rw-r--r--tests/plugins/websockets/configs/.rr-websockets-broker-no-section.yaml60
-rw-r--r--tests/plugins/websockets/configs/.rr-websockets-deny.yaml61
-rw-r--r--tests/plugins/websockets/configs/.rr-websockets-deny2.yaml64
-rw-r--r--tests/plugins/websockets/configs/.rr-websockets-init.yaml68
-rw-r--r--tests/plugins/websockets/configs/.rr-websockets-redis.yaml65
-rw-r--r--tests/plugins/websockets/configs/.rr-websockets-stop.yaml61
36 files changed, 573 insertions, 464 deletions
diff --git a/.vscode/settings.json b/.vscode/settings.json
index deac8e8b..8a0b4664 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -1,6 +1,13 @@
{
"cSpell.words": [
"addrs",
- "websockets"
+ "amqp",
+ "boltdb",
+ "gomemcache",
+ "goridge",
+ "memorykv",
+ "Upgrader",
+ "websockets",
+ "websocketsv"
]
} \ No newline at end of file
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)
}
diff --git a/plugins/kv/plugin.go b/plugins/kv/plugin.go
index a1144b85..a2b36e3e 100644
--- a/plugins/kv/plugin.go
+++ b/plugins/kv/plugin.go
@@ -10,12 +10,13 @@ import (
"github.com/spiral/roadrunner/v2/plugins/logger"
)
-// PluginName linked to the memory, boltdb, memcached, redis plugins. DO NOT change w/o sync.
-const PluginName string = "kv"
-
const (
+ // PluginName linked to the memory, boltdb, memcached, redis plugins. DO NOT change w/o sync.
+ PluginName string = "kv"
// driver is the mandatory field which should present in every storage
driver string = "driver"
+ // config key used to detect local configuration for the driver
+ cfg string = "config"
)
// Plugin for the unified storage
@@ -75,26 +76,45 @@ func (p *Plugin) Serve() chan error {
continue
}
- // config key for the particular sub-driver kv.memcached
- configKey := fmt.Sprintf("%s.%s", PluginName, k)
+ // config key for the particular sub-driver kv.memcached.config
+ configKey := fmt.Sprintf("%s.%s.%s", PluginName, k, cfg)
// at this point we know, that driver field present in the configuration
drName := v.(map[string]interface{})[driver]
// driver name should be a string
if drStr, ok := drName.(string); ok {
- if _, ok := p.constructors[drStr]; !ok {
- p.log.Warn("no constructors registered", "requested constructor", drStr, "registered", p.constructors)
- continue
+ switch {
+ // local configuration section key
+ case p.cfgPlugin.Has(configKey):
+ if _, ok := p.constructors[drStr]; !ok {
+ p.log.Warn("no constructors registered", "requested constructor", drStr, "registered", p.constructors)
+ continue
+ }
+
+ storage, err := p.constructors[drStr].KVConstruct(configKey)
+ if err != nil {
+ errCh <- errors.E(op, err)
+ return errCh
+ }
+
+ // save the storage
+ p.storages[k] = storage
+ default:
+ if _, ok := p.constructors[drStr]; !ok {
+ p.log.Warn("no constructors registered", "requested constructor", drStr, "registered", p.constructors)
+ continue
+ }
+
+ // use only key for the driver registration, for example rr-boltdb should be globally available
+ storage, err := p.constructors[drStr].KVConstruct(k)
+ if err != nil {
+ errCh <- errors.E(op, err)
+ return errCh
+ }
+
+ // save the storage
+ p.storages[k] = storage
}
-
- storage, err := p.constructors[drStr].KVConstruct(configKey)
- if err != nil {
- errCh <- errors.E(op, err)
- return errCh
- }
-
- // save the storage
- p.storages[k] = storage
}
continue
diff --git a/plugins/memcached/memcachedkv/driver.go b/plugins/memcached/memcachedkv/driver.go
index 6d5e1802..dcb071b4 100644
--- a/plugins/memcached/memcachedkv/driver.go
+++ b/plugins/memcached/memcachedkv/driver.go
@@ -32,6 +32,10 @@ func NewMemcachedDriver(log logger.Logger, key string, cfgPlugin config.Configur
return nil, errors.E(op, err)
}
+ if s.cfg == nil {
+ return nil, errors.E(op, errors.Errorf("config not found by provided key: %s", key))
+ }
+
s.cfg.InitDefaults()
m := memcache.New(s.cfg.Addr...)
diff --git a/plugins/memory/memoryjobs/consumer.go b/plugins/memory/memoryjobs/consumer.go
index fbdedefe..bebea3ce 100644
--- a/plugins/memory/memoryjobs/consumer.go
+++ b/plugins/memory/memoryjobs/consumer.go
@@ -61,6 +61,10 @@ func NewJobBroker(configKey string, log logger.Logger, cfg config.Configurer, eh
return nil, errors.E(op, err)
}
+ if jb.cfg == nil {
+ return nil, errors.E(op, errors.Errorf("config not found by provided key: %s", configKey))
+ }
+
if jb.cfg.Prefetch == 0 {
jb.cfg.Prefetch = 100_000
}
diff --git a/plugins/memory/memorykv/kv.go b/plugins/memory/memorykv/kv.go
index 9b3e176c..5383275c 100644
--- a/plugins/memory/memorykv/kv.go
+++ b/plugins/memory/memorykv/kv.go
@@ -33,6 +33,10 @@ func NewInMemoryDriver(key string, log logger.Logger, cfgPlugin config.Configure
return nil, errors.E(op, err)
}
+ if d.cfg == nil {
+ return nil, errors.E(op, errors.Errorf("config not found by provided key: %s", key))
+ }
+
d.cfg.InitDefaults()
go d.gc()
diff --git a/plugins/memory/plugin.go b/plugins/memory/plugin.go
index 515e469a..87e0f84b 100644
--- a/plugins/memory/plugin.go
+++ b/plugins/memory/plugin.go
@@ -49,7 +49,7 @@ func (p *Plugin) PSConstruct(key string) (pubsub.PubSub, error) {
}
func (p *Plugin) KVConstruct(key string) (kv.Storage, error) {
- const op = errors.Op("inmemory_plugin_provide")
+ const op = errors.Op("memory_plugin_construct")
st, err := memorykv.NewInMemoryDriver(key, p.log, p.cfg)
if err != nil {
return nil, errors.E(op, err)
diff --git a/plugins/redis/jobs/config.go b/plugins/redis/jobs/config.go
deleted file mode 100644
index 89d707af..00000000
--- a/plugins/redis/jobs/config.go
+++ /dev/null
@@ -1,34 +0,0 @@
-package jobs
-
-import "time"
-
-type Config struct {
- Addrs []string `mapstructure:"addrs"`
- DB int `mapstructure:"db"`
- Username string `mapstructure:"username"`
- Password string `mapstructure:"password"`
- MasterName string `mapstructure:"master_name"`
- SentinelPassword string `mapstructure:"sentinel_password"`
- RouteByLatency bool `mapstructure:"route_by_latency"`
- RouteRandomly bool `mapstructure:"route_randomly"`
- MaxRetries int `mapstructure:"max_retries"`
- DialTimeout time.Duration `mapstructure:"dial_timeout"`
- MinRetryBackoff time.Duration `mapstructure:"min_retry_backoff"`
- MaxRetryBackoff time.Duration `mapstructure:"max_retry_backoff"`
- PoolSize int `mapstructure:"pool_size"`
- MinIdleConns int `mapstructure:"min_idle_conns"`
- MaxConnAge time.Duration `mapstructure:"max_conn_age"`
- ReadTimeout time.Duration `mapstructure:"read_timeout"`
- WriteTimeout time.Duration `mapstructure:"write_timeout"`
- PoolTimeout time.Duration `mapstructure:"pool_timeout"`
- IdleTimeout time.Duration `mapstructure:"idle_timeout"`
- IdleCheckFreq time.Duration `mapstructure:"idle_check_freq"`
- ReadOnly bool `mapstructure:"read_only"`
-}
-
-// InitDefaults initializing fill config with default values
-func (s *Config) InitDefaults() {
- if s.Addrs == nil {
- s.Addrs = []string{"127.0.0.1:6379"} // default addr is pointing to local storage
- }
-}
diff --git a/plugins/redis/jobs/consumer.go b/plugins/redis/jobs/consumer.go
deleted file mode 100644
index 415ac457..00000000
--- a/plugins/redis/jobs/consumer.go
+++ /dev/null
@@ -1 +0,0 @@
-package jobs
diff --git a/plugins/redis/jobs/item.go b/plugins/redis/jobs/item.go
deleted file mode 100644
index 415ac457..00000000
--- a/plugins/redis/jobs/item.go
+++ /dev/null
@@ -1 +0,0 @@
-package jobs
diff --git a/plugins/redis/kv/config.go b/plugins/redis/kv/config.go
index 5b760952..5bd772a9 100644
--- a/plugins/redis/kv/config.go
+++ b/plugins/redis/kv/config.go
@@ -1,6 +1,8 @@
package kv
-import "time"
+import (
+ "time"
+)
type Config struct {
Addrs []string `mapstructure:"addrs"`
diff --git a/plugins/redis/kv/kv.go b/plugins/redis/kv/kv.go
index 3d062fbb..ae55d332 100644
--- a/plugins/redis/kv/kv.go
+++ b/plugins/redis/kv/kv.go
@@ -20,7 +20,7 @@ type Driver struct {
}
func NewRedisDriver(log logger.Logger, key string, cfgPlugin config.Configurer) (*Driver, error) {
- const op = errors.Op("new_boltdb_driver")
+ const op = errors.Op("new_redis_driver")
d := &Driver{
log: log,
@@ -32,8 +32,11 @@ func NewRedisDriver(log logger.Logger, key string, cfgPlugin config.Configurer)
return nil, errors.E(op, err)
}
+ if d.cfg == nil {
+ return nil, errors.E(op, errors.Errorf("config not found by provided key: %s", key))
+ }
+
d.cfg.InitDefaults()
- d.log = log
d.universalClient = redis.NewUniversalClient(&redis.UniversalOptions{
Addrs: d.cfg.Addrs,
diff --git a/plugins/redis/pubsub/pubsub.go b/plugins/redis/pubsub/pubsub.go
index c9ad3d58..3561ef18 100644
--- a/plugins/redis/pubsub/pubsub.go
+++ b/plugins/redis/pubsub/pubsub.go
@@ -13,7 +13,7 @@ import (
type PubSubDriver struct {
sync.RWMutex
- cfg *Config `mapstructure:"redis"`
+ cfg *Config
log logger.Logger
channel *redisChannel
@@ -34,6 +34,10 @@ func NewPubSubDriver(log logger.Logger, key string, cfgPlugin config.Configurer,
return nil, errors.E(op, err)
}
+ if ps.cfg == nil {
+ return nil, errors.E(op, errors.Errorf("config not found by provided key: %s", key))
+ }
+
ps.cfg.InitDefaults()
ps.universalClient = redis.NewUniversalClient(&redis.UniversalOptions{
diff --git a/tests/plugins/broadcast/configs/.rr-broadcast-config-error.yaml b/tests/plugins/broadcast/configs/.rr-broadcast-config-error.yaml
index 66114d64..1474feb7 100644
--- a/tests/plugins/broadcast/configs/.rr-broadcast-config-error.yaml
+++ b/tests/plugins/broadcast/configs/.rr-broadcast-config-error.yaml
@@ -17,6 +17,7 @@ http:
allocate_timeout: 60s
destroy_timeout: 60s
+# no global or local config
broadcast:
default:
driver: redis
diff --git a/tests/plugins/broadcast/configs/.rr-broadcast-global.yaml b/tests/plugins/broadcast/configs/.rr-broadcast-global.yaml
index 3216f875..c193af00 100644
--- a/tests/plugins/broadcast/configs/.rr-broadcast-global.yaml
+++ b/tests/plugins/broadcast/configs/.rr-broadcast-global.yaml
@@ -1,40 +1,52 @@
rpc:
- listen: tcp://127.0.0.1:6003
+ listen: tcp://127.0.0.1:6003
server:
- command: "php ../../psr-worker-bench.php"
- relay: "pipes"
- relay_timeout: "20s"
+ command: "php ../../psr-worker-bench.php"
+ relay: "pipes"
+ relay_timeout: "20s"
http:
- address: 127.0.0.1:21543
- max_request_size: 1024
- middleware: [ "websockets" ]
- trusted_subnets: [ "10.0.0.0/8", "127.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16", "::1/128", "fc00::/7", "fe80::/10" ]
- pool:
- num_workers: 2
- max_jobs: 0
- allocate_timeout: 60s
- destroy_timeout: 60s
+ address: 127.0.0.1:21543
+ max_request_size: 1024
+ middleware: ["websockets"]
+ trusted_subnets:
+ [
+ "10.0.0.0/8",
+ "127.0.0.0/8",
+ "172.16.0.0/12",
+ "192.168.0.0/16",
+ "::1/128",
+ "fc00::/7",
+ "fe80::/10",
+ ]
+ pool:
+ num_workers: 2
+ max_jobs: 0
+ allocate_timeout: 60s
+ destroy_timeout: 60s
-redis:
- addrs:
- - "127.0.0.1:6379"
-
-broadcast:
- test:
- driver: redis
- use: global
- test2:
- driver: redis
+test:
addrs:
- - "127.0.0.1:6378"
- test3:
- driver: memory
- test4:
- driver: memory
+ - "127.0.0.1:6379"
+broadcast:
+ test:
+ driver: redis
+ test2:
+ driver: redis
+ config:
+ addrs:
+ - "127.0.0.1:6378"
+ test3:
+ driver: memory
+ config:
+ placeholder: ""
+ test4:
+ driver: memory
+ config:
+ placeholder: ""
logs:
- mode: development
- level: info
+ mode: development
+ level: info
diff --git a/tests/plugins/broadcast/configs/.rr-broadcast-init.yaml b/tests/plugins/broadcast/configs/.rr-broadcast-init.yaml
index d8457578..1cbebdd7 100644
--- a/tests/plugins/broadcast/configs/.rr-broadcast-init.yaml
+++ b/tests/plugins/broadcast/configs/.rr-broadcast-init.yaml
@@ -22,8 +22,9 @@ http:
broadcast:
default:
driver: redis
- addrs:
- - "127.0.0.1:6379"
+ config:
+ addrs:
+ - "127.0.0.1:6379"
logs:
mode: development
diff --git a/tests/plugins/broadcast/configs/.rr-broadcast-same-section.yaml b/tests/plugins/broadcast/configs/.rr-broadcast-same-section.yaml
index 2337b8fe..f162aeba 100644
--- a/tests/plugins/broadcast/configs/.rr-broadcast-same-section.yaml
+++ b/tests/plugins/broadcast/configs/.rr-broadcast-same-section.yaml
@@ -1,36 +1,51 @@
rpc:
- listen: tcp://127.0.0.1:6002
+ listen: tcp://127.0.0.1:6002
server:
- command: "php ../../psr-worker-bench.php"
- relay: "pipes"
- relay_timeout: "20s"
+ command: "php ../../psr-worker-bench.php"
+ relay: "pipes"
+ relay_timeout: "20s"
http:
- address: 127.0.0.1:21345
- max_request_size: 1024
- middleware: [ "websockets" ]
- trusted_subnets: [ "10.0.0.0/8", "127.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16", "::1/128", "fc00::/7", "fe80::/10" ]
- pool:
- num_workers: 2
- max_jobs: 0
- allocate_timeout: 60s
- destroy_timeout: 60s
+ address: 127.0.0.1:21345
+ max_request_size: 1024
+ middleware: ["websockets"]
+ trusted_subnets:
+ [
+ "10.0.0.0/8",
+ "127.0.0.0/8",
+ "172.16.0.0/12",
+ "192.168.0.0/16",
+ "::1/128",
+ "fc00::/7",
+ "fe80::/10",
+ ]
+ pool:
+ num_workers: 2
+ max_jobs: 0
+ allocate_timeout: 60s
+ destroy_timeout: 60s
broadcast:
- test:
- driver: redis
- addrs:
- - "127.0.0.1:6379"
- test2:
- driver: redis
- addrs:
- - "127.0.0.1:6378"
- test3:
- driver: memory
- test4:
- driver: memory
+ test:
+ driver: redis
+ config:
+ addrs:
+ - "127.0.0.1:6379"
+ test2:
+ driver: redis
+ config:
+ addrs:
+ - "127.0.0.1:6378"
+ test3:
+ driver: memory
+ config:
+ placeholder: ""
+ test4:
+ driver: memory
+ config:
+ placeholder: ""
logs:
- mode: development
- level: info
+ mode: development
+ level: info
diff --git a/tests/plugins/kv/configs/.rr-boltdb.yaml b/tests/plugins/kv/configs/.rr-boltdb.yaml
index 81b47715..7a8aee4e 100644
--- a/tests/plugins/kv/configs/.rr-boltdb.yaml
+++ b/tests/plugins/kv/configs/.rr-boltdb.yaml
@@ -1,15 +1,16 @@
rpc:
- listen: tcp://127.0.0.1:6001
+ listen: tcp://127.0.0.1:6001
logs:
- mode: development
- level: error
+ mode: development
+ level: error
kv:
- boltdb-rr:
- driver: boltdb
- dir: "."
- file: "rr.db"
- bucket: "test"
- permissions: 0666
- interval: 1 # seconds
+ boltdb-rr:
+ driver: boltdb
+ config:
+ dir: "."
+ file: "rr.db"
+ bucket: "test"
+ permissions: 0666
+ interval: 1 # seconds
diff --git a/tests/plugins/kv/configs/.rr-in-memory.yaml b/tests/plugins/kv/configs/.rr-in-memory.yaml
index b3b01f46..0452d8bc 100644
--- a/tests/plugins/kv/configs/.rr-in-memory.yaml
+++ b/tests/plugins/kv/configs/.rr-in-memory.yaml
@@ -1,11 +1,12 @@
rpc:
- listen: tcp://127.0.0.1:6001
+ listen: tcp://127.0.0.1:6001
logs:
- mode: development
- level: error
+ mode: development
+ level: error
kv:
- memory-rr:
- driver: memory
- interval: 1
+ memory-rr:
+ driver: memory
+ config:
+ interval: 1
diff --git a/tests/plugins/kv/configs/.rr-kv-bolt-no-interval.yaml b/tests/plugins/kv/configs/.rr-kv-bolt-no-interval.yaml
index 471e5c77..476369c5 100644
--- a/tests/plugins/kv/configs/.rr-kv-bolt-no-interval.yaml
+++ b/tests/plugins/kv/configs/.rr-kv-bolt-no-interval.yaml
@@ -1,17 +1,19 @@
rpc:
- listen: tcp://127.0.0.1:6001
+ listen: tcp://127.0.0.1:6001
logs:
- mode: development
- level: error
+ mode: development
+ level: error
kv:
- boltdb-south:
- driver: boltdb
- file: "rr.db"
- permissions: 755
+ boltdb-south:
+ driver: boltdb
+ config:
+ file: "rr.db"
+ permissions: 755
- boltdb-africa:
- driver: boltdb
- file: "africa.db"
- permissions: 755
+ boltdb-africa:
+ driver: boltdb
+ config:
+ file: "africa.db"
+ permissions: 755
diff --git a/tests/plugins/kv/configs/.rr-kv-bolt-perms.yaml b/tests/plugins/kv/configs/.rr-kv-bolt-perms.yaml
index b46bcb1c..e7728972 100644
--- a/tests/plugins/kv/configs/.rr-kv-bolt-perms.yaml
+++ b/tests/plugins/kv/configs/.rr-kv-bolt-perms.yaml
@@ -1,16 +1,18 @@
rpc:
- listen: tcp://127.0.0.1:6001
+ listen: tcp://127.0.0.1:6001
logs:
- mode: development
- level: error
+ mode: development
+ level: error
kv:
- boltdb-south:
- driver: boltdb
- file: "rr.db"
+ boltdb-south:
+ driver: boltdb
+ config:
+ file: "rr.db"
- boltdb-africa:
- driver: boltdb
- file: "africa.db"
- permissions: 0777
+ boltdb-africa:
+ driver: boltdb
+ config:
+ file: "africa.db"
+ permissions: 0777
diff --git a/tests/plugins/kv/configs/.rr-kv-init.yaml b/tests/plugins/kv/configs/.rr-kv-init.yaml
index 6407c7ad..10cf6491 100644
--- a/tests/plugins/kv/configs/.rr-kv-init.yaml
+++ b/tests/plugins/kv/configs/.rr-kv-init.yaml
@@ -1,30 +1,35 @@
rpc:
- listen: tcp://127.0.0.1:6001
+ listen: tcp://127.0.0.1:6001
logs:
- mode: development
- level: error
+ mode: development
+ level: error
kv:
- default:
- driver: memory
+ default:
+ driver: memory
+ config:
+ interval: 60
- boltdb-south:
- driver: boltdb
- dir: "."
- file: "rr.db"
- bucket: "rr"
- permissions: 0666
- interval: 1
+ boltdb-south:
+ driver: boltdb
+ config:
+ dir: "."
+ file: "rr.db"
+ bucket: "rr"
+ permissions: 0666
+ interval: 1
- boltdb-africa:
- driver: boltdb
- dir: "."
- file: "africa.db"
- bucket: "rr"
- permissions: 0666
- interval: 1
+ boltdb-africa:
+ driver: boltdb
+ config:
+ dir: "."
+ file: "africa.db"
+ bucket: "rr"
+ permissions: 0666
+ interval: 1
- memcached:
- driver: memcached
- addr: [ "127.0.0.1:11211" ]
+ memcached:
+ driver: memcached
+ config:
+ addr: ["127.0.0.1:11211"]
diff --git a/tests/plugins/kv/configs/.rr-memcached.yaml b/tests/plugins/kv/configs/.rr-memcached.yaml
index da5d59c6..ef8de2ab 100644
--- a/tests/plugins/kv/configs/.rr-memcached.yaml
+++ b/tests/plugins/kv/configs/.rr-memcached.yaml
@@ -1,12 +1,13 @@
rpc:
- listen: tcp://127.0.0.1:6001
+ listen: tcp://127.0.0.1:6001
logs:
- mode: development
- level: error
+ mode: development
+ level: error
kv:
- memcached-rr:
- driver: memcached
- addr:
- - "127.0.0.1:11211"
+ memcached-rr:
+ driver: memcached
+ config:
+ addr:
+ - "127.0.0.1:11211"
diff --git a/tests/plugins/kv/configs/.rr-redis-global.yaml b/tests/plugins/kv/configs/.rr-redis-global.yaml
index a4979879..27377835 100644
--- a/tests/plugins/kv/configs/.rr-redis-global.yaml
+++ b/tests/plugins/kv/configs/.rr-redis-global.yaml
@@ -1,14 +1,14 @@
rpc:
- listen: tcp://127.0.0.1:6001
+ listen: tcp://127.0.0.1:6001
logs:
- mode: development
- level: error
+ mode: development
+ level: error
redis-rr:
- addrs:
- - '127.0.0.1:6379'
+ addrs:
+ - "127.0.0.1:6379"
kv:
- redis-rr:
- driver: redis
+ redis-rr:
+ driver: redis
diff --git a/tests/plugins/kv/configs/.rr-redis-no-config.yaml b/tests/plugins/kv/configs/.rr-redis-no-config.yaml
index 9cf06374..56113f13 100644
--- a/tests/plugins/kv/configs/.rr-redis-no-config.yaml
+++ b/tests/plugins/kv/configs/.rr-redis-no-config.yaml
@@ -1,10 +1,10 @@
rpc:
- listen: tcp://127.0.0.1:6001
+ listen: tcp://127.0.0.1:6001
logs:
- mode: development
- level: error
+ mode: development
+ level: error
kv:
- redis-rr:
- driver: redis
+ redis-rr:
+ driver: redis
diff --git a/tests/plugins/kv/configs/.rr-redis.yaml b/tests/plugins/kv/configs/.rr-redis.yaml
index 522e365a..f9b967d5 100644
--- a/tests/plugins/kv/configs/.rr-redis.yaml
+++ b/tests/plugins/kv/configs/.rr-redis.yaml
@@ -1,12 +1,13 @@
rpc:
- listen: tcp://127.0.0.1:6001
+ listen: tcp://127.0.0.1:6001
logs:
- mode: development
- level: error
+ mode: development
+ level: error
kv:
- redis-rr:
- driver: redis
- addrs:
- - '127.0.0.1:6379'
+ redis-rr:
+ driver: redis
+ config:
+ addrs:
+ - "127.0.0.1:6379"
diff --git a/tests/plugins/kv/storage_plugin_test.go b/tests/plugins/kv/storage_plugin_test.go
index e757a9e6..ec9e74fd 100644
--- a/tests/plugins/kv/storage_plugin_test.go
+++ b/tests/plugins/kv/storage_plugin_test.go
@@ -1308,48 +1308,8 @@ func TestRedisNoConfig(t *testing.T) {
t.Fatal(err)
}
- ch, err := cont.Serve()
- assert.NoError(t, err)
-
- sig := make(chan os.Signal, 1)
- signal.Notify(sig, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
-
- wg := &sync.WaitGroup{}
- wg.Add(1)
-
- stopCh := make(chan struct{}, 1)
-
- go func() {
- defer wg.Done()
- for {
- select {
- case e := <-ch:
- assert.Fail(t, "error", e.Error.Error())
- err = cont.Stop()
- if err != nil {
- assert.FailNow(t, "error", err.Error())
- }
- case <-sig:
- err = cont.Stop()
- if err != nil {
- assert.FailNow(t, "error", err.Error())
- }
- return
- case <-stopCh:
- // timeout
- err = cont.Stop()
- if err != nil {
- assert.FailNow(t, "error", err.Error())
- }
- return
- }
- }
- }()
-
- time.Sleep(time.Second * 1)
- t.Run("REDIS", testRPCMethodsRedis)
- stopCh <- struct{}{}
- wg.Wait()
+ _, err = cont.Serve()
+ assert.Error(t, err)
}
func testRPCMethodsRedis(t *testing.T) {
diff --git a/tests/plugins/websockets/configs/.rr-websockets-allow.yaml b/tests/plugins/websockets/configs/.rr-websockets-allow.yaml
index 900094a4..cf48176c 100644
--- a/tests/plugins/websockets/configs/.rr-websockets-allow.yaml
+++ b/tests/plugins/websockets/configs/.rr-websockets-allow.yaml
@@ -1,42 +1,53 @@
rpc:
- listen: tcp://127.0.0.1:6001
+ listen: tcp://127.0.0.1:6001
server:
- command: "php ../../worker-ok.php"
- user: ""
- group: ""
- relay: "pipes"
- relay_timeout: "20s"
+ command: "php ../../worker-ok.php"
+ user: ""
+ group: ""
+ relay: "pipes"
+ relay_timeout: "20s"
http:
- address: 127.0.0.1:41278
- max_request_size: 1024
- middleware: [ "websockets" ]
- trusted_subnets: [ "10.0.0.0/8", "127.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16", "::1/128", "fc00::/7", "fe80::/10" ]
- pool:
- num_workers: 2
- max_jobs: 0
- allocate_timeout: 60s
- destroy_timeout: 60s
+ address: 127.0.0.1:41278
+ max_request_size: 1024
+ middleware: ["websockets"]
+ trusted_subnets:
+ [
+ "10.0.0.0/8",
+ "127.0.0.0/8",
+ "172.16.0.0/12",
+ "192.168.0.0/16",
+ "::1/128",
+ "fc00::/7",
+ "fe80::/10",
+ ]
+ pool:
+ num_workers: 2
+ max_jobs: 0
+ allocate_timeout: 60s
+ destroy_timeout: 60s
redis:
- addrs:
- - "127.0.0.1:6379"
+ addrs:
+ - "127.0.0.1:6379"
broadcast:
- test:
- driver: memory
+ test:
+ driver: memory
+ config:
+ placeholder: ""
websockets:
- broker: test
- allowed_origin: "*"
- path: "/ws"
+ broker: test
+ allowed_origin: "*"
+ path: "/ws"
logs:
- mode: development
- level: error
+ mode: development
+ level: error
endure:
- grace_period: 120s
- print_graph: false
- log_level: error
+ grace_period: 120s
+ print_graph: false
+ log_level: error
diff --git a/tests/plugins/websockets/configs/.rr-websockets-allow2.yaml b/tests/plugins/websockets/configs/.rr-websockets-allow2.yaml
index 43f4b2ec..f8e36136 100644
--- a/tests/plugins/websockets/configs/.rr-websockets-allow2.yaml
+++ b/tests/plugins/websockets/configs/.rr-websockets-allow2.yaml
@@ -1,44 +1,54 @@
rpc:
- listen: tcp://127.0.0.1:6001
+ listen: tcp://127.0.0.1:6001
server:
- command: "php ../../worker-ok.php"
- user: ""
- group: ""
- relay: "pipes"
- relay_timeout: "20s"
+ command: "php ../../worker-ok.php"
+ user: ""
+ group: ""
+ relay: "pipes"
+ relay_timeout: "20s"
http:
- address: 127.0.0.1:41270
- max_request_size: 1024
- middleware: [ "websockets" ]
- trusted_subnets: [ "10.0.0.0/8", "127.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16", "::1/128", "fc00::/7", "fe80::/10" ]
- pool:
- num_workers: 2
- max_jobs: 0
- allocate_timeout: 60s
- destroy_timeout: 60s
+ address: 127.0.0.1:41270
+ max_request_size: 1024
+ middleware: ["websockets"]
+ trusted_subnets:
+ [
+ "10.0.0.0/8",
+ "127.0.0.0/8",
+ "172.16.0.0/12",
+ "192.168.0.0/16",
+ "::1/128",
+ "fc00::/7",
+ "fe80::/10",
+ ]
+ pool:
+ num_workers: 2
+ max_jobs: 0
+ allocate_timeout: 60s
+ destroy_timeout: 60s
-redis:
- addrs:
- - "127.0.0.1:6379"
+test:
+ addrs:
+ - "127.0.0.1:6379"
broadcast:
- test:
- driver: redis
- addrs:
- - "127.0.0.1:6379"
+ test:
+ driver: redis
+ config:
+ addrs:
+ - "127.0.0.1:6379"
websockets:
- broker: test
- allowed_origin: "*"
- path: "/ws"
+ broker: test
+ allowed_origin: "*"
+ path: "/ws"
logs:
- mode: development
- level: error
+ mode: development
+ level: error
endure:
- grace_period: 120s
- print_graph: false
- log_level: error
+ grace_period: 120s
+ print_graph: false
+ log_level: error
diff --git a/tests/plugins/websockets/configs/.rr-websockets-broker-no-section.yaml b/tests/plugins/websockets/configs/.rr-websockets-broker-no-section.yaml
index ada23845..c72e1f15 100644
--- a/tests/plugins/websockets/configs/.rr-websockets-broker-no-section.yaml
+++ b/tests/plugins/websockets/configs/.rr-websockets-broker-no-section.yaml
@@ -1,38 +1,48 @@
rpc:
- listen: tcp://127.0.0.1:6001
+ listen: tcp://127.0.0.1:6001
server:
- command: "php ../../psr-worker-bench.php"
- user: ""
- group: ""
- relay: "pipes"
- relay_timeout: "20s"
+ command: "php ../../psr-worker-bench.php"
+ user: ""
+ group: ""
+ relay: "pipes"
+ relay_timeout: "20s"
http:
- address: 127.0.0.1:13235
- max_request_size: 1024
- middleware: [ "websockets" ]
- trusted_subnets: [ "10.0.0.0/8", "127.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16", "::1/128", "fc00::/7", "fe80::/10" ]
- pool:
- num_workers: 2
- max_jobs: 0
- allocate_timeout: 60s
- destroy_timeout: 60s
+ address: 127.0.0.1:13235
+ max_request_size: 1024
+ middleware: ["websockets"]
+ trusted_subnets:
+ [
+ "10.0.0.0/8",
+ "127.0.0.0/8",
+ "172.16.0.0/12",
+ "192.168.0.0/16",
+ "::1/128",
+ "fc00::/7",
+ "fe80::/10",
+ ]
+ pool:
+ num_workers: 2
+ max_jobs: 0
+ allocate_timeout: 60s
+ destroy_timeout: 60s
broadcast:
- test1:
- driver: no
+ test1:
+ driver: no
+ config:
websockets:
- broker: test
- allowed_origin: "*"
- path: "/ws"
+ broker: test
+ allowed_origin: "*"
+ path: "/ws"
logs:
- mode: development
- level: error
+ mode: development
+ level: error
endure:
- grace_period: 120s
- print_graph: false
- log_level: error
+ grace_period: 120s
+ print_graph: false
+ log_level: error
diff --git a/tests/plugins/websockets/configs/.rr-websockets-deny.yaml b/tests/plugins/websockets/configs/.rr-websockets-deny.yaml
index 594a746d..6ad6628c 100644
--- a/tests/plugins/websockets/configs/.rr-websockets-deny.yaml
+++ b/tests/plugins/websockets/configs/.rr-websockets-deny.yaml
@@ -1,38 +1,49 @@
rpc:
- listen: tcp://127.0.0.1:6001
+ listen: tcp://127.0.0.1:6001
server:
- command: "php ../../worker-deny.php"
- user: ""
- group: ""
- relay: "pipes"
- relay_timeout: "20s"
+ command: "php ../../worker-deny.php"
+ user: ""
+ group: ""
+ relay: "pipes"
+ relay_timeout: "20s"
http:
- address: 127.0.0.1:15587
- max_request_size: 1024
- middleware: [ "websockets" ]
- trusted_subnets: [ "10.0.0.0/8", "127.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16", "::1/128", "fc00::/7", "fe80::/10" ]
- pool:
- num_workers: 2
- max_jobs: 0
- allocate_timeout: 60s
- destroy_timeout: 60s
+ address: 127.0.0.1:15587
+ max_request_size: 1024
+ middleware: ["websockets"]
+ trusted_subnets:
+ [
+ "10.0.0.0/8",
+ "127.0.0.0/8",
+ "172.16.0.0/12",
+ "192.168.0.0/16",
+ "::1/128",
+ "fc00::/7",
+ "fe80::/10",
+ ]
+ pool:
+ num_workers: 2
+ max_jobs: 0
+ allocate_timeout: 60s
+ destroy_timeout: 60s
broadcast:
- test:
- driver: memory
+ test:
+ driver: memory
+ config:
+ placeholder: ""
websockets:
- broker: test
- allowed_origin: "*"
- path: "/ws"
+ broker: test
+ allowed_origin: "*"
+ path: "/ws"
logs:
- mode: development
- level: error
+ mode: development
+ level: error
endure:
- grace_period: 120s
- print_graph: false
- log_level: error
+ grace_period: 120s
+ print_graph: false
+ log_level: error
diff --git a/tests/plugins/websockets/configs/.rr-websockets-deny2.yaml b/tests/plugins/websockets/configs/.rr-websockets-deny2.yaml
index e0bdf993..b99a3571 100644
--- a/tests/plugins/websockets/configs/.rr-websockets-deny2.yaml
+++ b/tests/plugins/websockets/configs/.rr-websockets-deny2.yaml
@@ -1,40 +1,50 @@
rpc:
- listen: tcp://127.0.0.1:6001
+ listen: tcp://127.0.0.1:6001
server:
- command: "php ../../worker-deny.php"
- user: ""
- group: ""
- relay: "pipes"
- relay_timeout: "20s"
+ command: "php ../../worker-deny.php"
+ user: ""
+ group: ""
+ relay: "pipes"
+ relay_timeout: "20s"
http:
- address: 127.0.0.1:15588
- max_request_size: 1024
- middleware: [ "websockets" ]
- trusted_subnets: [ "10.0.0.0/8", "127.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16", "::1/128", "fc00::/7", "fe80::/10" ]
- pool:
- num_workers: 2
- max_jobs: 0
- allocate_timeout: 60s
- destroy_timeout: 60s
+ address: 127.0.0.1:15588
+ max_request_size: 1024
+ middleware: ["websockets"]
+ trusted_subnets:
+ [
+ "10.0.0.0/8",
+ "127.0.0.0/8",
+ "172.16.0.0/12",
+ "192.168.0.0/16",
+ "::1/128",
+ "fc00::/7",
+ "fe80::/10",
+ ]
+ pool:
+ num_workers: 2
+ max_jobs: 0
+ allocate_timeout: 60s
+ destroy_timeout: 60s
broadcast:
- test:
- driver: redis
- addrs:
- - "127.0.0.1:6379"
+ test:
+ driver: redis
+ config:
+ addrs:
+ - "127.0.0.1:6379"
websockets:
- broker: test
- allowed_origin: "*"
- path: "/ws"
+ broker: test
+ allowed_origin: "*"
+ path: "/ws"
logs:
- mode: development
- level: error
+ mode: development
+ level: error
endure:
- grace_period: 120s
- print_graph: false
- log_level: error
+ grace_period: 120s
+ print_graph: false
+ log_level: error
diff --git a/tests/plugins/websockets/configs/.rr-websockets-init.yaml b/tests/plugins/websockets/configs/.rr-websockets-init.yaml
index 115f9a71..733de25c 100644
--- a/tests/plugins/websockets/configs/.rr-websockets-init.yaml
+++ b/tests/plugins/websockets/configs/.rr-websockets-init.yaml
@@ -1,39 +1,55 @@
rpc:
- listen: tcp://127.0.0.1:6001
+ listen: tcp://127.0.0.1:6001
server:
- command: "php ../../psr-worker-bench.php"
- user: ""
- group: ""
- relay: "pipes"
- relay_timeout: "20s"
+ command: "php ../../psr-worker-bench.php"
+ user: ""
+ group: ""
+ relay: "pipes"
+ relay_timeout: "20s"
http:
- address: 127.0.0.1:11111
- max_request_size: 1024
- middleware: [ "websockets" ]
- trusted_subnets: [ "10.0.0.0/8", "127.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16", "::1/128", "fc00::/7", "fe80::/10" ]
- pool:
- num_workers: 2
- max_jobs: 0
- allocate_timeout: 60s
- destroy_timeout: 60s
+ address: 127.0.0.1:11111
+ max_request_size: 1024
+ middleware: ["websockets"]
+ trusted_subnets:
+ [
+ "10.0.0.0/8",
+ "127.0.0.0/8",
+ "172.16.0.0/12",
+ "192.168.0.0/16",
+ "::1/128",
+ "fc00::/7",
+ "fe80::/10",
+ ]
+ pool:
+ num_workers: 2
+ max_jobs: 0
+ allocate_timeout: 60s
+ destroy_timeout: 60s
broadcast:
- default:
- driver: memory
+ default:
+ driver: memory
+ # %YAML 1.1
+ #---
+ # !!map {
+ # ? !!str "key"
+ # : !!null "null",
+ #}
+ config:
+ placeholder: ""
websockets:
- broker: default
- allowed_origin: "*"
- path: "/ws"
-
+ broker: default
+ allowed_origin: "*"
+ path: "/ws"
logs:
- mode: development
- level: error
+ mode: development
+ level: error
endure:
- grace_period: 120s
- print_graph: false
- log_level: error
+ grace_period: 120s
+ print_graph: false
+ log_level: error
diff --git a/tests/plugins/websockets/configs/.rr-websockets-redis.yaml b/tests/plugins/websockets/configs/.rr-websockets-redis.yaml
index e3d5f0b8..fc01e0b1 100644
--- a/tests/plugins/websockets/configs/.rr-websockets-redis.yaml
+++ b/tests/plugins/websockets/configs/.rr-websockets-redis.yaml
@@ -1,42 +1,51 @@
rpc:
- listen: tcp://127.0.0.1:6001
+ listen: tcp://127.0.0.1:6001
server:
- command: "php ../../psr-worker-bench.php"
- user: ""
- group: ""
- relay: "pipes"
- relay_timeout: "20s"
+ command: "php ../../psr-worker-bench.php"
+ user: ""
+ group: ""
+ relay: "pipes"
+ relay_timeout: "20s"
http:
- address: 127.0.0.1:13235
- max_request_size: 1024
- middleware: [ "websockets" ]
- trusted_subnets: [ "10.0.0.0/8", "127.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16", "::1/128", "fc00::/7", "fe80::/10" ]
- pool:
- num_workers: 2
- max_jobs: 0
- allocate_timeout: 60s
- destroy_timeout: 60s
+ address: 127.0.0.1:13235
+ max_request_size: 1024
+ middleware: ["websockets"]
+ trusted_subnets:
+ [
+ "10.0.0.0/8",
+ "127.0.0.0/8",
+ "172.16.0.0/12",
+ "192.168.0.0/16",
+ "::1/128",
+ "fc00::/7",
+ "fe80::/10",
+ ]
+ pool:
+ num_workers: 2
+ max_jobs: 0
+ allocate_timeout: 60s
+ destroy_timeout: 60s
-redis:
- addrs:
- - "127.0.0.1:6379"
+test:
+ addrs:
+ - "127.0.0.1:6379"
broadcast:
- test:
- driver: redis
+ test:
+ driver: redis
websockets:
- broker: test
- allowed_origin: "*"
- path: "/ws"
+ broker: test
+ allowed_origin: "*"
+ path: "/ws"
logs:
- mode: development
- level: error
+ mode: development
+ level: error
endure:
- grace_period: 120s
- print_graph: false
- log_level: error
+ grace_period: 120s
+ print_graph: false
+ log_level: error
diff --git a/tests/plugins/websockets/configs/.rr-websockets-stop.yaml b/tests/plugins/websockets/configs/.rr-websockets-stop.yaml
index 5377aef2..af1f57d4 100644
--- a/tests/plugins/websockets/configs/.rr-websockets-stop.yaml
+++ b/tests/plugins/websockets/configs/.rr-websockets-stop.yaml
@@ -1,38 +1,49 @@
rpc:
- listen: tcp://127.0.0.1:6001
+ listen: tcp://127.0.0.1:6001
server:
- command: "php ../../worker-stop.php"
- user: ""
- group: ""
- relay: "pipes"
- relay_timeout: "20s"
+ command: "php ../../worker-stop.php"
+ user: ""
+ group: ""
+ relay: "pipes"
+ relay_timeout: "20s"
http:
- address: 127.0.0.1:11114
- max_request_size: 1024
- middleware: [ "websockets" ]
- trusted_subnets: [ "10.0.0.0/8", "127.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16", "::1/128", "fc00::/7", "fe80::/10" ]
- pool:
- num_workers: 2
- max_jobs: 0
- allocate_timeout: 60s
- destroy_timeout: 60s
+ address: 127.0.0.1:11114
+ max_request_size: 1024
+ middleware: ["websockets"]
+ trusted_subnets:
+ [
+ "10.0.0.0/8",
+ "127.0.0.0/8",
+ "172.16.0.0/12",
+ "192.168.0.0/16",
+ "::1/128",
+ "fc00::/7",
+ "fe80::/10",
+ ]
+ pool:
+ num_workers: 2
+ max_jobs: 0
+ allocate_timeout: 60s
+ destroy_timeout: 60s
broadcast:
- test:
- driver: memory
+ test:
+ driver: memory
+ config:
+ placeholder: ""
websockets:
- broker: test
- allowed_origin: "*"
- path: "/ws"
+ broker: test
+ allowed_origin: "*"
+ path: "/ws"
logs:
- mode: development
- level: error
+ mode: development
+ level: error
endure:
- grace_period: 120s
- print_graph: false
- log_level: error
+ grace_period: 120s
+ print_graph: false
+ log_level: error