Something went wrong. Try again.
wip outbox library design
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566package outpost
import "time"
// Message is the durable unit of work: enough to route, execute, and retry it.type Message struct { // ID identifies the message. Emit generates one when unset. It is stable // across retries and is the natural provider idempotency key. ID string
// Name selects the handler. It is the wire contract between emitter and // consumer: version it ("email.send.v2") when the payload can evolve. Name string
// Key groups related messages, for example a recipient or user id. The // core does not interpret it; producers and backends may. Key string
// Payload is the encoded message body. The core treats it as opaque. Payload []byte
// Headers carries out-of-band metadata such as trace context. Treat it as // immutable: Emit freezes it and nothing in the core mutates it. Headers map[string]string
// CreatedAt is stamped by Emit and persisted by adapters for audit; the // core does not read it. CreatedAt time.Time
// AvailableAt is the earliest delivery time. The zero value means now. AvailableAt time.Time}
// Claim is a leased message handed to the relay by a Store.type Claim struct { Message
// Attempts is the number of failed deliveries recorded for the message so // far. The delivery the relay is about to perform is Attempts+1. Attempts int
// Token identifies this lease. Complete and Fail affect nothing unless the // token still matches the store's current lease. Token string}
// ClaimRef addresses a lease for Complete and Fail.type ClaimRef struct { ID string Token string}
// Info is the message metadata available to handlers and hooks.type Info struct { ID string Name string Key string
// Attempt is the delivery number. It starts at 1 for messages delivered by // a relay, and is 0 for a message that did not come from one. Attempt int
// Headers is shared with the message; treat it as read-only. Headers map[string]string}