Documentation
¶
Index ¶
Constants ¶
const QueueKeyPrefix = "sfmail:"
QueueKeyPrefix is the prefix used for the underlying Streamfleet queues used for email queues.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a mail queue client.
func NewClient ¶
func NewClient(ctx context.Context, sfClientOpt streamfleet.ClientOpt, queueKey string) (*Client, error)
NewClient creates a new mail client. Uses the specified queue key and Streamfleet client options. The client will only be able to send mail on the mail queue with the specified key. Make sure all workers this client is meant to queue to have the same queue key.
func (*Client) Close ¶
Close closes the client and releases all associated resources. The client cannot be used after Close has been called.
func (*Client) EnqueueAndForget ¶
EnqueueAndForget adds an email to the queue and immediately returns. Errors in queuing or the status of the email once it is picked up by a server are not tracked. If you need to know when the email has been sent, use EnqueueAndTrack. If the number of locally queued emails would exceed streamfleet.ClientOpt.MaxLocalQueueSize, returns streamfleet.ErrClientQueueFull. This will normally only happen if the client cannot connect to Redis and emails pile up.
func (*Client) EnqueueAndTrack ¶
func (c *Client) EnqueueAndTrack(email *mail.Msg, opt streamfleet.TaskOpt) (*streamfleet.TaskHandle, error)
EnqueueAndTrack adds an email to the queue and returns a handle to it. Errors in queuing or the status of the email once it is picked up by the server can be tracked using the returned handle. If you do not need to know when the email has been sent, use EnqueueAndForget. You should only use this method if you need to know the status of the email, as it is less efficient than EnqueueAndForget.
If the number of locally queued emails would exceed streamfleet.ClientOpt.MaxLocalQueueSize, returns streamfleet.ErrClientQueueFull. This will normally only happen if the client cannot connect to Redis and emails pile up.
type Worker ¶
type Worker struct {
// contains filtered or unexported fields
}
Worker is a worker that receives emails from the queue and sends them.
func NewWorker ¶
func NewWorker(ctx context.Context, mailClient *mail.Client, sfClientOpt streamfleet.ServerOpt, queueKey string) (*Worker, error)
NewWorker creates a new mail worker that takes emails off the queue and sends them. Uses the specified queue key and Streamfleet server options. The worker will only be able to receive mail from the mail queue with the specified key. Make sure all clients this worker is meant to queue from have the same queue key.