{"modulePath":"github.com/foxcpp/maddy","version":"v0.9.8","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package queue\n\nPackage queue implements module which keeps messages on disk and tries delivery to the configured target (usually remote) multiple times until all recipients are succeeded.\n\nInterfaces implemented: - module.DeliveryTarget\n\nImplementation summary follows.\n\nAll scheduled deliveries are attempted to the configured DeliveryTarget. All metadata is preserved on disk.\n\nFailure status is determined on per-recipient basis:\n\n  - Delivery.StartDelivery fail handled as a failure for all recipients.\n  - Delivery.AddRcpt fail handled as a failure for the corresponding recipient.\n  - Delivery.Body fail handled as a failure for all recipients.\n  - If Delivery implements PartialDelivery, then PartialDelivery.BodyNonAtomic is used instead. Failures are determined based on StatusCollector.SetStatus calls done by target in this case.\n\nFor each failure check is done to see if it is a permanent failure or a temporary one. This is done using exterrors.IsTemporaryOrUnspec. That is, errors are assumed to be temporary by default. All errors are converted to SMTPError then due to a storage limitations.\n\nIf there are any \\*temporary\\* failed recipients, delivery will be retried after delay \\*only for these\\* recipients.\n\nLast error for each recipient is saved for reporting in NDN. A NDN is generated if there are any failed recipients left after last attempt to deliver the message.\n\nAmount of attempts for each message is limited to a certain configured number. After last attempt, all recipients that are still temporary failing are assumed to be permanently failed.\n\n## Functions\n\n```go\nfunc New(c *container.C, modName, instName string) (module.Module, error)\n```\n\n## Types\n\n```go\ntype BufferedReadCloser struct {\n\t*bufio.Reader\n\tio.Closer\n}\n```\n\n```go\ntype Queue struct {\n\tTarget module.DeliveryTarget\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (q *Queue) Configure(inlineArgs []string, cfg *config.Map) error\n```\n\n```go\nfunc (q *Queue) EarlyStop() error\n```\n\n```go\nfunc (q *Queue) InstanceName() string\n```\n\n```go\nfunc (q *Queue) Name() string\n```\n\n```go\nfunc (q *Queue) Start() error\n```\n\n```go\nfunc (q *Queue) StartDelivery(ctx context.Context, msgMeta *module.MsgMetadata, mailFrom string) (module.Delivery, error)\n```\n\n```go\nfunc (q *Queue) Stop() error\n```\n\n```go\ntype QueueMetadata struct {\n\tMsgMeta *module.MsgMetadata\n\tFrom    string\n\n\t// Recipients that should be tried next.\n\t// May or may not be equal to partialError.TemporaryFailed.\n\tTo []string\n\n\t// Information about previous failures.\n\t// Preserved to be included in a bounce message.\n\tFailedRcpts          []string\n\tTemporaryFailedRcpts []string\n\t// All errors are converted to SMTPError we can serialize and\n\t// also it is directly usable for bounce messages.\n\tRcptErrs map[string]*smtp.SMTPError\n\n\t// Amount of times delivery *already tried*.\n\tTriesCount map[string]int\n\n\tFirstAttempt time.Time\n\tLastAttempt  time.Time\n}\n```\n\n```go\ntype TimeSlot[Value any] struct {\n\tTime  time.Time\n\tValue Value\n}\n```\n\n```go\ntype TimeWheel[Value any] struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewTimeWheel[Value any](dispatch func(context.Context, TimeSlot[Value])) *TimeWheel[Value]\n```\n\n```go\nfunc (tw *TimeWheel[Value]) Add(target time.Time, value Value)\n```\n\n```go\nfunc (tw *TimeWheel[Value]) Close()\n```\n\n","path":"github.com/foxcpp/maddy/internal/target/queue","name":"queue","synopsis":"Package queue implements module which keeps messages on disk and tries delivery to the configured target (usually remote) multiple times until all recipients are succeeded.","isRedistributable":true}
