-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
69 lines (64 loc) · 1.43 KB
/
main.go
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package main
import (
"log"
"fmt"
"time"
"github.com/zpatrick/go-config"
"github.com/qnib/qframe-types"
"github.com/qnib/qframe-utils"
"github.com/qnib/qframe-filter-id/lib"
"github.com/moby/moby/api/types/events"
)
func Run(qChan qtypes.QChan, cfg config.Config, name string) {
p := qframe_filter_id.New(qChan, cfg, name)
p.Run()
}
func main() {
myId := qutils.GetGID()
qChan := qtypes.NewQChan()
qChan.Broadcast()
cfgMap := map[string]string{
"filter.test.send-back": "docker-event",
"filter.test.send-data": "docker-event",
"filter.test.inputs": "docker-events",
}
cfg := config.NewConfig(
[]config.Provider{
config.NewStatic(cfgMap),
},
)
p := qframe_filter_id.New(qChan, *cfg, "test")
go p.Run()
time.Sleep(2*time.Second)
dc := qChan.Data.Join()
bc := qChan.Back.Join()
qm := qtypes.NewQMsg("collector", "docker-events")
qm.SourceID = myId
qm.Msg = "docker-event"
qm.Data = events.Message{}
log.Println("Send message")
qChan.Data.Send(qm)
gotData := false
gotBack := false
for {
select {
case msg := <-dc.Read:
qm := msg.(qtypes.QMsg)
if qm.SourceID == myId {
continue
}
fmt.Printf("#### Received message on Data-channel: %s\n", qm.Msg)
gotData = true
case msg := <-bc.Read:
qm := msg.(qtypes.QMsg)
if qm.SourceID == myId {
continue
}
fmt.Printf("#### Received message on Back-channel: %s\n", qm.Msg)
gotBack = true
}
if gotBack && gotData {
break
}
}
}