-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathjoin_channel.go
63 lines (49 loc) · 1.14 KB
/
join_channel.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
package pluto
const ProcessorName_JoinChannel = "Join Channel"
func init() {
PredefinedProcessors[ProcessorName_JoinChannel] = func(args []Value) (p Processor, err error) {
defer creatorPanicHandler(ProcessorName_JoinChannel, &err)()
return JoinChannel{}, err
}
}
type JoinChannel struct {
}
func (p JoinChannel) Process(processable Processable) (Processable, bool) {
appendable, ok := processable.GetBody().(map[string]any)
if !ok {
return processable, false
}
v, found := appendable["channel"]
if !found {
return processable, false
}
channel, ok := v.(Channel)
if !ok {
return processable, false
}
v, found = appendable["identifier"]
if !found {
return processable, false
}
identifier, ok := v.(Identifier)
if !ok {
return processable, false
}
v, found = appendable["processor"]
if !found {
return processable, false
}
processor, ok := v.(Processor)
if !ok {
return processable, false
}
channel.Join(&BaseJoinable{identifier, processor})
return processable, true
}
func (p JoinChannel) GetDescriptor() ProcessorDescriptor {
return ProcessorDescriptor{}
}
type BaseJoinable struct {
Identifier
Processor
}