Documentation ¶
Index ¶
- Variables
- func MailIDFromContext(ctx context.Context) uuid.UUID
- func New(s Store, opts ...Option) postdog.Plugin
- func WithMailID(ctx context.Context, id uuid.UUID) context.Context
- type Cursor
- type Mail
- func (m Mail) ID() uuid.UUID
- func (m Mail) Map(opts ...mapper.Option) map[string]interface{}
- func (m *Mail) Parse(mm map[string]interface{})
- func (m Mail) SendError() string
- func (m Mail) SentAt() time.Time
- func (m Mail) WithID(id uuid.UUID) Mail
- func (m Mail) WithSendError(err string) Mail
- func (m Mail) WithSendTime(t time.Time) Mail
- type Option
- type Printer
- type Store
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotFound means a mail could not be found in the Store. ErrNotFound = errors.New("mail not found") )
Functions ¶
func MailIDFromContext ¶ added in v0.13.4
MailIDFromContext returns the mail UUID from the given Context, or uuid.Nil if the Context has no mail UUID.
Types ¶
type Cursor ¶
type Cursor interface { // Next advances the cursor to the next Mail. // Implementations should return true if the next call to Current() would // return a valid Mail, or false if the Cursor reached the end or if Next() // failed because of an error. In the latter case, Err() should return that error. Next(stdctx.Context) bool // Current returns the current Mail. Current() Mail // All returns the remaining Mails from the Cursor and calls cur.Close(ctx) afterwards. All(stdctx.Context) ([]Mail, error) // Err returns the current error that occurred during a previous Next() call. Err() error // Close closes the Cursor. Users must call Close() after using the Cursor if they don't call All(). Close(stdctx.Context) error }
Cursor is a cursor archived Mails.
type Mail ¶
Mail is the archived form of a sent mail, containing the send time and send error of the mail.
func ExpandMail ¶
ExpandMail takes a postdog.Mail and builds a Mail from it. If pm has a SendError() method, the error will be added to the Mail. If pm has a SentAt() method, the time will be added as the send time.
func (Mail) SendError ¶
SendError returns the message of the send error. An empty string means there was no error.
func (Mail) WithSendError ¶
WithSendError returns a copy of m with it's send error set to err.
type Option ¶
type Option func(*config)
Option is an archive option.
func InsertTimeout ¶ added in v0.10.2
InsertTimeout returns an Option that sets the timeout for inserts.
func WithLogger ¶
WithLogger returns an Option that sets the error logger.
type Store ¶
type Store interface { // Insert inserts a Mail into the Store. Insert(stdctx.Context, Mail) error // Find returns the Mail with the given ID. Find(stdctx.Context, uuid.UUID) (Mail, error) // Query queries the Store using the given query.Query. Query(stdctx.Context, query.Query) (Cursor, error) // Remove removes the given Mail from the Store. Remove(stdctx.Context, Mail) error }
Store is the underlying store for the Mails.