/
channel_example_test.go
52 lines (43 loc) · 911 Bytes
/
channel_example_test.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
package pluto_test
import (
"os"
"pluto"
"testing"
"time"
"github.com/google/uuid"
)
func TestChannel(t *testing.T) {
ch := pluto.NewChannel("MY_CHANNEL", 10)
ch.Join(&pluto.ChannelJoinableProcessor{
Name: "OUT_1",
Kind: "STD_IO",
Processor: pluto.WriteToIOProcessor{
Writer: os.Stdout,
},
})
ch.Join(&pluto.ChannelJoinableProcessor{
Name: "OUT_2",
Kind: "STD_IO",
Processor: pluto.WriteToIOProcessor{
Writer: os.Stdout,
},
})
ch.Join(&pluto.ChannelJoinableProcessor{
Name: "OUT_3",
Kind: "STD_IO",
Processor: pluto.WriteToIOProcessor{
Writer: os.Stdout,
},
})
ch.Publish(&pluto.InternalProcessable{
ID: uuid.New(),
Body: []byte("Hello World 1\n"),
CreatedAt: time.Now(),
})
ch.Publish(&pluto.InternalProcessable{
ID: uuid.New(),
Body: []byte("Hello World 2\n"),
CreatedAt: time.Now(),
})
<-time.Tick(time.Second)
}