mailout

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2026 License: BSD-2-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusPending = "pending"
	StatusSending = "sending"
	StatusSent    = "sent"
	StatusFailed  = "failed"

	RouteLocal = "local"
	RouteRelay = "relay"
)
View Source
const (
	DefaultRetention  = 7 * 24 * time.Hour
	TerminalRetention = 30 * 24 * time.Hour
)
View Source
const DeliveryQueueSize = 256

Variables

This section is empty.

Functions

func Claim

func Claim(ctx context.Context, database Database, messageID string) (bool, error)

func Insert

func Insert(ctx context.Context, database Database, task Task) (bool, error)

func IsPermanentFailure

func IsPermanentFailure(err error) bool

func MarkFailed

func MarkFailed(ctx context.Context, database Database, messageID string, attempts int, deliveryError error) error

func MarkPending

func MarkPending(ctx context.Context, database Database, messageID string, attempts int, nextAttempt time.Time, deliveryError error) error

func MarkSent

func MarkSent(ctx context.Context, database Database, messageID string, attempts int, sentAt time.Time) error

func NewDeliveryID

func NewDeliveryID() string

func PurgeTerminal

func PurgeTerminal(ctx context.Context, database Database, before time.Time) error

func RecoverInterrupted

func RecoverInterrupted(ctx context.Context, database Database, now time.Time) error

func RetryDelay

func RetryDelay(attempts int) time.Duration

func RetryDelayWithJitter

func RetryDelayWithJitter(attempts int) time.Duration

func SchemaQueries

func SchemaQueries() []string

func StartDeliveryWorker

func StartDeliveryWorker(ctx context.Context, sender Sender) chan DeliveryJob

Types

type Database

type Database interface {
	ExecContext(context.Context, string, ...any) (sql.Result, error)
	QueryContext(context.Context, string, ...any) (*sql.Rows, error)
	QueryRowContext(context.Context, string, ...any) *sql.Row
}

Database is the database/sql surface required by the outbox store.

type DeliveryJob

type DeliveryJob struct {
	Message Message
}

type DirectSender

type DirectSender struct {
	Hostname    string
	DialTimeout time.Duration
}

func (DirectSender) Send

func (sender DirectSender) Send(ctx context.Context, message Message) error

type Message

type Message struct {
	MessageID string
	Kind      string
	From      string
	To        string
	Subject   string
	Body      string
	HTMLBody  string
}

type PermanentError

type PermanentError struct {
	Err error
}

func (PermanentError) Error

func (deliveryError PermanentError) Error() string

func (PermanentError) Unwrap

func (deliveryError PermanentError) Unwrap() error

type Record

type Record struct {
	Task
	Status      string
	Attempts    int
	NextAttempt time.Time
	SentAt      time.Time
	LastError   string
}

func ByID

func ByID(ctx context.Context, database Database, messageID string) (Record, bool, error)

func Due

func Due(ctx context.Context, database Database, now time.Time, limit int) ([]Record, error)

type Result

type Result struct {
	ID          string
	Status      string
	Attempts    int
	NextAttempt time.Time
	Err         error
}

type Sender

type Sender func(context.Context, Message) error

type Task

type Task struct {
	ID             string
	InstallationID string
	Kind           string
	Route          string
	Message        Message
	CreatedAt      time.Time
	ExpiresAt      time.Time
	Accepted       chan error
	Reply          chan Result
	Done           <-chan struct{}
}

Task transfers responsibility for one durable delivery to the mail process. Reply belongs to the submitting consumer and may be reused for later tasks.

func NewTask

func NewTask(kind, route string, message Message, expiresAt time.Time, reply chan Result) Task

func NormalizeTask

func NormalizeTask(task Task) (Task, error)

Jump to

Keyboard shortcuts

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