service

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Message

type Message struct {
	// EventType is a free-form label identifying what this call represents,
	// e.g. "trainer_session_feedback". Used for filtering in the admin UI.
	EventType string

	// TargetURL is the HTTP endpoint that will receive a POST with the payload.
	// It is persisted at enqueue time so retries are independent of config changes.
	TargetURL string

	// Payload is any JSON-serialisable value. It will be stored as jsonb.
	Payload any

	// TenantID is optional — used for filtering in the admin UI.
	TenantID string

	// CreatedBy is the user ID that triggered the outbound call (optional).
	CreatedBy string

	// MaxAttempts overrides the default of 5. Zero means use the default.
	MaxAttempts int
}

Message is the caller-facing type for enqueuing an outbound HTTP call. Payload accepts any JSON-serialisable value; it is marshalled internally.

type Service

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

Service provides the Enqueue / EnqueueTx surface for any module that needs reliable outbound HTTP delivery.

func NewService

func NewService(store *db.Store) *Service

func (*Service) Enqueue

func (s *Service) Enqueue(ctx context.Context, msg Message) error

Enqueue persists a new outbox message outside any caller transaction. The message will be delivered asynchronously by the background dispatcher.

func (*Service) EnqueueTx

func (s *Service) EnqueueTx(ctx context.Context, tx pgx.Tx, msg Message) error

EnqueueTx persists a new outbox message inside an existing pgx.Tx. Use this for atomic "write your data + enqueue the webhook in one transaction".

Jump to

Keyboard shortcuts

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