signal

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package signal carries external signals to waiting executions. Signals are published to a durable JetStream stream so they survive restarts and are redelivered until acknowledged; the engine applies them idempotently using each message's stream sequence number (spec §7).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Delivery

type Delivery struct {
	ExecID  string
	Name    string
	Seq     uint64
	Payload []byte
}

Delivery is a received signal with its stream sequence (for idempotency).

type Signals

type Signals struct {
	// contains filtered or unexported fields
}

Signals publishes and consumes external signals within one namespace.

func New

New returns a Signals bound to the given JetStream context and namespace.

func (*Signals) Consume

func (s *Signals) Consume(
	ctx context.Context, durable string, handler func(context.Context, Delivery) error,
) (jetstream.ConsumeContext, error)

Consume sets up a durable consumer and invokes handler for every signal. The handler must persist state before returning nil; only then is the message acked (CAS-before-ack). A returned error triggers redelivery. The returned ConsumeContext must be stopped by the caller.

func (*Signals) EnsureStream

func (s *Signals) EnsureStream(ctx context.Context) error

EnsureStream creates the signals stream if it does not exist.

func (*Signals) Publish

func (s *Signals) Publish(ctx context.Context, execID, name string, payload []byte) error

Publish sends a signal for execID/name with the given payload.

func (*Signals) Subject

func (s *Signals) Subject(execID, name string) string

Subject returns the signal subject for an execution and signal name.

Jump to

Keyboard shortcuts

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