queue

package
v0.0.0-...-bb97991 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2019 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Overview

Package queue implements our email queue. Accepted envelopes get put in the queue, and processed asynchronously.

Package queue is a generated protocol buffer package.

It is generated from these files:

queue.proto

It has these top-level messages:

Message
Recipient

Index

Constants

This section is empty.

Variables

View Source
var Recipient_Status_name = map[int32]string{
	0: "PENDING",
	1: "SENT",
	2: "FAILED",
}
View Source
var Recipient_Status_value = map[string]int32{
	"PENDING": 0,
	"SENT":    1,
	"FAILED":  2,
}
View Source
var Recipient_Type_name = map[int32]string{
	0: "EMAIL",
	1: "PIPE",
}
View Source
var Recipient_Type_value = map[string]int32{
	"EMAIL": 0,
	"PIPE":  1,
}

Functions

This section is empty.

Types

type Item

type Item struct {
	// Base the item on the protobuf message.
	// We will use this for serialization, so any fields below are NOT
	// serialized.
	Message

	// Protect the entire item.
	sync.Mutex

	// Go-friendly version of Message.CreatedAtTs.
	CreatedAt time.Time
}

An Item in the queue.

func ItemFromFile

func ItemFromFile(fname string) (*Item, error)

ItemFromFile loads an item from the given file.

func (*Item) SendLoop

func (item *Item) SendLoop(q *Queue)

SendLoop repeatedly attempts to send the item.

func (*Item) WriteTo

func (item *Item) WriteTo(dir string) error

WriteTo saves an item to the given directory.

type Message

type Message struct {
	// Message ID. Uniquely identifies this message, it is used for
	// auditing and troubleshooting.
	ID string `protobuf:"bytes,1,opt,name=ID,json=iD" json:"ID,omitempty"`
	// The envelope for this message.
	From string       `protobuf:"bytes,2,opt,name=from" json:"from,omitempty"`
	To   []string     `protobuf:"bytes,3,rep,name=To,json=to" json:"To,omitempty"`
	Rcpt []*Recipient `protobuf:"bytes,4,rep,name=rcpt" json:"rcpt,omitempty"`
	Data []byte       `protobuf:"bytes,5,opt,name=data,proto3" json:"data,omitempty"`
	// Creation timestamp.
	CreatedAtTs *google_protobuf.Timestamp `protobuf:"bytes,6,opt,name=created_at_ts,json=createdAtTs" json:"created_at_ts,omitempty"`
}

func (*Message) Descriptor

func (*Message) Descriptor() ([]byte, []int)

func (*Message) GetCreatedAtTs

func (m *Message) GetCreatedAtTs() *google_protobuf.Timestamp

func (*Message) GetRcpt

func (m *Message) GetRcpt() []*Recipient

func (*Message) ProtoMessage

func (*Message) ProtoMessage()

func (*Message) Reset

func (m *Message) Reset()

func (*Message) String

func (m *Message) String() string

type Queue

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

Queue that keeps mail waiting for delivery.

func New

func New(path string, localDomains *set.String, aliases *aliases.Resolver,
	localC, remoteC courier.Courier) *Queue

New creates a new Queue instance.

func (*Queue) DumpString

func (q *Queue) DumpString() string

DumpString returns a human-readable string with the current queue. Useful for debugging purposes.

func (*Queue) Len

func (q *Queue) Len() int

Len returns the number of elements in the queue.

func (*Queue) Load

func (q *Queue) Load() error

Load the queue and launch the sending loops on startup.

func (*Queue) Put

func (q *Queue) Put(from string, to []string, data []byte) (string, error)

Put an envelope in the queue.

func (*Queue) Remove

func (q *Queue) Remove(id string)

Remove an item from the queue.

type Recipient

type Recipient struct {
	// Address to send the message to.
	// This is the final one, after expanding aliases.
	Address            string           `protobuf:"bytes,1,opt,name=address" json:"address,omitempty"`
	Type               Recipient_Type   `protobuf:"varint,2,opt,name=type,enum=queue.Recipient_Type" json:"type,omitempty"`
	Status             Recipient_Status `protobuf:"varint,3,opt,name=status,enum=queue.Recipient_Status" json:"status,omitempty"`
	LastFailureMessage string           `protobuf:"bytes,4,opt,name=last_failure_message,json=lastFailureMessage" json:"last_failure_message,omitempty"`
	// Address that this recipient was originally intended to.
	// This is before expanding aliases and only used in very particular
	// cases.
	OriginalAddress string `protobuf:"bytes,5,opt,name=original_address,json=originalAddress" json:"original_address,omitempty"`
}

func (*Recipient) Descriptor

func (*Recipient) Descriptor() ([]byte, []int)

func (*Recipient) ProtoMessage

func (*Recipient) ProtoMessage()

func (*Recipient) Reset

func (m *Recipient) Reset()

func (*Recipient) String

func (m *Recipient) String() string

type Recipient_Status

type Recipient_Status int32
const (
	Recipient_PENDING Recipient_Status = 0
	Recipient_SENT    Recipient_Status = 1
	Recipient_FAILED  Recipient_Status = 2
)

func (Recipient_Status) EnumDescriptor

func (Recipient_Status) EnumDescriptor() ([]byte, []int)

func (Recipient_Status) String

func (x Recipient_Status) String() string

type Recipient_Type

type Recipient_Type int32
const (
	Recipient_EMAIL Recipient_Type = 0
	Recipient_PIPE  Recipient_Type = 1
)

func (Recipient_Type) EnumDescriptor

func (Recipient_Type) EnumDescriptor() ([]byte, []int)

func (Recipient_Type) String

func (x Recipient_Type) String() string

Jump to

Keyboard shortcuts

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