-
Notifications
You must be signed in to change notification settings - Fork 5
/
listener.go
67 lines (59 loc) · 1.65 KB
/
listener.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
package superscribe
import (
"log"
)
type listener struct {
EventListener
}
type MultiEventListener struct {
listeners []listener
}
func NewMultiEventListener() *MultiEventListener {
return &MultiEventListener{make([]listener, 0)}
}
func (multi *MultiEventListener) Add(l EventListener) {
multi.listeners = append(multi.listeners, listener{l})
}
func (multi *MultiEventListener) Name() string {
return "Internal event bus"
}
func (multi MultiEventListener) ChangedAutoRenewProduct(evt AutoRenewEvent) error {
for _, l := range multi.listeners {
if err := l.ChangedAutoRenewProduct(evt); err != nil {
log.Printf("%s listener ChangedAutoRenewProduct error: %v\n", l.Name(), err)
}
}
return nil
}
func (multi MultiEventListener) ChangedAutoRenewStatus(evt AutoRenewEvent) error {
for _, l := range multi.listeners {
if err := l.ChangedAutoRenewStatus(evt); err != nil {
log.Printf("%s listener ChangedAutoRenewStatus error: %v\n", l.Name(), err)
}
}
return nil
}
func (multi MultiEventListener) Paid(evt PayEvent) error {
for _, l := range multi.listeners {
if err := l.Paid(evt); err != nil {
log.Printf("%s listener Paid error: %v\n", l.Name(), err)
}
}
return nil
}
func (multi MultiEventListener) Refunded(evt RefundEvent) error {
for _, l := range multi.listeners {
if err := l.Refunded(evt); err != nil {
log.Printf("%s listener Refunded error: %v\n", l.Name(), err)
}
}
return nil
}
func (multi MultiEventListener) StartedTrial(evt StartTrialEvent) error {
for _, l := range multi.listeners {
if err := l.StartedTrial(evt); err != nil {
log.Printf("%s listener StartedTrial error: %v\n", l.Name(), err)
}
}
return nil
}