sendramp

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package sendramp implements durable, per-domain recipient-volume ramping for the asynchronous outbound delivery worker.

Index

Constants

View Source
const (
	StatusInactive = "inactive"
	StatusRamping  = "ramping"
	StatusComplete = "complete"
	StatusExempt   = "exempt"
)
View Source
const MinimumStartDaily = 50

Variables

View Source
var DefaultSchedule = Schedule{StartDaily: 50, TargetDaily: 2000, RampDays: 30}

Functions

func Qualifies

func Qualifies(confirmed, limit int) bool

Qualifies reports whether provider-accepted recipient volume reached half of the day's snapshotted allowance, rounded up.

Types

type Decision

type Decision struct {
	Allowed    bool
	Status     string
	DailyLimit int
	UsedToday  int
	RetryAt    time.Time
}

type MaintenanceArgs

type MaintenanceArgs struct{}

func (MaintenanceArgs) Kind

func (MaintenanceArgs) Kind() string

type MaintenanceJobs

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

func NewMaintenanceJobs

func NewMaintenanceJobs(store *Store) *MaintenanceJobs

func (*MaintenanceJobs) RegisterJobs

func (m *MaintenanceJobs) RegisterJobs(w *river.Workers) []*river.PeriodicJob

type MaintenanceWorker

type MaintenanceWorker struct {
	river.WorkerDefaults[MaintenanceArgs]
	// contains filtered or unexported fields
}

func NewMaintenanceWorker

func NewMaintenanceWorker(store *Store) *MaintenanceWorker

func (*MaintenanceWorker) Work

type PermanentError

type PermanentError struct{ Err error }

func (*PermanentError) Error

func (e *PermanentError) Error() string

func (*PermanentError) Permanent

func (e *PermanentError) Permanent() bool

func (*PermanentError) Unwrap

func (e *PermanentError) Unwrap() error

type ReserveRequest

type ReserveRequest struct {
	MessageID string
	UserID    string
	Domain    string
	Units     int
	Day       time.Time
	Schedule  Schedule
}

type Schedule

type Schedule struct {
	StartDaily  int
	TargetDaily int
	RampDays    int
}

Schedule is snapshotted when a domain first sends through its verified identity. Progress is measured in UTC days that reach the provider-accepted volume threshold, so idle or token sends cannot age into full volume.

func NewSchedule

func NewSchedule(startDaily, targetDaily, rampDays int) Schedule

func (Schedule) CapForActiveDay

func (s Schedule) CapForActiveDay(activeDay int) int

CapForActiveDay returns the recipient allowance for a zero-based qualified-day index. The target is reached on the final configured ramp day.

type Snapshot

type Snapshot struct {
	Status      string
	StartedAt   *time.Time
	CompletedAt *time.Time
	ActiveDays  int
	StartDaily  int
	TargetDaily int
	RampDays    int
	DailyLimit  int
	UsedToday   int
}

type Store

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

func NewStore

func NewStore(pool *pgxpool.Pool) *Store

func (*Store) Confirm

func (s *Store) Confirm(ctx context.Context, messageID string) error

func (*Store) Exempt

func (s *Store) Exempt(ctx context.Context, userID, domain string) error

func (*Store) Release

func (s *Store) Release(ctx context.Context, messageID string) error

func (*Store) Reserve

func (s *Store) Reserve(ctx context.Context, req ReserveRequest) (Decision, error)

func (*Store) Resolve

func (s *Store) Resolve(ctx context.Context, messageID string) error

Resolve settles a pending reservation from the message's durable provider outcome. It is used by terminal reconciliation after ambiguous worker exits.

func (*Store) Snapshot

func (s *Store) Snapshot(ctx context.Context, userID, domain string, now time.Time) (Snapshot, error)

func (*Store) Sweep

func (s *Store) Sweep(ctx context.Context, now time.Time) error

Jump to

Keyboard shortcuts

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