diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/websockets/memory/inMemory.go (renamed from plugins/memory/plugin.go) | 24 | ||||
-rw-r--r-- | plugins/websockets/plugin.go | 6 |
2 files changed, 13 insertions, 17 deletions
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, |