First draft of modifying RunnerListener to CallListener to get it closer to the action (and named better).

This commit is contained in:
Travis Reeder
2017-10-09 18:38:29 -06:00
parent 1237a7bf82
commit d080c23981
10 changed files with 95 additions and 70 deletions

32
api/agent/listeners.go Normal file
View File

@@ -0,0 +1,32 @@
package agent
import (
"context"
"github.com/fnproject/fn/api/extenders"
"github.com/fnproject/fn/api/models"
)
func (a *agent) AddCallListener(listener extenders.CallListener) {
a.callListeners = append(a.callListeners, listener)
}
func (a *agent) fireBeforeCall(ctx context.Context, call *models.Call) error {
for _, l := range a.callListeners {
err := l.BeforeCall(ctx, call)
if err != nil {
return err
}
}
return nil
}
func (a *agent) fireAfterCall(ctx context.Context, call *models.Call) error {
for _, l := range a.callListeners {
err := l.AfterCall(ctx, call)
if err != nil {
return err
}
}
return nil
}