-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathresolvers.go
30 lines (26 loc) · 1.01 KB
/
resolvers.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
package neocortex
func (engine *Engine) ResolveAny(channel CommunicationChannel, handler HandleResolver) {
if engine.generalResolver == nil {
engine.generalResolver = map[CommunicationChannel]*HandleResolver{}
}
engine.generalResolver[channel] = &handler
}
func (engine *Engine) Resolve(channel CommunicationChannel, matcher *Matcher, handler HandleResolver) {
if engine.registeredResolvers == nil {
engine.registeredResolvers = map[CommunicationChannel]map[*Matcher]*HandleResolver{}
}
if engine.registeredResolvers[channel] == nil {
engine.registeredResolvers[channel] = map[*Matcher]*HandleResolver{}
}
engine.registeredResolvers[channel][matcher] = &handler
}
func (engine *Engine) ResolveMany(channels []CommunicationChannel, matcher *Matcher, handler HandleResolver) {
for _, ch := range channels {
engine.Resolve(ch, matcher, handler)
}
}
func (engine *Engine) ResolveManyAny(channels []CommunicationChannel, handler HandleResolver) {
for _, ch := range channels {
engine.ResolveAny(ch, handler)
}
}