Documentation
¶
Overview ¶
Package eventtriggers provides event-driven workflow triggers. It lets workflows subscribe to domain events via HTTP API, evaluates filter expressions, and automatically starts workflow instances when matching events are published.
Index ¶
- func EvaluateFilter(expr string, eventData map[string]any) (bool, error)
- func New() plugin.Plugin
- func PublishEvent(ctx context.Context, db plugin.PluginDB, logger *slog.Logger, ...) (int, error)
- type Plugin
- func (p *Plugin) Info() plugin.PluginInfo
- func (p *Plugin) Init(ctx context.Context, env *plugin.Environment) error
- func (p *Plugin) Migrations() []plugin.Migration
- func (p *Plugin) RegisterHostFunctions(scope plugin.FuncRegistry) error
- func (p *Plugin) RegisterRoutes(mux *http.ServeMux) error
- func (p *Plugin) Run(ctx context.Context) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EvaluateFilter ¶
EvaluateFilter evaluates a filter against event data. It accepts two forms:
- Structured JSON filter (when expr starts with '{'): {"event.data.amount": {"$gt": 100}, "event.data.status": {"$in": ["active","pending"]}}
- Text expression (otherwise): event.data.amount > 100
If the expression is empty or "true", returns true without evaluation.
func PublishEvent ¶
func PublishEvent( ctx context.Context, db plugin.PluginDB, logger *slog.Logger, env *plugin.Environment, eventID uuid.UUID, tenantID uuid.UUID, eventType string, eventData map[string]any, ) (int, error)
PublishEvent stores an event, dispatches it to matching subscriptions, and signals any workflows awaiting this event type. Returns the number of workflows started.
This is the core publishing pipeline, exported so that other plugins (e.g., kafkaconnect, webhookingest) can publish events without going through the HTTP API.
Types ¶
type Plugin ¶
type Plugin struct {
// contains filtered or unexported fields
}
Plugin implements event-driven workflow triggers with tenant-isolated event subscriptions, idempotent event ingestion, and filter expressions.
func (*Plugin) Info ¶
func (p *Plugin) Info() plugin.PluginInfo
Info returns plugin metadata for discovery and documentation.
func (*Plugin) Migrations ¶
Migrations returns the database schema for event subscription management and event storage. Tables are idempotent (IF NOT EXISTS) and safe to run multiple times.
func (*Plugin) RegisterHostFunctions ¶
func (p *Plugin) RegisterHostFunctions(scope plugin.FuncRegistry) error
RegisterHostFunctions registers workflow-callable functions on the scoped function registry under the "event-triggers" plugin namespace.
func (*Plugin) RegisterRoutes ¶
RegisterRoutes registers HTTP handlers for the event-triggers plugin.