worknotify

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package worknotify turns PostgreSQL commit notifications into process-local, coalesced wakeup hints. Durable tables remain the only work authority.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Hub

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

Hub fans commit hints out to interested workers without carrying authority.

func NewHub

func NewHub() *Hub

NewHub constructs an empty wakeup hub.

func (*Hub) Publish

func (hub *Hub) Publish(kind Kind, key string)

Publish offers one non-blocking hint to every matching subscriber.

func (*Hub) Subscribe

func (hub *Hub) Subscribe(kind Kind, key string) (<-chan struct{}, func())

Subscribe returns a capacity-one channel and an idempotent cancellation function.

type Kind

type Kind string

Kind identifies one durable worker queue.

const (
	KindLifecycle     Kind = "lifecycle"
	KindAssignment    Kind = "assignment"
	KindRunnerCommand Kind = "runner_command"
)

type PostgresListener

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

PostgresListener receives transaction-commit hints on one dedicated connection.

func NewPostgresListener

func NewPostgresListener(
	ctx context.Context,
	databaseURL string,
	hub *Hub,
) (*PostgresListener, error)

NewPostgresListener establishes LISTEN before returning so no later startup operation can race worker subscription setup.

func (*PostgresListener) Run

func (listener *PostgresListener) Run(ctx context.Context) (returnError error)

Run forwards valid hints until cancellation. A connection or payload failure is terminal because silently reverting to polling would hide a broken fast path.

type Source

type Source interface {
	Subscribe(Kind, string) (<-chan struct{}, func())
}

Source provides bounded, coalesced wakeup subscriptions.

Jump to

Keyboard shortcuts

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