diff options
author | Valery Piashchynski <[email protected]> | 2021-06-08 18:41:54 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2021-06-08 18:41:54 +0300 |
commit | a8baaaae403a556b6d5d76bc2f7eb46cca7bfb15 (patch) | |
tree | e7f43f625836456104bc0c39227b71e5e3cf848a | |
parent | 47c40407a7ca5f1391f4d3d504d0def166eac4e9 (diff) |
- Move ws memory pub-sub plugin into the websockets folder
- Update CHANGELOG
Signed-off-by: Valery Piashchynski <[email protected]>
-rw-r--r-- | CHANGELOG.md | 2 | ||||
-rw-r--r-- | plugins/websockets/memory/inMemory.go (renamed from plugins/memory/plugin.go) | 24 | ||||
-rw-r--r-- | plugins/websockets/plugin.go | 6 | ||||
-rw-r--r-- | tests/plugins/websockets/websocket_plugin_test.go | 5 |
4 files changed, 14 insertions, 23 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 80ee8681..6f4eb607 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ v2.3.0 (08.06.2021) - ✏️ Brand new `broadcast` plugin now has the name - `websockets` with broadcast capabilities. It can handle hundreds of thousands websocket connections very efficiently (~300k messages per second with 1k connected clients, in-memory bus on 2CPU cores and 1GB of RAM) -- ✏️ Flatbuffers binary messages for the `websockets` RPC calls under the hood. +- ✏️ Protobuf binary messages for the `websockets` RPC calls under the hood. - ✏️ Json-schemas for the config file v1.0 (it also registered in [schemastore.org](https://github.com/SchemaStore/schemastore/pull/1614)) - ✏️ `latest` docker image tag supported now (but we strongly recommend using a versioned tag (like `0.2.3`) instead) diff --git a/plugins/memory/plugin.go b/plugins/websockets/memory/inMemory.go index d724dff9..deb927ed 100644 --- a/plugins/memory/plugin.go +++ b/plugins/websockets/memory/inMemory.go @@ -4,15 +4,12 @@ import ( "sync" "github.com/spiral/roadrunner/v2/pkg/bst" + "github.com/spiral/roadrunner/v2/pkg/pubsub" "github.com/spiral/roadrunner/v2/pkg/pubsub/message" "github.com/spiral/roadrunner/v2/plugins/logger" "google.golang.org/protobuf/proto" ) -const ( - PluginName string = "memory" -) - type Plugin struct { sync.RWMutex log logger.Logger @@ -23,19 +20,12 @@ type Plugin struct { storage bst.Storage } -func (p *Plugin) Init(log logger.Logger) error { - p.log = log - p.pushCh = make(chan []byte, 10) - p.storage = bst.NewBST() - return nil -} - -// Available interface implementation for the plugin -func (p *Plugin) Available() {} - -// Name is endure.Named interface implementation -func (p *Plugin) Name() string { - return PluginName +func NewInMemory(log logger.Logger) pubsub.PubSub { + return &Plugin{ + log: log, + pushCh: make(chan []byte, 10), + storage: bst.NewBST(), + } } func (p *Plugin) Publish(message []byte) error { diff --git a/plugins/websockets/plugin.go b/plugins/websockets/plugin.go index 39a4e139..cf21fffa 100644 --- a/plugins/websockets/plugin.go +++ b/plugins/websockets/plugin.go @@ -23,6 +23,7 @@ import ( "github.com/spiral/roadrunner/v2/plugins/server" "github.com/spiral/roadrunner/v2/plugins/websockets/connection" "github.com/spiral/roadrunner/v2/plugins/websockets/executor" + "github.com/spiral/roadrunner/v2/plugins/websockets/memory" "github.com/spiral/roadrunner/v2/plugins/websockets/pool" "github.com/spiral/roadrunner/v2/plugins/websockets/validator" "google.golang.org/protobuf/proto" @@ -90,6 +91,11 @@ func (p *Plugin) Serve() chan error { p.Lock() defer p.Unlock() + // attach default driver + if len(p.pubsubs) == 0 { + p.pubsubs["memory"] = memory.NewInMemory(p.log) + } + p.phpPool, err = p.server.NewWorkerPool(context.Background(), phpPool.Config{ Debug: p.cfg.Pool.Debug, NumWorkers: p.cfg.Pool.NumWorkers, diff --git a/tests/plugins/websockets/websocket_plugin_test.go b/tests/plugins/websockets/websocket_plugin_test.go index 5f472106..593085b7 100644 --- a/tests/plugins/websockets/websocket_plugin_test.go +++ b/tests/plugins/websockets/websocket_plugin_test.go @@ -20,7 +20,6 @@ import ( "github.com/spiral/roadrunner/v2/plugins/config" httpPlugin "github.com/spiral/roadrunner/v2/plugins/http" "github.com/spiral/roadrunner/v2/plugins/logger" - "github.com/spiral/roadrunner/v2/plugins/memory" "github.com/spiral/roadrunner/v2/plugins/redis" rpcPlugin "github.com/spiral/roadrunner/v2/plugins/rpc" "github.com/spiral/roadrunner/v2/plugins/server" @@ -168,7 +167,6 @@ func TestWSRedisAndMemory(t *testing.T) { &redis.Plugin{}, &websockets.Plugin{}, &httpPlugin.Plugin{}, - &memory.Plugin{}, ) assert.NoError(t, err) @@ -462,7 +460,6 @@ func TestWSMemoryDeny(t *testing.T) { &redis.Plugin{}, &websockets.Plugin{}, &httpPlugin.Plugin{}, - &memory.Plugin{}, ) assert.NoError(t, err) @@ -590,7 +587,6 @@ func TestWSMemoryStop(t *testing.T) { &redis.Plugin{}, &websockets.Plugin{}, &httpPlugin.Plugin{}, - &memory.Plugin{}, ) assert.NoError(t, err) @@ -683,7 +679,6 @@ func TestWSMemoryOk(t *testing.T) { &redis.Plugin{}, &websockets.Plugin{}, &httpPlugin.Plugin{}, - &memory.Plugin{}, ) assert.NoError(t, err) |