{"modulePath":"github.com/uber/submitqueue","version":"v0.2.1","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package lib\n\n## Functions\n\n```go\nfunc FormatJSON(w io.Writer, v any) error\n```\nFormatJSON marshals v as indented JSON and writes it to w.\n\n```go\nfunc FormatMillis(ms int64) string\n```\nFormatMillis converts an epoch-millisecond timestamp to a human-readable string. Returns \"-\" for zero values (no timestamp set).\n\n```go\nfunc FormatTable(w io.Writer, headers []string, rows [][]string)\n```\nFormatTable writes rows as an aligned text table to w. headers defines column names. rows is a slice of slices where each inner slice corresponds to one row's cell values (pre-formatted as strings).\n\n## Types\n\n```go\ntype AdminStore struct {\n\t// contains filtered or unexported fields\n}\n```\nAdminStore provides read-only inspection and targeted admin mutations for the MySQL queue tables.\n\n```go\nfunc NewAdminStore(db *sql.DB) *AdminStore\n```\nNewAdminStore creates a new AdminStore backed by the given database connection.\n\n```go\nfunc (s *AdminStore) ConsumerLag(ctx context.Context, topic string) ([]LagInfo, error)\n```\nConsumerLag returns per-partition lag for each consumer group on a topic. Lag = max message offset in partition - consumer group's acked offset.\n\n```go\nfunc (s *AdminStore) DeleteMessage(ctx context.Context, topic string, messageID string) (int64, error)\n```\nDeleteMessage deletes a specific message by topic and ID.\n\n```go\nfunc (s *AdminStore) GetTopicStats(ctx context.Context, topic string, dlqSuffix string) (TopicStats, error)\n```\nGetTopicStats returns detailed statistics for a topic.\n\n```go\nfunc (s *AdminStore) InspectMessage(ctx context.Context, topic string, messageID string) (MessageDetail, bool, error)\n```\nInspectMessage returns full message details including payload and DLQ fields.\n\n```go\nfunc (s *AdminStore) ListLeases(ctx context.Context) ([]LeaseInfo, error)\n```\nListLeases returns all partition leases.\n\n```go\nfunc (s *AdminStore) ListMessages(ctx context.Context, topic string, partition string, limit int) ([]MessageSummary, error)\n```\nListMessages returns messages for a topic, optionally filtered by partition.\n\n```go\nfunc (s *AdminStore) ListOffsets(ctx context.Context, consumerGroup string) ([]OffsetInfo, error)\n```\nListOffsets returns consumer group offsets, optionally filtered by group.\n\n```go\nfunc (s *AdminStore) ListTopics(ctx context.Context) ([]TopicInfo, error)\n```\nListTopics returns all topics with their message counts.\n\n```go\nfunc (s *AdminStore) PurgeTopic(ctx context.Context, topic string) (int64, error)\n```\nPurgeTopic deletes all messages for a topic.\n\n```go\nfunc (s *AdminStore) ReleaseLease(ctx context.Context, consumerGroup, topic, partition string) (int64, error)\n```\nReleaseLease force-releases a partition lease.\n\n```go\nfunc (s *AdminStore) RequeueDLQ(ctx context.Context, topic string, messageID string, dlqSuffix string) error\n```\nRequeueDLQ moves a message from the DLQ topic back to its original topic. This is done transactionally: read from DLQ, insert into original topic, delete from DLQ.\n\n```go\nfunc (s *AdminStore) ResetOffset(ctx context.Context, consumerGroup, topic, partition string, offset int64) (int64, error)\n```\nResetOffset updates the acked offset for a consumer group/topic/partition.\n\n```go\nfunc (s *AdminStore) StaleLeases(ctx context.Context, thresholdMs int64) ([]LeaseInfo, error)\n```\nStaleLeases returns leases whose lease\\_renewed\\_at is older than the threshold. thresholdMs is the staleness threshold in milliseconds — leases not renewed within this duration from now are considered stale.\n\n```go\ntype LagInfo struct {\n\t// ConsumerGroup is the consumer group name\n\tConsumerGroup string\n\t// Topic is the topic being consumed\n\tTopic string\n\t// PartitionKey is the partition being consumed\n\tPartitionKey string\n\t// LatestOffset is the highest message offset in this partition\n\tLatestOffset int64\n\t// AckedOffset is the last acked offset for this consumer group\n\tAckedOffset int64\n\t// Lag is the number of unprocessed messages (LatestOffset - AckedOffset)\n\tLag int64\n}\n```\nLagInfo contains consumer lag information for a single partition.\n\n```go\ntype LeaseInfo struct {\n\t// ConsumerGroup is the consumer group name\n\tConsumerGroup string\n\t// Topic is the topic being consumed\n\tTopic string\n\t// PartitionKey is the partition that is leased\n\tPartitionKey string\n\t// LeasedBy is the worker that owns the lease\n\tLeasedBy string\n\t// LeasedAt is the epoch milliseconds when the lease was acquired\n\tLeasedAt int64\n\t// LeaseRenewedAt is the epoch milliseconds of the last renewal\n\tLeaseRenewedAt int64\n}\n```\nLeaseInfo contains partition lease information.\n\n```go\ntype MessageDetail struct {\n\tMessageSummary\n\t// Payload is the message body\n\tPayload []byte\n\t// Metadata contains key-value pairs for message attributes\n\tMetadata map[string]string\n\t// FailedAt is epoch milliseconds when the message failed (0 for normal)\n\tFailedAt int64\n\t// FailureCount is total failures before DLQ move (0 for normal)\n\tFailureCount int\n\t// LastError is the error message from final failure\n\tLastError string\n\t// OriginalTopic is where the message originally failed\n\tOriginalTopic string\n}\n```\nMessageDetail contains all message fields including payload and DLQ info.\n\n```go\ntype MessageSummary struct {\n\t// Offset is the auto-incrementing sequence number\n\tOffset int64\n\t// ID is the unique message identifier\n\tID string\n\t// Topic identifies the queue type\n\tTopic string\n\t// PartitionKey determines message distribution\n\tPartitionKey string\n\t// CreatedAt is the epoch milliseconds when the message was created\n\tCreatedAt int64\n\t// PublishedAt is the epoch milliseconds when the message was published\n\tPublishedAt int64\n}\n```\nMessageSummary contains a subset of message fields for listing.\n\n```go\ntype OffsetInfo struct {\n\t// ConsumerGroup is the consumer group name\n\tConsumerGroup string\n\t// Topic is the topic being consumed\n\tTopic string\n\t// PartitionKey is the partition being consumed\n\tPartitionKey string\n\t// OffsetAcked is the last successfully acked offset\n\tOffsetAcked int64\n\t// UpdatedAt is the epoch milliseconds of the last update\n\tUpdatedAt int64\n}\n```\nOffsetInfo contains consumer group offset information.\n\n```go\ntype TopicInfo struct {\n\t// Topic is the queue topic name\n\tTopic string\n\t// MessageCount is the number of messages in this topic\n\tMessageCount int64\n}\n```\nTopicInfo contains a topic name and its message count.\n\n```go\ntype TopicStats struct {\n\t// Topic is the queue topic name\n\tTopic string\n\t// TotalMessages is the total number of messages\n\tTotalMessages int64\n\t// DLQCount is the number of messages in the DLQ for this topic\n\tDLQCount int64\n\t// PartitionCount is the number of distinct partitions\n\tPartitionCount int64\n\t// ConsumerGroupCount is the number of consumer groups consuming this topic\n\tConsumerGroupCount int64\n}\n```\nTopicStats contains detailed statistics for a topic.\n\n","path":"github.com/uber/submitqueue/platform/extension/messagequeue/mysql/ctl/lib","name":"lib","synopsis":"","isRedistributable":true}
