summaryrefslogtreecommitdiff
path: root/plugins/channel/plugin.go
blob: 8901c42e16d697fda25aacfd19586d4fe43ea93d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package channel

import (
	"sync"
)

const (
	PluginName string = "hub"
)

type Plugin struct {
	sync.Mutex
	send    chan interface{}
	receive chan interface{}
}

func (p *Plugin) Init() error {
	p.Lock()
	defer p.Unlock()
	p.send = make(chan interface{})
	p.receive = make(chan interface{})
	return nil
}

func (p *Plugin) Serve() chan error {
	return make(chan error)
}

func (p *Plugin) Stop() error {
	close(p.receive)
	return nil
}

func (p *Plugin) SendCh() chan interface{} {
	p.Lock()
	defer p.Unlock()
	// bi-directional queue
	return p.send
}

func (p *Plugin) ReceiveCh() chan interface{} {
	p.Lock()
	defer p.Unlock()
	// bi-directional queue
	return p.receive
}

func (p *Plugin) Available() {}

func (p *Plugin) Name() string {
	return PluginName
}