triggers

package
v0.112.1-nightly Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 22, 2026 License: AGPL-3.0 Imports: 9 Imported by: 0

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

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

func (s *PubSubTriggerStore) Add(ctx context.Context, functionID, topic string) (string, error)

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.

type TriggerMatch

type TriggerMatch struct {
	TriggerID    string
	FunctionID   string
	FunctionName string
	Namespace    string
	Topic        string
}

TriggerMatch contains the fields needed to dispatch a trigger invocation. It's the result of JOINing function_pubsub_triggers with functions.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL