Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Executor ¶
type Executor interface {
// ExecuteFunction executes a function with the given code and event.
// It returns a result as a JSON-like map and any error encountered.
ExecuteFunction(
ctx context.Context,
code string,
functionName string,
event *eventstore.Event,
) (map[string]interface{}, error)
}
Executor defines the interface for executing functions with an event as input.
type FunctionWithTrigger ¶
type FunctionWithTrigger struct {
Function *functionstore.Function
Trigger *functionstore.EventTrigger
}
FunctionWithTrigger represents a function and its associated trigger.
type FunctionsHandler ¶
type FunctionsHandler struct {
// contains filtered or unexported fields
}
FunctionsHandler manages the caching and execution of functions triggered by events. It maintains caches of functions and event triggers that are periodically synchronized.
func (*FunctionsHandler) GetFunctions ¶
func (r *FunctionsHandler) GetFunctions(ctx context.Context, eventTypes ...string) (map[string][]*FunctionWithTrigger, error)
GetFunctions retrieves all functions associated with the given event types. It returns a mapping from event type to a list of function-trigger pairs.
func (*FunctionsHandler) HandleEvent ¶
func (r *FunctionsHandler) HandleEvent(ctx context.Context, events ...*eventstore.Event)
HandleEvent processes incoming events and triggers any associated functions.
type Trigger ¶
type Trigger interface {
// HandleEvent processes one or more events and triggers any associated functions.
HandleEvent(ctx context.Context, events ...*eventstore.Event)
}
Trigger defines the interface for handling events and executing associated functions.
type TriggerManager ¶
func New ¶
func New( ctx context.Context, functions functionservice.Service, onError func(context.Context, error), syncInterval time.Duration, fnexec Executor, tracker libtracker.ActivityTracker) (TriggerManager, error)
New creates a new FunctionsHandler instance with initial synchronization. It returns a Trigger implementation that can handle events.
Parameters:
- ctx: Context for the initialization operations
- functions: Service for retrieving functions and triggers
- onError: Error handler callback
- syncInterval: How often to synchronize with the function service
- tracker: Activity tracker for monitoring (optional)