-
Notifications
You must be signed in to change notification settings - Fork 405
/
trigger_listeners.go
77 lines (66 loc) · 1.7 KB
/
trigger_listeners.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
70
71
72
73
74
75
76
77
package server
import (
"context"
"github.com/fnproject/fn/api/models"
"github.com/fnproject/fn/fnext"
)
type triggerListeners []fnext.TriggerListener
var _ fnext.TriggerListener = new(triggerListeners)
func (t *triggerListeners) BeforeTriggerCreate(ctx context.Context, trigger *models.Trigger) error {
for _, l := range *t {
err := l.BeforeTriggerCreate(ctx, trigger)
if err != nil {
return err
}
}
return nil
}
func (t *triggerListeners) AfterTriggerCreate(ctx context.Context, trigger *models.Trigger) error {
for _, l := range *t {
err := l.AfterTriggerCreate(ctx, trigger)
if err != nil {
return err
}
}
return nil
}
func (t *triggerListeners) BeforeTriggerUpdate(ctx context.Context, trigger *models.Trigger) error {
for _, l := range *t {
err := l.BeforeTriggerUpdate(ctx, trigger)
if err != nil {
return err
}
}
return nil
}
func (t *triggerListeners) AfterTriggerUpdate(ctx context.Context, trigger *models.Trigger) error {
for _, l := range *t {
err := l.AfterTriggerUpdate(ctx, trigger)
if err != nil {
return err
}
}
return nil
}
func (t *triggerListeners) BeforeTriggerDelete(ctx context.Context, triggerID string) error {
for _, l := range *t {
err := l.BeforeTriggerDelete(ctx, triggerID)
if err != nil {
return err
}
}
return nil
}
func (t *triggerListeners) AfterTriggerDelete(ctx context.Context, triggerID string) error {
for _, l := range *t {
err := l.AfterTriggerDelete(ctx, triggerID)
if err != nil {
return err
}
}
return nil
}
// AddTriggerListener adds an TriggerListener for the server to use.
func (s *Server) AddTriggerListener(listener fnext.TriggerListener) {
*s.triggerListeners = append(*s.triggerListeners, listener)
}