{"modulePath":"github.com/uber/submitqueue","version":"v0.2.1","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package messagequeue\n\n## Types\n\n```go\ntype DLQConfig struct {\n\t// Enabled enables dead letter queue.\n\tEnabled bool\n\n\t// TopicSuffix is appended to the original topic name to create the DLQ topic.\n\t// For example, if original topic is \"orders\" and suffix is \"_dlq\", DLQ topic will be \"orders_dlq\".\n\tTopicSuffix string\n}\n```\nDLQConfig configures dead letter queue behavior.\n\n```go\ntype Delivery interface {\n\t// Message returns the delivered message.\n\tMessage() entityqueue.Message\n\n\t// Ack acknowledges successful processing of the message.\n\t// The message will be removed from the queue and not redelivered.\n\tAck(ctx context.Context) error\n\n\t// Nack negatively acknowledges the message, indicating processing failure.\n\t// The message will be requeued for redelivery after requeueAfterMillis.\n\t// If requeueAfterMillis is 0, the message is requeued immediately.\n\tNack(ctx context.Context, requeueAfterMillis int64) error\n\n\t// Reject moves the message to the dead letter entityqueue.\n\t// Use for poison pill messages that should never be retried.\n\t// reason is stored as last_error in the DLQ for debugging.\n\t// If DLQ is not configured, the message is acked (removed from queue).\n\tReject(ctx context.Context, reason string) error\n\n\t// ExtendVisibilityTimeout extends the time before this message becomes\n\t// visible to other consumers. Use when processing takes longer than expected.\n\tExtendVisibilityTimeout(ctx context.Context, durationMillis int64) error\n\n\t// DeliveryID returns a backend-specific identifier for this delivery.\n\tDeliveryID() string\n\n\t// Attempt returns how many times this message has been delivered.\n\t// Starts at 1 for first delivery.\n\tAttempt() int\n\n\t// ReceivedAt returns when this delivery was received (Unix milliseconds).\n\tReceivedAt() int64\n\n\t// Metadata returns backend-specific delivery metadata.\n\tMetadata() map[string]string\n}\n```\nDelivery represents a message delivered by a Subscriber. Provides access to the message and methods to acknowledge or reject it.\n\nImplementations must be safe for concurrent Message() calls. Ack/Nack/ExtendVisibilityTimeout should not be called concurrently on the same instance.\n\n```go\ntype Publisher interface {\n\t// Publish sends a message to the specified topic.\n\tPublish(ctx context.Context, topic string, message entityqueue.Message) error\n\n\t// PublishAfter sends a message that becomes visible to subscribers only\n\t// after delayMs from now. It is a fresh publish — not a redelivery — so\n\t// it does not consume a delivery_state retry slot. delayMs \u003c= 0 is\n\t// equivalent to Publish.\n\t//\n\t// Use for \"postpone this work\" semantics (e.g. spacing out repeated\n\t// poll cycles for a single key). Use Nack with a delay for \"this\n\t// delivery failed, try again\" — the two signals stay separate so\n\t// retry_count and DLQ behaviour remain meaningful.\n\tPublishAfter(ctx context.Context, topic string, message entityqueue.Message, delayMs int64) error\n\n\t// Close gracefully shuts down the publisher, flushing pending messages.\n\tClose() error\n}\n```\nPublisher publishes messages to topics. Implementations must be thread-safe.\n\n```go\ntype Queue interface {\n\t// Publisher returns a Publisher instance.\n\t// May return a singleton or new instance depending on implementation.\n\tPublisher() Publisher\n\n\t// Subscriber returns a Subscriber instance.\n\t// May return a singleton or new instance depending on implementation.\n\tSubscriber() Subscriber\n\n\t// Close shuts down the queue and all associated resources.\n\tClose() error\n}\n```\nQueue creates and manages queue publishers and subscribers. Implementations handle connection pooling, consumer group configuration, and resource lifecycle.\n\n```go\ntype RetryConfig struct {\n\t// MaxAttempts is the maximum number of processing attempts.\n\t// After this many attempts, the message is moved to DLQ (if enabled).\n\tMaxAttempts int\n\n\t// InitialBackoffMs is the initial backoff duration for retries (in milliseconds).\n\tInitialBackoffMs int64\n\n\t// MaxBackoffMs is the maximum backoff duration (in milliseconds).\n\tMaxBackoffMs int64\n\n\t// BackoffMultiplier is the multiplier for exponential backoff.\n\tBackoffMultiplier float64\n}\n```\nRetryConfig configures message retry behavior.\n\n```go\ntype Subscriber interface {\n\t// Subscribe starts consuming messages from the specified topic with the given config.\n\t// Returns a channel of Delivery instances and an error if subscription fails.\n\t//\n\t// Each subscription can have its own configuration for polling, batching,\n\t// retries, and dead letter queue behavior.\n\t//\n\t// The channel is closed when the subscriber is closed or context is cancelled.\n\t// Implementations should handle infrastructure errors internally (e.g., reconnect).\n\t//\n\t// Each Delivery provides the message and methods to acknowledge or reject it.\n\t// Consumers should call delivery.Ack() or delivery.Nack() for each delivery.\n\tSubscribe(ctx context.Context, topic string, config SubscriptionConfig) (\u003c-chan Delivery, error)\n\n\t// Close gracefully shuts down the subscriber.\n\t// All delivery channels will be closed.\n\t// Idempotent - safe to call multiple times.\n\tClose() error\n}\n```\nSubscriber consumes messages from topics. Implementations must be thread-safe.\n\n```go\ntype SubscriptionConfig struct {\n\t// SubscriberName uniquely identifies this subscriber instance for partition leases.\n\t// Different workers should use different names (e.g., hostname, pod name, UUID).\n\t// Combined with ConsumerGroup, this determines which worker owns a partition lease.\n\tSubscriberName string\n\n\t// ConsumerGroup identifies this consumer for offset tracking.\n\t// Different consumer groups maintain independent offsets.\n\tConsumerGroup string\n\n\t// PollIntervalMs is how often to poll for new messages (in milliseconds).\n\tPollIntervalMs int64\n\n\t// BatchSize is the maximum number of messages to fetch per poll.\n\tBatchSize int\n\n\t// VisibilityTimeoutMs is how long a message is invisible after being fetched (in milliseconds).\n\t// If the worker crashes or doesn't ack/nack in time, the message becomes\n\t// visible again after this duration.\n\tVisibilityTimeoutMs int64\n\n\t// LeaseRenewalIntervalMs is how often to renew partition leases (in milliseconds).\n\tLeaseRenewalIntervalMs int64\n\n\t// LeaseDurationMs is how long a lease is valid without renewal (in milliseconds).\n\t// Stale leases (not renewed within this duration) can be stolen by other workers.\n\tLeaseDurationMs int64\n\n\t// Retry configures message retry behavior.\n\tRetry RetryConfig\n\n\t// DLQ configures dead letter queue behavior.\n\tDLQ DLQConfig\n}\n```\nSubscriptionConfig holds per-subscription configuration. Each subscription (topic) can have its own settings for polling, batching, retries, and dead letter queue behavior.\n\n```go\nfunc DefaultSubscriptionConfig(subscriberName, consumerGroup string) SubscriptionConfig\n```\nDefaultSubscriptionConfig returns a SubscriptionConfig with sensible defaults.\n\n","path":"github.com/uber/submitqueue/platform/extension/messagequeue","name":"messagequeue","synopsis":"","isRedistributable":true}
