queue

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2024 License: GPL-3.0 Imports: 31 Imported by: 0

Documentation

Overview

Package queue implements module which keeps messages on disk and tries delivery to the configured target (usually remote) multiple times until all recipients are succeeded.

Interfaces implemented: - module.DeliveryTarget

Implementation summary follows.

All scheduled deliveries are attempted to the configured DeliveryTarget. All metadata is preserved on disk.

Failure status is determined on per-recipient basis:

  • Delivery.Start fail handled as a failure for all recipients.
  • Delivery.AddRcpt fail handled as a failure for the corresponding recipient.
  • Delivery.Body fail handled as a failure for all recipients.
  • If Delivery implements PartialDelivery, then PartialDelivery.BodyNonAtomic is used instead. Failures are determined based on StatusCollector.SetStatus calls done by target in this case.

For each failure check is done to see if it is a permanent failure or a temporary one. This is done using exterrors.IsTemporaryOrUnspec. That is, errors are assumed to be temporary by default. All errors are converted to SMTPError then due to a storage limitations.

If there are any *temporary* failed recipients, delivery will be retried after delay *only for these* recipients.

Last error for each recipient is saved for reporting in NDN. A NDN is generated if there are any failed recipients left after last attempt to deliver the message.

Amount of attempts for each message is limited to a certain configured number. After last attempt, all recipients that are still temporary failing are assumed to be permanently failed.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewQueue

func NewQueue(_, instName string, _, inlineArgs []string) (module.Module, error)

Types

type BufferedReadCloser

type BufferedReadCloser struct {
	*bufio.Reader
	io.Closer
}

type Queue

type Queue struct {
	Log    log.Logger
	Target module.DeliveryTarget
	// contains filtered or unexported fields
}

func (*Queue) Close

func (q *Queue) Close() error

func (*Queue) Init

func (q *Queue) Init(cfg *config.Map) error

func (*Queue) InstanceName

func (q *Queue) InstanceName() string

func (*Queue) Name

func (q *Queue) Name() string

func (*Queue) Start

func (q *Queue) Start(ctx context.Context, msgMeta *module.MsgMetadata, mailFrom string) (module.Delivery, error)

type QueueMetadata

type QueueMetadata struct {
	MsgMeta *module.MsgMetadata
	From    string

	// Recipients that should be tried next.
	// May or may not be equal to partialError.TemporaryFailed.
	To []string

	// Information about previous failures.
	// Preserved to be included in a bounce message.
	FailedRcpts          []string
	TemporaryFailedRcpts []string
	// All errors are converted to SMTPError we can serialize and
	// also it is directly usable for bounce messages.
	RcptErrs map[string]*smtp.SMTPError

	// Amount of times delivery *already tried*.
	TriesCount map[string]int

	FirstAttempt time.Time
	LastAttempt  time.Time
}

type TimeSlot

type TimeSlot struct {
	Time  time.Time
	Value interface{}
}

type TimeWheel

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

func NewTimeWheel

func NewTimeWheel(dispatch func(TimeSlot)) *TimeWheel

func (*TimeWheel) Add

func (tw *TimeWheel) Add(target time.Time, value interface{})

func (*TimeWheel) Close

func (tw *TimeWheel) Close()

Jump to

Keyboard shortcuts

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