summaryrefslogtreecommitdiff
path: root/plugins/channel/plugin.go
blob: 9afd12647f0ed7626a8fa69e73b051cb150ac697 (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
package channel

import (
	"sync"
)

const (
	PluginName string = "hub"
)

type Plugin struct {
	sync.Mutex
	fromCh chan interface{}
	toCh   chan interface{}
}

func (p *Plugin) Init() error {
	p.Lock()
	defer p.Unlock()

	p.fromCh = make(chan interface{})
	p.toCh = make(chan interface{})
	return nil
}

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

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

func (p *Plugin) FromWorker() chan interface{} {
	p.Lock()
	defer p.Unlock()
	// one-directional queue
	return p.fromCh
}

func (p *Plugin) ToWorker() chan interface{} {
	p.Lock()
	defer p.Unlock()
	// one-directional queue
	return p.toCh
}

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