Documentation ¶
Index ¶
- Constants
- func GetMessageHash(b []byte) (string, error)
- type ID
- type SendRecorder
- func (h *SendRecorder) HasEntryWait(ctx context.Context, hash string, deadline time.Time, toList []string) (string, bool, error)
- func (h *SendRecorder) RemoveOnFail(hash string, id ID)
- func (h *SendRecorder) SignalMessageSent(hash string, srID ID, msgID string)
- func (h *SendRecorder) TryInsert(hash string, toList []string) (ID, <-chan struct{}, bool)
- func (h *SendRecorder) TryInsertWait(ctx context.Context, hash string, toList []string, deadline time.Time) (ID, bool, error)
Constants ¶
const SendEntryExpiry = 30 * time.Minute
Variables ¶
This section is empty.
Functions ¶
func GetMessageHash ¶
GetMessageHash returns the hash of the given message. This takes into account: - the Subject header, - the From/To/Cc headers, - the Content-Type header of each (leaf) part, - the Content-Disposition header of each (leaf) part, - the (decoded) body of each part.
Types ¶
type SendRecorder ¶
type SendRecorder struct {
// contains filtered or unexported fields
}
func NewSendRecorder ¶
func NewSendRecorder(expiry time.Duration) *SendRecorder
func (*SendRecorder) HasEntryWait ¶
func (h *SendRecorder) HasEntryWait(ctx context.Context, hash string, deadline time.Time, toList []string, ) (string, bool, error)
HasEntryWait returns whether the given message already exists in the send recorder. If it does, it waits for its ID to be known, then returns it and true. If no entry exists, or it times out while waiting for its ID to be known, it returns false.
func (*SendRecorder) RemoveOnFail ¶
func (h *SendRecorder) RemoveOnFail(hash string, id ID)
func (*SendRecorder) SignalMessageSent ¶
func (h *SendRecorder) SignalMessageSent(hash string, srID ID, msgID string)
SignalMessageSent should be called after a message has been successfully sent.
func (*SendRecorder) TryInsert ¶
func (h *SendRecorder) TryInsert(hash string, toList []string) (ID, <-chan struct{}, bool)
func (*SendRecorder) TryInsertWait ¶
func (h *SendRecorder) TryInsertWait( ctx context.Context, hash string, toList []string, deadline time.Time, ) (ID, bool, error)
TryInsertWait tries to insert the given message into the send recorder. If an entry already exists but it was not sent yet, it waits. It returns whether an entry could be inserted and an error if it times out while waiting.