queue

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2021 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config added in v0.2.0

type Config struct {
	// TODO: support json marshal for duration
	Hostname               string        `json:"hostname"`
	Directory              string        `json:"directory"`
	DisableSSLVerification bool          `json:"disable-ssl-verification"`
	InitialInterval        time.Duration `json:"-"`
	RandomizationFactor    float64       `json:"randomization_factor"`
	Multiplier             float64       `json:"multiplier"`
	MaxInterval            time.Duration `json:"-"`
	MaxAttempts            int           `json:"max_attempts"`
	Jitter                 bool          `json:"jitter"`

	// Map domain names to DKIM config for that domain
	DKIMConfigs map[string]DKIMConfig `json:"dkim-configs"`
	// ProcessFunc allow you to define custom process function for message.
	ProcessFunc ProcessFunc `json:"-"`
	// ProcessFailFunc allow you to define processor if message failed with 5xx status.
	ProcessFailFunc ProcessFailFunc `json:"-"`
}

Application configuration.

type DKIMConfig added in v0.3.2

type DKIMConfig struct {
	PrivateKey       string `json:"private-key"`
	Selector         string `json:"selector"`
	Canonicalization string `json:"canonicalization"`
}

See https://github.com/Freeaqingme/dkim

type Host

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

Persistent connection to an SMTP host.

func NewHost

func NewHost(host string, s *Storage, c *Config) *Host

NewHost creates a new host connection.

func (*Host) Deliver

func (h *Host) Deliver(m *Message)

Attempt to deliver a message to the host.

func (*Host) Idle

func (h *Host) Idle() time.Duration

Retrieve the connection idle time.

func (*Host) Status added in v0.3.0

func (h *Host) Status() *HostStatus

Return the status of the host connection.

func (*Host) Stop

func (h *Host) Stop()

Close the connection to the host.

type HostStatus added in v0.3.0

type HostStatus struct {
	Active bool `json:"active"`
	Length int  `json:"length"`
}

Host status information.

type MailServerFinder added in v1.0.3

type MailServerFinder interface {
	// Attempt to find the mail servers for the specified host. MX records are
	// checked first. If one or more were found, the records are converted into an
	// array of strings (sorted by priority). If none were found, the original host
	// is returned.
	FindServers(host string) ([]string, error)
}

type Message added in v0.2.0

type Message struct {
	Host    string   `json:"host"`
	From    string   `json:"from"`
	To      []string `json:"to"`
	Attempt int      `json:"attempt"`
	// Metadata can store any data useful for custom processors.
	Metadata map[string]string `json:"metadata"`
	// contains filtered or unexported fields
}

Message metadata.

type ProcessFailFunc added in v1.1.0

type ProcessFailFunc func(m *Message, s *Storage, err error) error

type ProcessFunc added in v1.0.3

type ProcessFunc func(m *Message, s *Storage) error

type Queue

type Queue struct {
	Storage *Storage
	// contains filtered or unexported fields
}

Mail queue managing the sending of messages to hosts.

func NewQueue

func NewQueue(c *Config) (*Queue, error)

Create a new message queue. Any undelivered messages on disk will be added to the appropriate queue.

func (*Queue) Deliver

func (q *Queue) Deliver(m *Message)

Deliver the specified message to the appropriate host queue.

func (*Queue) Status added in v0.3.0

func (q *Queue) Status() *QueueStatus

Provide the status of each host queue.

func (*Queue) Stop

func (q *Queue) Stop()

Stop all active host queues.

type QueueStatus added in v0.3.0

type QueueStatus struct {
	Uptime int                    `json:"uptime"`
	Hosts  map[string]*HostStatus `json:"hosts"`
}

QueueStatus status information.

type SMTPError added in v1.0.3

type SMTPError struct {
	Err error
}

func (*SMTPError) Error added in v1.0.3

func (e *SMTPError) Error() string

func (*SMTPError) IsPermanent added in v1.0.3

func (e *SMTPError) IsPermanent() bool

func (*SMTPError) IsTemporary added in v1.0.3

func (e *SMTPError) IsTemporary() bool

func (*SMTPError) Unwrap added in v1.0.3

func (e *SMTPError) Unwrap() error

type Storage added in v0.2.0

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

Manager for message metadata and body on disk. All methods are safe to call from multiple goroutines.

func NewStorage added in v0.2.0

func NewStorage(directory string) *Storage

Create a Storage instance for the specified directory.

func (*Storage) DeleteMessage added in v0.2.0

func (s *Storage) DeleteMessage(m *Message) error

Delete the specified message. The message body is also deleted if no more messages exist.

func (*Storage) GetMessageBody added in v0.2.0

func (s *Storage) GetMessageBody(m *Message) (io.ReadCloser, error)

Retreive a reader for the message body.

func (*Storage) LoadMessages added in v0.2.0

func (s *Storage) LoadMessages() ([]*Message, error)

Load messages from the storage directory. Any messages that could not be loaded are ignored.

func (*Storage) NewBody added in v0.2.0

func (s *Storage) NewBody() (io.WriteCloser, string, error)

Create a new message body. The writer must be closed after writing the message body.

func (*Storage) SaveMessage added in v0.2.0

func (s *Storage) SaveMessage(m *Message, body string) error

Save the specified message to disk.

Jump to

Keyboard shortcuts

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