summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2021-05-12 08:49:27 +0300
committerValery Piashchynski <[email protected]>2021-05-12 08:49:27 +0300
commit8d675100ba4e77909b0dcea7ad60ae4cbbe8ff37 (patch)
tree1271381601550d4f4d07364c0d78aad582b978ca /plugins
parentf6ba3c077ccbc572eda26701b9dbacaf9fa453b9 (diff)
- Update diagramm
- Remove old code Signed-off-by: Valery Piashchynski <[email protected]>
Diffstat (limited to 'plugins')
-rw-r--r--plugins/broadcast/doc/broadcast.drawio152
-rw-r--r--plugins/broadcast/interface.go2
-rw-r--r--plugins/broadcast/old/redis.go172
-rw-r--r--plugins/broadcast/old/redis_test.go98
-rw-r--r--plugins/broadcast/plugin.go10
-rw-r--r--plugins/broadcast/redis/storage.go1
-rw-r--r--plugins/broadcast/ws/config.go1
-rw-r--r--plugins/broadcast/ws/plugin.go1
-rw-r--r--plugins/broadcast/ws/subscriber.go1
9 files changed, 161 insertions, 277 deletions
diff --git a/plugins/broadcast/doc/broadcast.drawio b/plugins/broadcast/doc/broadcast.drawio
index f610396d..2339f5b1 100644
--- a/plugins/broadcast/doc/broadcast.drawio
+++ b/plugins/broadcast/doc/broadcast.drawio
@@ -1 +1,151 @@
-<mxfile host="Electron" modified="2021-05-06T16:04:55.563Z" agent="5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/14.5.1 Chrome/89.0.4389.128 Electron/12.0.6 Safari/537.36" etag="VqUxZH_MlIcOLQiFtrvy" version="14.5.1" type="device"><diagram id="fD2kwGC0DAS2S_q_IsmE" name="Page-1">7VtZc+I4EP41VM08QNnyySNHrppkkgnJzmRfpoQtwBtjsbIJML9+JR/YsoTDYSCp2iRF7JYspO6vT8kNrTddXhE4m9xhF/kNoLjLhtZvAKBqBqD/GGWVUCzbTAhj4rlpp5ww8P6glKik1LnnopDrGGHsR96MJzo4CJATcTRICF7w3UbY5791BsdIIAwc6IvUn54bTVJqG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//CyHHypI3WzlRngV5GRJxGXtFkkLoZ5VO35mKzQ+RLPP909RWu4Q7ozRQfYcY5Cg766H/0+207wpNObN2OoB0rgKOKub8nbsfB8b/+26zH2SUy9vsprFlxlDHNruct/Y51WWXs1wfQV2sLdVlQ13uuNm+WnpLy3gn2y/31+zd3uoq9T/SgWsxlZK/xPH5ird2paloKi0tw1vG8Fo8fZMflIZlLU3nB6mlkFOpQZJUbu6Xo3Hfyyi9CXJe46WPvZDKErEUJGIpS1gI3fP+4giPyPVIYVPVJZSDpPJhSizO6RBnU0oS6vAkpXjNkOToqiUpNO/hSeht/h55goT8dXzt4j8=</diagram></mxfile> \ No newline at end of file
+<mxfile>
+ <diagram id="fD2kwGC0DAS2S_q_IsmE" name="Page-1">
+ <mxGraphModel dx="1582" dy="1094" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1920" pageHeight="1200" math="0" shadow="0">
+ <root>
+ <mxCell id="0"/>
+ <mxCell id="1" parent="0"/>
+ <mxCell id="y4MLTYBancT3lkQri0nA-9" style="edgeStyle=orthogonalEdgeStyle;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;" parent="1" source="y4MLTYBancT3lkQri0nA-1" edge="1">
+ <mxGeometry relative="1" as="geometry">
+ <mxPoint x="620" y="440" as="targetPoint"/>
+ </mxGeometry>
+ </mxCell>
+ <mxCell id="CDYlmZ7dxupAKddLQDts-15" style="edgeStyle=orthogonalEdgeStyle;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.25;exitY=0;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;fillColor=#dae8fc;strokeColor=#6c8ebf;" parent="1" source="y4MLTYBancT3lkQri0nA-1" target="y4MLTYBancT3lkQri0nA-2" edge="1">
+ <mxGeometry relative="1" as="geometry">
+ <Array as="points">
+ <mxPoint x="460" y="240"/>
+ <mxPoint x="270" y="240"/>
+ </Array>
+ </mxGeometry>
+ </mxCell>
+ <mxCell id="34_DfmtK1x9xla_BCLYV-16" value="4" style="edgeStyle=orthogonalEdgeStyle;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.25;exitY=1;exitDx=0;exitDy=0;entryX=1;entryY=0.5;entryDx=0;entryDy=0;" parent="1" source="y4MLTYBancT3lkQri0nA-1" target="34_DfmtK1x9xla_BCLYV-17" edge="1">
+ <mxGeometry x="0.0526" y="10" relative="1" as="geometry">
+ <mxPoint x="459.72413793103465" y="510" as="targetPoint"/>
+ <mxPoint x="-10" y="10" as="offset"/>
+ </mxGeometry>
+ </mxCell>
+ <mxCell id="y4MLTYBancT3lkQri0nA-1" value="BROADCAST HUB (PLUGIN)" style="whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontColor=#000000;" parent="1" vertex="1">
+ <mxGeometry x="430" y="410" width="120" height="60" as="geometry"/>
+ </mxCell>
+ <mxCell id="y4MLTYBancT3lkQri0nA-5" style="edgeStyle=orthogonalEdgeStyle;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" parent="1" source="y4MLTYBancT3lkQri0nA-2" target="y4MLTYBancT3lkQri0nA-1" edge="1">
+ <mxGeometry relative="1" as="geometry"/>
+ </mxCell>
+ <mxCell id="34_DfmtK1x9xla_BCLYV-19" style="edgeStyle=orthogonalEdgeStyle;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.25;exitY=0;exitDx=0;exitDy=0;entryX=0.5;entryY=1;entryDx=0;entryDy=0;" parent="1" source="y4MLTYBancT3lkQri0nA-2" target="34_DfmtK1x9xla_BCLYV-1" edge="1">
+ <mxGeometry relative="1" as="geometry">
+ <Array as="points">
+ <mxPoint x="240" y="160"/>
+ <mxPoint x="696" y="160"/>
+ </Array>
+ </mxGeometry>
+ </mxCell>
+ <mxCell id="34_DfmtK1x9xla_BCLYV-22" value="6" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" parent="34_DfmtK1x9xla_BCLYV-19" vertex="1" connectable="0">
+ <mxGeometry x="-0.2172" relative="1" as="geometry">
+ <mxPoint x="108.62" y="-10" as="offset"/>
+ </mxGeometry>
+ </mxCell>
+ <mxCell id="y4MLTYBancT3lkQri0nA-2" value="WS" style="whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;fontColor=#333333;" parent="1" vertex="1">
+ <mxGeometry x="210" y="290" width="120" height="40" as="geometry"/>
+ </mxCell>
+ <mxCell id="y4MLTYBancT3lkQri0nA-6" style="edgeStyle=orthogonalEdgeStyle;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" parent="1" source="y4MLTYBancT3lkQri0nA-3" target="y4MLTYBancT3lkQri0nA-1" edge="1">
+ <mxGeometry relative="1" as="geometry"/>
+ </mxCell>
+ <mxCell id="34_DfmtK1x9xla_BCLYV-23" style="edgeStyle=orthogonalEdgeStyle;orthogonalLoop=1;jettySize=auto;html=1;exitX=0;exitY=0.5;exitDx=0;exitDy=0;" parent="1" source="y4MLTYBancT3lkQri0nA-3" edge="1">
+ <mxGeometry relative="1" as="geometry">
+ <mxPoint x="50" y="440.2068965517242" as="targetPoint"/>
+ </mxGeometry>
+ </mxCell>
+ <mxCell id="y4MLTYBancT3lkQri0nA-3" value="REDIS" style="whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;fontColor=#000000;" parent="1" vertex="1">
+ <mxGeometry x="210" y="420" width="120" height="40" as="geometry"/>
+ </mxCell>
+ <mxCell id="y4MLTYBancT3lkQri0nA-7" style="edgeStyle=orthogonalEdgeStyle;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0.5;entryY=1;entryDx=0;entryDy=0;" parent="1" source="y4MLTYBancT3lkQri0nA-4" target="y4MLTYBancT3lkQri0nA-1" edge="1">
+ <mxGeometry relative="1" as="geometry"/>
+ </mxCell>
+ <mxCell id="y4MLTYBancT3lkQri0nA-4" value="IN-MEMORY" style="whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontColor=#000000;" parent="1" vertex="1">
+ <mxGeometry x="210" y="560" width="120" height="40" as="geometry"/>
+ </mxCell>
+ <mxCell id="y4MLTYBancT3lkQri0nA-8" value="Collects sub-plugins" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;" parent="1" vertex="1">
+ <mxGeometry x="310" y="370" width="120" height="20" as="geometry"/>
+ </mxCell>
+ <mxCell id="34_DfmtK1x9xla_BCLYV-15" value="3" style="edgeStyle=orthogonalEdgeStyle;orthogonalLoop=1;jettySize=auto;html=1;exitX=0;exitY=0.75;exitDx=0;exitDy=0;entryX=1;entryY=0.75;entryDx=0;entryDy=0;" parent="1" source="y4MLTYBancT3lkQri0nA-10" target="y4MLTYBancT3lkQri0nA-1" edge="1">
+ <mxGeometry x="0.1429" y="15" relative="1" as="geometry">
+ <mxPoint as="offset"/>
+ </mxGeometry>
+ </mxCell>
+ <mxCell id="y4MLTYBancT3lkQri0nA-10" value="RPC BUS" style="whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontColor=#000000;" parent="1" vertex="1">
+ <mxGeometry x="620" y="410" width="120" height="60" as="geometry"/>
+ </mxCell>
+ <mxCell id="CDYlmZ7dxupAKddLQDts-6" style="edgeStyle=orthogonalEdgeStyle;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.75;entryY=0;entryDx=0;entryDy=0;fillColor=#dae8fc;strokeColor=#6c8ebf;" parent="1" source="CDYlmZ7dxupAKddLQDts-1" target="y4MLTYBancT3lkQri0nA-1" edge="1">
+ <mxGeometry relative="1" as="geometry"/>
+ </mxCell>
+ <mxCell id="CDYlmZ7dxupAKddLQDts-8" value="Connect to the GO endpoint (from the config)" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" parent="CDYlmZ7dxupAKddLQDts-6" vertex="1" connectable="0">
+ <mxGeometry x="-0.6679" y="-2" relative="1" as="geometry">
+ <mxPoint x="-33.3" y="-13" as="offset"/>
+ </mxGeometry>
+ </mxCell>
+ <mxCell id="CDYlmZ7dxupAKddLQDts-1" value="" style="aspect=fixed;html=1;points=[];align=center;image;fontSize=12;image=img/lib/azure2/general/Browser.svg;" parent="1" vertex="1">
+ <mxGeometry x="652.5" y="30" width="87.5" height="70" as="geometry"/>
+ </mxCell>
+ <mxCell id="34_DfmtK1x9xla_BCLYV-12" style="edgeStyle=orthogonalEdgeStyle;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=0;exitDx=0;exitDy=0;entryX=0.5;entryY=1;entryDx=0;entryDy=0;" parent="1" source="CDYlmZ7dxupAKddLQDts-3" target="y4MLTYBancT3lkQri0nA-10" edge="1">
+ <mxGeometry relative="1" as="geometry"/>
+ </mxCell>
+ <mxCell id="34_DfmtK1x9xla_BCLYV-20" value="2" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" parent="34_DfmtK1x9xla_BCLYV-12" vertex="1" connectable="0">
+ <mxGeometry x="0.2355" y="-1" relative="1" as="geometry">
+ <mxPoint x="9" y="12.69" as="offset"/>
+ </mxGeometry>
+ </mxCell>
+ <mxCell id="CDYlmZ7dxupAKddLQDts-3" value="PUBLISH" style="whiteSpace=wrap;html=1;" parent="1" vertex="1">
+ <mxGeometry x="636.25" y="568" width="87.5" height="30" as="geometry"/>
+ </mxCell>
+ <mxCell id="34_DfmtK1x9xla_BCLYV-11" value="1" style="edgeStyle=orthogonalEdgeStyle;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=0;exitDx=0;exitDy=0;entryX=0.5;entryY=1;entryDx=0;entryDy=0;" parent="1" source="CDYlmZ7dxupAKddLQDts-5" target="CDYlmZ7dxupAKddLQDts-3" edge="1">
+ <mxGeometry x="0.2" y="-10" relative="1" as="geometry">
+ <Array as="points">
+ <mxPoint x="680" y="620"/>
+ <mxPoint x="680" y="620"/>
+ </Array>
+ <mxPoint as="offset"/>
+ </mxGeometry>
+ </mxCell>
+ <mxCell id="CDYlmZ7dxupAKddLQDts-5" value="PHP" style="whiteSpace=wrap;html=1;" parent="1" vertex="1">
+ <mxGeometry x="620" y="628" width="120" height="30" as="geometry"/>
+ </mxCell>
+ <mxCell id="CDYlmZ7dxupAKddLQDts-9" value="Save the websocket connection" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;" parent="1" vertex="1">
+ <mxGeometry x="280" y="220" width="180" height="20" as="geometry"/>
+ </mxCell>
+ <mxCell id="34_DfmtK1x9xla_BCLYV-1" value="BROKER?? -&amp;gt; Subscriber" style="whiteSpace=wrap;html=1;" parent="1" vertex="1">
+ <mxGeometry x="653" y="100" width="87" height="30" as="geometry"/>
+ </mxCell>
+ <mxCell id="34_DfmtK1x9xla_BCLYV-9" value="&lt;p style=&quot;margin: 0px ; margin-top: 4px ; text-align: center ; text-decoration: underline&quot;&gt;&lt;b&gt;Structure&lt;/b&gt;&lt;/p&gt;&lt;hr&gt;&lt;p style=&quot;margin: 0px ; margin-left: 8px&quot;&gt;Topic = string&lt;br&gt;Payload = raw&lt;br&gt;&lt;/p&gt;&lt;p style=&quot;margin: 0px ; margin-left: 8px&quot;&gt;Broker = ws (from config) (hardcoded)&lt;br&gt;&lt;/p&gt;" style="verticalAlign=top;align=left;overflow=fill;fontSize=12;fontFamily=Helvetica;html=1;" parent="1" vertex="1">
+ <mxGeometry x="780" y="543" width="220" height="80" as="geometry"/>
+ </mxCell>
+ <mxCell id="34_DfmtK1x9xla_BCLYV-10" value="" style="endArrow=none;html=1;entryX=0;entryY=0.5;entryDx=0;entryDy=0;exitX=1;exitY=0.5;exitDx=0;exitDy=0;" parent="1" source="CDYlmZ7dxupAKddLQDts-3" target="34_DfmtK1x9xla_BCLYV-9" edge="1">
+ <mxGeometry width="50" height="50" relative="1" as="geometry">
+ <mxPoint x="740" y="608" as="sourcePoint"/>
+ <mxPoint x="790" y="558" as="targetPoint"/>
+ </mxGeometry>
+ </mxCell>
+ <mxCell id="34_DfmtK1x9xla_BCLYV-14" style="edgeStyle=orthogonalEdgeStyle;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0.5;entryY=1;entryDx=0;entryDy=0;" parent="1" source="34_DfmtK1x9xla_BCLYV-13" target="y4MLTYBancT3lkQri0nA-1" edge="1">
+ <mxGeometry relative="1" as="geometry"/>
+ </mxCell>
+ <mxCell id="34_DfmtK1x9xla_BCLYV-13" value="AMQP" style="whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontColor=#000000;" parent="1" vertex="1">
+ <mxGeometry x="210" y="658" width="120" height="40" as="geometry"/>
+ </mxCell>
+ <mxCell id="34_DfmtK1x9xla_BCLYV-18" style="edgeStyle=orthogonalEdgeStyle;orthogonalLoop=1;jettySize=auto;html=1;exitX=0;exitY=0.5;exitDx=0;exitDy=0;entryX=0.5;entryY=1;entryDx=0;entryDy=0;" parent="1" source="34_DfmtK1x9xla_BCLYV-17" target="y4MLTYBancT3lkQri0nA-2" edge="1">
+ <mxGeometry relative="1" as="geometry">
+ <Array as="points">
+ <mxPoint x="160" y="520"/>
+ <mxPoint x="160" y="380"/>
+ <mxPoint x="270" y="380"/>
+ </Array>
+ </mxGeometry>
+ </mxCell>
+ <mxCell id="34_DfmtK1x9xla_BCLYV-21" value="5" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" parent="34_DfmtK1x9xla_BCLYV-18" vertex="1" connectable="0">
+ <mxGeometry x="-0.317" y="3" relative="1" as="geometry">
+ <mxPoint x="-7" y="-10.34" as="offset"/>
+ </mxGeometry>
+ </mxCell>
+ <mxCell id="34_DfmtK1x9xla_BCLYV-17" value="&lt;ul&gt;&lt;li&gt;Check registered topics&lt;/li&gt;&lt;li&gt;Redirect to driver&lt;/li&gt;&lt;/ul&gt;" style="whiteSpace=wrap;html=1;align=left;" parent="1" vertex="1">
+ <mxGeometry x="240" y="500" width="175" height="40" as="geometry"/>
+ </mxCell>
+ </root>
+ </mxGraphModel>
+ </diagram>
+</mxfile> \ No newline at end of file
diff --git a/plugins/broadcast/interface.go b/plugins/broadcast/interface.go
index 093943af..716b3aac 100644
--- a/plugins/broadcast/interface.go
+++ b/plugins/broadcast/interface.go
@@ -18,7 +18,7 @@ type Subscriber interface {
}
type Storage interface {
-
+ Store()
}
type Publisher interface {
diff --git a/plugins/broadcast/old/redis.go b/plugins/broadcast/old/redis.go
deleted file mode 100644
index 62970bc2..00000000
--- a/plugins/broadcast/old/redis.go
+++ /dev/null
@@ -1,172 +0,0 @@
-package old
-
-import (
- "context"
- "errors"
- "sync/atomic"
-
- "github.com/go-redis/redis/v8"
-)
-
-// Redis based broadcast Router.
-type Redis struct {
- client redis.UniversalClient
- psClient redis.UniversalClient
- router *Router
- messages chan *Message
- listen, leave chan subscriber
- stop chan interface{}
- stopped int32
-}
-
-// creates new redis broker
-func redisBroker(cfg *RedisConfig) (*Redis, error) {
- client := cfg.redisClient()
- if _, err := client.Ping(context.Background()).Result(); err != nil {
- return nil, err
- }
-
- psClient := cfg.redisClient()
- if _, err := psClient.Ping(context.Background()).Result(); err != nil {
- return nil, err
- }
-
- return &Redis{
- client: client,
- psClient: psClient,
- router: NewRouter(),
- messages: make(chan *Message),
- listen: make(chan subscriber),
- leave: make(chan subscriber),
- stop: make(chan interface{}),
- stopped: 0,
- }, nil
-}
-
-// Serve serves broker.
-func (r *Redis) Serve() error {
- pubsub := r.psClient.Subscribe(context.Background())
- channel := pubsub.Channel()
-
- for {
- select {
- case ctx := <-r.listen:
- ctx.done <- r.handleJoin(ctx, pubsub)
- case ctx := <-r.leave:
- ctx.done <- r.handleLeave(ctx, pubsub)
- case msg := <-channel:
- r.router.Dispatch(&Message{
- Topic: msg.Channel,
- Payload: []byte(msg.Payload),
- })
- case <-r.stop:
- return nil
- }
- }
-}
-
-func (r *Redis) handleJoin(sub subscriber, pubsub *redis.PubSub) error {
- if sub.pattern != "" {
- newPatterns, err := r.router.SubscribePattern(sub.upstream, sub.pattern)
- if err != nil || len(newPatterns) == 0 {
- return err
- }
-
- return pubsub.PSubscribe(context.Background(), newPatterns...)
- }
-
- newTopics := r.router.Subscribe(sub.upstream, sub.topics...)
- if len(newTopics) == 0 {
- return nil
- }
-
- return pubsub.Subscribe(context.Background(), newTopics...)
-}
-
-func (r *Redis) handleLeave(sub subscriber, pubsub *redis.PubSub) error {
- if sub.pattern != "" {
- dropPatterns := r.router.UnsubscribePattern(sub.upstream, sub.pattern)
- if len(dropPatterns) == 0 {
- return nil
- }
-
- return pubsub.PUnsubscribe(context.Background(), dropPatterns...)
- }
-
- dropTopics := r.router.Unsubscribe(sub.upstream, sub.topics...)
- if len(dropTopics) == 0 {
- return nil
- }
-
- return pubsub.Unsubscribe(context.Background(), dropTopics...)
-}
-
-// Stop closes the consumption and disconnects broker.
-func (r *Redis) Stop() {
- if atomic.CompareAndSwapInt32(&r.stopped, 0, 1) {
- close(r.stop)
- }
-}
-
-// Subscribe broker to one or multiple channels.
-func (r *Redis) Subscribe(upstream chan *Message, topics ...string) error {
- if atomic.LoadInt32(&r.stopped) == 1 {
- return errors.New("broker has been stopped")
- }
-
- ctx := subscriber{upstream: upstream, topics: topics, done: make(chan error)}
-
- r.listen <- ctx
- return <-ctx.done
-}
-
-// SubscribePattern broker to pattern.
-func (r *Redis) SubscribePattern(upstream chan *Message, pattern string) error {
- if atomic.LoadInt32(&r.stopped) == 1 {
- return errors.New("broker has been stopped")
- }
-
- ctx := subscriber{upstream: upstream, pattern: pattern, done: make(chan error)}
-
- r.listen <- ctx
- return <-ctx.done
-}
-
-// Unsubscribe broker from one or multiple channels.
-func (r *Redis) Unsubscribe(upstream chan *Message, topics ...string) error {
- if atomic.LoadInt32(&r.stopped) == 1 {
- return errors.New("broker has been stopped")
- }
-
- ctx := subscriber{upstream: upstream, topics: topics, done: make(chan error)}
-
- r.leave <- ctx
- return <-ctx.done
-}
-
-// UnsubscribePattern broker from pattern.
-func (r *Redis) UnsubscribePattern(upstream chan *Message, pattern string) error {
- if atomic.LoadInt32(&r.stopped) == 1 {
- return errors.New("broker has been stopped")
- }
-
- ctx := subscriber{upstream: upstream, pattern: pattern, done: make(chan error)}
-
- r.leave <- ctx
- return <-ctx.done
-}
-
-// Publish one or multiple Channel.
-func (r *Redis) Publish(messages ...*Message) error {
- if atomic.LoadInt32(&r.stopped) == 1 {
- return errors.New("broker has been stopped")
- }
-
- for _, msg := range messages {
- if err := r.client.Publish(context.Background(), msg.Topic, []byte(msg.Payload)).Err(); err != nil {
- return err
- }
- }
-
- return nil
-}
diff --git a/plugins/broadcast/old/redis_test.go b/plugins/broadcast/old/redis_test.go
deleted file mode 100644
index 8148c155..00000000
--- a/plugins/broadcast/old/redis_test.go
+++ /dev/null
@@ -1,98 +0,0 @@
-package old
-
-import (
- "fmt"
- "testing"
-
- "github.com/sirupsen/logrus"
- "github.com/sirupsen/logrus/hooks/test"
- "github.com/stretchr/testify/assert"
-)
-
-func TestRedis_Error(t *testing.T) {
- logger, _ := test.NewNullLogger()
- logger.SetLevel(logrus.DebugLevel)
-
- //c := service.NewContainer(logger)
- //c.Register(rpc.ID, &rpc.Service{})
- //c.Register(ID, &Service{})
- //
- //err := c.Init(&testCfg{
- // broadcast: `{"redis":{"addr":"localhost:6372"}}`,
- // rpc: fmt.Sprintf(`{"join":"tcp://:%v"}`, rpcPort),
- //})
-
- rpcPort++
-
- assert.Error(t, err)
-}
-
-func TestRedis_Broadcast(t *testing.T) {
- br, _, c := setup(`{"redis":{"addr":"localhost:6379"}}`)
- defer c.Stop()
-
- client := br.NewClient()
- defer client.Close()
-
- assert.NoError(t, br.Broker().Publish(newMessage("topic", "hello1"))) // must not be delivered
-
- assert.NoError(t, client.Subscribe("topic"))
-
- assert.NoError(t, br.Broker().Publish(newMessage("topic", "hello1")))
- assert.Equal(t, `hello1`, readStr(<-client.Channel()))
-
- assert.NoError(t, br.Broker().Publish(newMessage("topic", "hello2")))
- assert.Equal(t, `hello2`, readStr(<-client.Channel()))
-
- assert.NoError(t, client.Unsubscribe("topic"))
-
- assert.NoError(t, br.Broker().Publish(newMessage("topic", "hello3")))
-
- assert.NoError(t, client.Subscribe("topic"))
-
- assert.NoError(t, br.Broker().Publish(newMessage("topic", "hello4")))
- assert.Equal(t, `hello4`, readStr(<-client.Channel()))
-}
-
-func TestRedis_BroadcastPattern(t *testing.T) {
- br, _, c := setup(`{"redis":{"addr":"localhost:6379"}}`)
- defer c.Stop()
-
- client := br.NewClient()
- defer client.Close()
-
- assert.NoError(t, br.Broker().Publish(newMessage("topic", "hello1"))) // must not be delivered
-
- assert.NoError(t, client.SubscribePattern("topic/*"))
-
- assert.NoError(t, br.Broker().Publish(newMessage("topic/1", "hello1")))
- assert.Equal(t, `hello1`, readStr(<-client.Channel()))
-
- assert.NoError(t, br.Broker().Publish(newMessage("topic/2", "hello2")))
- assert.Equal(t, `hello2`, readStr(<-client.Channel()))
-
- assert.NoError(t, br.Broker().Publish(newMessage("different", "hello4")))
- assert.NoError(t, br.Broker().Publish(newMessage("topic/2", "hello5")))
-
- assert.Equal(t, `hello5`, readStr(<-client.Channel()))
-
- assert.NoError(t, client.UnsubscribePattern("topic/*"))
-
- assert.NoError(t, br.Broker().Publish(newMessage("topic/3", "hello6")))
-
- assert.NoError(t, client.SubscribePattern("topic/*"))
-
- assert.NoError(t, br.Broker().Publish(newMessage("topic/4", "hello7")))
- assert.Equal(t, `hello7`, readStr(<-client.Channel()))
-}
-
-func TestRedis_NotActive(t *testing.T) {
- b := &Redis{}
- b.stopped = 1
-
- assert.Error(t, b.Publish(nil))
- assert.Error(t, b.Subscribe(nil))
- assert.Error(t, b.Unsubscribe(nil))
- assert.Error(t, b.SubscribePattern(nil, ""))
- assert.Error(t, b.UnsubscribePattern(nil, ""))
-}
diff --git a/plugins/broadcast/plugin.go b/plugins/broadcast/plugin.go
index f1ea258e..ec7c2587 100644
--- a/plugins/broadcast/plugin.go
+++ b/plugins/broadcast/plugin.go
@@ -13,6 +13,7 @@ const (
type Plugin struct {
broker Subscriber
+ driver Storage
log logger.Logger
cfg *Config
@@ -48,17 +49,16 @@ func (p *Plugin) Serve() chan error {
// start the underlying broker
go func() {
- err := p.broker.Serve()
- if err != nil {
- errCh <- errors.E(op, err)
- }
+ // err := p.broker.Serve()
+ // if err != nil {
+ // errCh <- errors.E(op, err)
+ // }
}()
return errCh
}
func (p *Plugin) Stop() error {
-
return nil
}
diff --git a/plugins/broadcast/redis/storage.go b/plugins/broadcast/redis/storage.go
new file mode 100644
index 00000000..65a229e1
--- /dev/null
+++ b/plugins/broadcast/redis/storage.go
@@ -0,0 +1 @@
+package redis
diff --git a/plugins/broadcast/ws/config.go b/plugins/broadcast/ws/config.go
new file mode 100644
index 00000000..33da2485
--- /dev/null
+++ b/plugins/broadcast/ws/config.go
@@ -0,0 +1 @@
+package ws \ No newline at end of file
diff --git a/plugins/broadcast/ws/plugin.go b/plugins/broadcast/ws/plugin.go
new file mode 100644
index 00000000..98592950
--- /dev/null
+++ b/plugins/broadcast/ws/plugin.go
@@ -0,0 +1 @@
+package ws
diff --git a/plugins/broadcast/ws/subscriber.go b/plugins/broadcast/ws/subscriber.go
new file mode 100644
index 00000000..98592950
--- /dev/null
+++ b/plugins/broadcast/ws/subscriber.go
@@ -0,0 +1 @@
+package ws