events

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const QueueEvents = "events"

Variables

This section is empty.

Functions

func Migrate added in v0.4.0

func Migrate(ctx context.Context, pool *pgxpool.Pool) error

Migrate brings the river job tables (river_job etc.) up to date (idempotent). Deliberately NOT part of ploykit migrations (001-999): the river schema follows the river library's own version sequence, managed adaptively by its official migrator - embedding it would pin us to one river version. Call it once in the product boot sequence after events.New and before workers.Start; deployments with their own migration pipeline may call it from there instead.

func Subscribe

func Subscribe(kind string, h Handler)

Types

type Emitter

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

func New

func New(pool *pgxpool.Pool, wks *workers.Workers, opts ...Option) (*Emitter, error)

func (*Emitter) Emit

func (e *Emitter) Emit(ctx context.Context, tx pgx.Tx, ev Event, opts ...river.InsertOpts) error

func (*Emitter) EmitAt added in v0.4.0

func (e *Emitter) EmitAt(ctx context.Context, tx pgx.Tx, ev Event, at time.Time) error

EmitAt schedules a one-shot event for a specific time (typed sugar over river's ScheduledAt). Use for "do X once at time T"; recurring plans still belong to the schedule domain. Must be called inside a transaction, like Emit.

type Event

type Event struct {
	Kind string

	WorkspaceID uuid.UUID

	Payload []byte

	IDempotencyKey string
}

type Handler

type Handler func(ctx context.Context, ev Event) error

type Option

type Option func(*river.Config)

Jump to

Keyboard shortcuts

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