event

package
v0.34.1 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OnEachBatch

func OnEachBatch[T comparable](b *Bus, fn func(ctx context.Context, data []T) error)

OnEachBatch registers a handler for a specific event type.

func OnEachBatchTx

func OnEachBatchTx[T, TTx comparable](b *Bus, fn func(ctx context.Context, tx TTx, data []T) error)

OnEachBatchTx registers a handler for a specific event type that is contingent on a transaction.

func RegisterJobSource

func RegisterJobSource[T comparable](b *Bus, newJobFn func(data T) (river.JobArgs, *river.InsertOpts))

RegisterJobSource registers a handler for a specific event type that creates jobs.

func Send

func Send[T comparable](ctx context.Context, b *Bus, event T)

Send sends an event to the bus.

func SendMany

func SendMany[T comparable](ctx context.Context, b *Bus, events []T)

Send sends an event to the bus.

func SendManyTx

func SendManyTx[T, TTx comparable](ctx context.Context, b *Bus, tx TTx, events []T)

SendTx sends an event to the bus that is contingent on a transaction.

func SendTx

func SendTx[T, TTx comparable](ctx context.Context, b *Bus, tx TTx, event T)

SendTx sends an event to the bus that is contingent on a transaction.

Types

type Bus

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

func NewBus

func NewBus(l *slog.Logger) *Bus

NewBus creates a new event bus.

func (*Bus) SetRiver

func (b *Bus) SetRiver(r *river.Client[pgx.Tx])

SetRiver sets the river client for the bus.

func (*Bus) SetRiverDBSQL

func (b *Bus) SetRiverDBSQL(r *river.Client[*sql.Tx])

SetRiverDBSQL sets the river client for the bus.

Jump to

Keyboard shortcuts

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