mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
First draft of modifying RunnerListener to CallListener to get it closer to the action (and named better).
This commit is contained in:
32
api/agent/listeners.go
Normal file
32
api/agent/listeners.go
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user