sending

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package sending runs campaign sends: it builds the recipient list, applies suppressions, routes each recipient to a sending provider, throttles per provider and per mailbox provider, sends in batches through River jobs, updates live counters and pauses automatically when thresholds trip.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotReady = errors.New("send readiness is blocked")

ErrNotReady is returned when Send Readiness blocks the send at start.

View Source
var ErrUnavailable = errors.New("sending is not available in this process")

ErrUnavailable is returned by Unavailable, before the sending domain is wired.

Functions

func Retryable

func Retryable(err error) bool

Retryable reports whether err is a deadlock or a serialization failure.

func Tx

func Tx(ctx context.Context, pool *pgxpool.Pool, fn func(pgx.Tx) error) error

Tx runs fn in a transaction and retries it when Postgres aborts it for a deadlock or a serialization failure. Concurrent batches update the same counter rows and can lock them in different orders; an aborted attempt commits nothing, so retrying is safe. fn must not keep state between attempts.

func WithRecheck

func WithRecheck(ctx context.Context, campaignID uuid.UUID, rc Recheck) context.Context

WithRecheck hands Start the send-time recheck its caller has just run for the campaign, so Send Readiness doesn't run a second time.

Types

type Engagement

type Engagement struct {
	MessageID uuid.UUID
	Click     bool
	Link      int
	UserAgent string
	IP        string
	Method    string
	At        time.Time
}

Engagement is one open-pixel fetch or link click, as the tracking endpoints (and the demo transport) report it. Link is the click's link position; UserAgent, IP and Method decide human or machine.

type NotReadyError

type NotReadyError struct {
	Reason   string
	Blocking []string
}

NotReadyError is ErrNotReady with what blocked the send.

func (*NotReadyError) Error

func (e *NotReadyError) Error() string

func (*NotReadyError) Is

func (e *NotReadyError) Is(target error) bool

Is makes errors.Is(err, ErrNotReady) hold.

type Readiness

type Readiness interface {
	Recheck(ctx context.Context, campaignID uuid.UUID) (Recheck, error)
}

Readiness reruns Send Readiness when a send starts (the send-time recheck, add-on §3.8) and supplies its per-mailbox-provider throttles. The engine falls back to ReadyAlways when none is wired.

type ReadyAlways

type ReadyAlways struct{}

ReadyAlways never blocks and keeps the default throttles.

func (ReadyAlways) Recheck

Recheck implements Readiness.

type Recheck

type Recheck struct {
	// Verdict is "ready", "warnings" or "blocked".
	Verdict string
	// Blocking lists the titles of the checks that block.
	Blocking []string
	// Throttles are messages per second per mailbox provider ("outlook": 5);
	// nil keeps the engine's defaults.
	Throttles map[string]float64
	// Audience is the final recipient count the recheck counted, and RunID
	// its Send Readiness run; a hold records both.
	Audience int64
	RunID    string
}

Recheck is the result of the send-time recheck.

func RecheckFrom

func RecheckFrom(ctx context.Context, campaignID uuid.UUID) (Recheck, bool)

RecheckFrom returns the recheck WithRecheck attached for the campaign.

type Recorder

type Recorder interface {
	RecordEngagement(ctx context.Context, evs []Engagement) error
}

Recorder records opens and clicks (the tracking domain implements it).

type Segments

type Segments interface {
	ContactIDs(ctx context.Context, workspaceID, segmentID uuid.UUID) ([]uuid.UUID, error)
}

Segments resolves saved segments to contact ids (the audience domain).

type Starter

type Starter interface {
	Start(ctx context.Context, campaignID uuid.UUID, startedBy uuid.UUID) error
	Pause(ctx context.Context, campaignID uuid.UUID, by uuid.UUID, reason string) error
	Resume(ctx context.Context, campaignID uuid.UUID, by uuid.UUID) error
	Cancel(ctx context.Context, campaignID uuid.UUID, by uuid.UUID) error
}

Starter starts or schedules a campaign send. The review & send screen calls it after confirmation (and after approval, when required).

type Unavailable

type Unavailable struct{}

Unavailable is the Starter used until the sending domain replaces it.

func (Unavailable) Cancel

Cancel always fails with ErrUnavailable.

func (Unavailable) Pause

Pause always fails with ErrUnavailable.

func (Unavailable) Resume

Resume always fails with ErrUnavailable.

func (Unavailable) Start

Start always fails with ErrUnavailable.

Directories

Path Synopsis
Package engine is ReputeCast's sending engine (spec 5.3, 7.6): it builds a campaign's recipient list, routes, renders and hands every message to its sending provider within rate limits and throttles, watches bounce, complaint and outage signals and pauses what they concern, sends automation emails, and serves the live monitor's snapshot and stream.
Package engine is ReputeCast's sending engine (spec 5.3, 7.6): it builds a campaign's recipient list, routes, renders and hands every message to its sending provider within rate limits and throttles, watches bounce, complaint and outage signals and pauses what they concern, sends automation emails, and serves the live monitor's snapshot and stream.

Jump to

Keyboard shortcuts

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