queue

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2023 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

View Source
var (
	Recipient_Type_name = map[int32]string{
		0: "EMAIL",
		1: "PIPE",
	}
	Recipient_Type_value = map[string]int32{
		"EMAIL": 0,
		"PIPE":  1,
	}
)

Enum value maps for Recipient_Type.

View Source
var (
	Recipient_Status_name = map[int32]string{
		0: "PENDING",
		1: "SENT",
		2: "FAILED",
	}
	Recipient_Status_value = map[string]int32{
		"PENDING": 0,
		"SENT":    1,
		"FAILED":  2,
	}
)

Enum value maps for Recipient_Status.

View Source
var File_queue_proto protoreflect.FileDescriptor

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,proto3" json:"ID,omitempty"`
	// The envelope for this message.
	From string       `protobuf:"bytes,2,opt,name=from,proto3" json:"from,omitempty"`
	To   []string     `protobuf:"bytes,3,rep,name=To,proto3" json:"To,omitempty"`
	Rcpt []*Recipient `protobuf:"bytes,4,rep,name=rcpt,proto3" json:"rcpt,omitempty"`
	Data []byte       `protobuf:"bytes,5,opt,name=data,proto3" json:"data,omitempty"`
	// Creation timestamp.
	CreatedAtTs *Timestamp `protobuf:"bytes,6,opt,name=created_at_ts,json=createdAtTs,proto3" json:"created_at_ts,omitempty"`
	// contains filtered or unexported fields
}

func (*Message) Descriptor deprecated

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

Deprecated: Use Message.ProtoReflect.Descriptor instead.

func (*Message) GetCreatedAtTs

func (x *Message) GetCreatedAtTs() *Timestamp

func (*Message) GetData

func (x *Message) GetData() []byte

func (*Message) GetFrom

func (x *Message) GetFrom() string

func (*Message) GetID

func (x *Message) GetID() string

func (*Message) GetRcpt

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

func (*Message) GetTo

func (x *Message) GetTo() []string

func (*Message) ProtoMessage

func (*Message) ProtoMessage()

func (*Message) ProtoReflect

func (x *Message) ProtoReflect() protoreflect.Message

func (*Message) Reset

func (x *Message) Reset()

func (*Message) String

func (x *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, error)

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(tr *trace.Trace, 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,proto3" json:"address,omitempty"`
	Type               Recipient_Type   `protobuf:"varint,2,opt,name=type,proto3,enum=queue.Recipient_Type" json:"type,omitempty"`
	Status             Recipient_Status `protobuf:"varint,3,opt,name=status,proto3,enum=queue.Recipient_Status" json:"status,omitempty"`
	LastFailureMessage string           `protobuf:"bytes,4,opt,name=last_failure_message,json=lastFailureMessage,proto3" 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,proto3" json:"original_address,omitempty"`
	// contains filtered or unexported fields
}

func (*Recipient) Descriptor deprecated

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

Deprecated: Use Recipient.ProtoReflect.Descriptor instead.

func (*Recipient) GetAddress

func (x *Recipient) GetAddress() string

func (*Recipient) GetLastFailureMessage

func (x *Recipient) GetLastFailureMessage() string

func (*Recipient) GetOriginalAddress

func (x *Recipient) GetOriginalAddress() string

func (*Recipient) GetStatus

func (x *Recipient) GetStatus() Recipient_Status

func (*Recipient) GetType

func (x *Recipient) GetType() Recipient_Type

func (*Recipient) ProtoMessage

func (*Recipient) ProtoMessage()

func (*Recipient) ProtoReflect

func (x *Recipient) ProtoReflect() protoreflect.Message

func (*Recipient) Reset

func (x *Recipient) Reset()

func (*Recipient) String

func (x *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) Descriptor

func (Recipient_Status) Enum

func (Recipient_Status) EnumDescriptor deprecated

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

Deprecated: Use Recipient_Status.Descriptor instead.

func (Recipient_Status) Number

func (Recipient_Status) String

func (x Recipient_Status) String() string

func (Recipient_Status) Type

type Recipient_Type

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

func (Recipient_Type) Descriptor

func (Recipient_Type) Enum

func (x Recipient_Type) Enum() *Recipient_Type

func (Recipient_Type) EnumDescriptor deprecated

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

Deprecated: Use Recipient_Type.Descriptor instead.

func (Recipient_Type) Number

func (Recipient_Type) String

func (x Recipient_Type) String() string

func (Recipient_Type) Type

type Timestamp

type Timestamp struct {

	// Represents seconds of UTC time since Unix epoch.
	Seconds int64 `protobuf:"varint,1,opt,name=seconds,proto3" json:"seconds,omitempty"`
	// Non-negative fractions of a second at nanosecond resolution.
	Nanos int32 `protobuf:"varint,2,opt,name=nanos,proto3" json:"nanos,omitempty"`
	// contains filtered or unexported fields
}

Timestamp representation, for convenience. We used to use the well-known type, but the dependency makes packaging much more convoluted and adds very little value, so we now just include it here.

func (*Timestamp) Descriptor deprecated

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

Deprecated: Use Timestamp.ProtoReflect.Descriptor instead.

func (*Timestamp) GetNanos

func (x *Timestamp) GetNanos() int32

func (*Timestamp) GetSeconds

func (x *Timestamp) GetSeconds() int64

func (*Timestamp) ProtoMessage

func (*Timestamp) ProtoMessage()

func (*Timestamp) ProtoReflect

func (x *Timestamp) ProtoReflect() protoreflect.Message

func (*Timestamp) Reset

func (x *Timestamp) Reset()

func (*Timestamp) String

func (x *Timestamp) String() string

Jump to

Keyboard shortcuts

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