Documentation
¶
Overview ¶
Package triggers provides PubSub trigger management for the serverless engine. It handles registering, querying, and removing triggers that automatically invoke functions when messages are published to specific PubSub topics.
Index ¶
- type PubSubDispatcher
- type PubSubEvent
- type PubSubTriggerStore
- func (s *PubSubTriggerStore) Add(ctx context.Context, functionID, topic string) (string, error)
- func (s *PubSubTriggerStore) GetByTopicAndNamespace(ctx context.Context, topic, namespace string) ([]TriggerMatch, error)
- func (s *PubSubTriggerStore) ListByFunction(ctx context.Context, functionID string) ([]serverless.PubSubTrigger, error)
- func (s *PubSubTriggerStore) Remove(ctx context.Context, triggerID string) error
- func (s *PubSubTriggerStore) RemoveByFunction(ctx context.Context, functionID string) error
- type TriggerMatch
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PubSubDispatcher ¶
type PubSubDispatcher struct {
// contains filtered or unexported fields
}
PubSubDispatcher looks up triggers for a topic+namespace and asynchronously invokes matching serverless functions.
func NewPubSubDispatcher ¶
func NewPubSubDispatcher( store *PubSubTriggerStore, invoker *serverless.Invoker, olricClient olriclib.Client, logger *zap.Logger, ) *PubSubDispatcher
NewPubSubDispatcher creates a new PubSub trigger dispatcher.
func (*PubSubDispatcher) Dispatch ¶
func (d *PubSubDispatcher) Dispatch(ctx context.Context, namespace, topic string, data []byte, depth int)
Dispatch looks up all triggers registered for the given topic+namespace and invokes matching functions asynchronously. Each invocation runs in its own goroutine and does not block the caller.
func (*PubSubDispatcher) InvalidateCache ¶
func (d *PubSubDispatcher) InvalidateCache(ctx context.Context, namespace, topic string)
InvalidateCache removes the cached trigger lookup for a namespace+topic. Call this when triggers are added or removed.
type PubSubEvent ¶
type PubSubEvent struct {
Topic string `json:"topic"`
Data json.RawMessage `json:"data"`
Namespace string `json:"namespace"`
TriggerDepth int `json:"trigger_depth"`
Timestamp int64 `json:"timestamp"`
}
PubSubEvent is the JSON payload sent to functions triggered by PubSub messages.
type PubSubTriggerStore ¶
type PubSubTriggerStore struct {
// contains filtered or unexported fields
}
PubSubTriggerStore manages PubSub trigger persistence in RQLite.
func NewPubSubTriggerStore ¶
func NewPubSubTriggerStore(db rqlite.Client, logger *zap.Logger) *PubSubTriggerStore
NewPubSubTriggerStore creates a new PubSub trigger store.
func (*PubSubTriggerStore) Add ¶
Add registers a new PubSub trigger for a function. Returns the trigger ID.
func (*PubSubTriggerStore) GetByTopicAndNamespace ¶
func (s *PubSubTriggerStore) GetByTopicAndNamespace(ctx context.Context, topic, namespace string) ([]TriggerMatch, error)
GetByTopicAndNamespace returns all enabled triggers for a topic within a namespace. Only returns triggers for active functions.
func (*PubSubTriggerStore) ListByFunction ¶
func (s *PubSubTriggerStore) ListByFunction(ctx context.Context, functionID string) ([]serverless.PubSubTrigger, error)
ListByFunction returns all PubSub triggers for a function.
func (*PubSubTriggerStore) Remove ¶
func (s *PubSubTriggerStore) Remove(ctx context.Context, triggerID string) error
Remove deletes a trigger by ID.
func (*PubSubTriggerStore) RemoveByFunction ¶
func (s *PubSubTriggerStore) RemoveByFunction(ctx context.Context, functionID string) error
RemoveByFunction deletes all triggers for a function. Used during function re-deploy to clear old triggers.