mysql

package
v0.3.0-20260730171007-... Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 30, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

README

SQL Queue Implementation

MySQL-based distributed queue with partition leasing, delivery state tracking, and at-least-once delivery.

For design rationale, guarantees, and trade-offs, see the RFC.

Quick Start

import (
    "database/sql"
    _ "github.com/go-sql-driver/mysql"
    queueMySQL "github.com/uber/submitqueue/platform/extension/messagequeue/mysql"
    extqueue "github.com/uber/submitqueue/platform/extension/messagequeue"
    entityqueue "github.com/uber/submitqueue/platform/base/messagequeue"
)

// Setup
db, _ := sql.Open("mysql", "user:pass@tcp(localhost:3306)/db")
q, _ := queueMySQL.NewQueue(queueMySQL.Params{
    DB:           db,
    Logger:       logger,
    MetricsScope: metrics,
})
defer q.Close()

// Publish
msg := entityqueue.NewMessage("msg-id", []byte(`{"data": "value"}`), "repo-123", nil)
q.Publisher().Publish(ctx, "merge_events", msg)

// Subscribe with per-subscription config
subConfig := extqueue.DefaultSubscriptionConfig("worker-1", "orchestrator")
deliveryCh, _ := q.Subscriber().Subscribe(ctx, "merge_events", subConfig)
for delivery := range deliveryCh {
    if err := process(delivery.Message()); err != nil {
        delivery.Nack(ctx, 0)  // Retry
        continue
    }
    delivery.Ack(ctx)
}

Configuration

Per-subscription configuration enables different settings for each topic:

import extqueue "github.com/uber/submitqueue/platform/extension/messagequeue"

subConfig := extqueue.DefaultSubscriptionConfig("worker-1", "consumer-group")

subConfig.PollIntervalMs = 50                         // Poll frequency (milliseconds)
subConfig.BatchSize = 20                              // Messages per poll
subConfig.VisibilityTimeoutMs = 60000                 // Retry delay (milliseconds)
subConfig.LeaseRenewalIntervalMs = 10000              // Lease renewal frequency (milliseconds)
subConfig.LeaseDurationMs = 30000                     // Lease timeout (milliseconds)
subConfig.Retry.MaxAttempts = 3                       // Max retries before DLQ
subConfig.Retry.InitialBackoffMs = 1000               // Initial retry backoff (milliseconds)
subConfig.Retry.MaxBackoffMs = 30000                  // Max retry backoff (milliseconds)
subConfig.Retry.BackoffMultiplier = 2.0               // Backoff multiplier for exponential backoff
subConfig.DLQ.Enabled = true                          // Enable dead letter queue
subConfig.DLQ.TopicSuffix = "_dlq"                    // DLQ topic suffix

Key Configuration Fields:

Field Description
SubscriberName Unique worker identifier for partition leasing (e.g., hostname, pod name)
ConsumerGroup Consumer group for independent offset tracking
PollIntervalMs How often to poll for new messages
BatchSize Maximum messages to fetch per poll. Set to 1 for strict serialization
VisibilityTimeoutMs How long messages are invisible after fetch. Must exceed max processing time for BatchSize=1
LeaseRenewalIntervalMs How often to renew partition leases
LeaseDurationMs How long leases remain valid without renewal
Retry.MaxAttempts Maximum processing attempts before DLQ
DLQ.TopicSuffix Suffix appended to topic name for DLQ (e.g., "orders""orders_dlq")

Package Layout

platform/extension/messagequeue/mysql/
├── sql.go                          # NewQueue constructor, wires stores → publisher/subscriber
├── stores.go                       # Internal store interfaces (messageStore, offsetStore, etc.)
├── message_store.go                # queue_messages table operations (immutable log)
├── delivery_state_store.go         # queue_delivery_state table operations (per-consumer-group)
├── offset_store.go                 # queue_offsets table operations (watermark tracking)
├── partition_lease_store.go        # queue_partition_leases table operations
├── subscriber_heartbeat_store.go   # queue_subscriber_heartbeats table operations
├── publisher.go                    # Publisher implementation
├── subscriber.go                   # Subscriber, delivery, goroutine management
├── constants.go                    # Log key constants
├── errors.go                       # Error types
├── schema/                         # SQL schema files (one per table)
│   ├── queue_messages.sql
│   ├── queue_delivery_state.sql
│   ├── queue_offsets.sql
│   ├── queue_partition_leases.sql
│   └── queue_subscriber_heartbeats.sql
└── ctl/                            # Admin CLI (see ctl/README.md)

Internal Architecture

Database Tables
Table Purpose Scoped To
queue_messages Immutable append-only message log (topic, partition_key) — shared across consumer groups
queue_delivery_state Visibility, ack state, retry count (consumer_group, topic, partition_key, offset)
queue_offsets Contiguous acked watermark (consumer_group, topic, partition_key)
queue_partition_leases Partition lease coordination (consumer_group, topic, partition_key)
queue_subscriber_heartbeats Active subscriber tracking (consumer_group, topic, subscriber_name)

queue_messages has a visible_after BIGINT UNSIGNED NOT NULL DEFAULT 0 column that supports Publisher.PublishAfter: subscribers' FetchByOffset skips rows where visible_after > now. Default 0 means immediately visible, so existing rows continue to behave as before — the column is back-compatible.

See schema/ for full SQL definitions. See the RFC for field-level documentation.

Store Architecture

Each table is backed by an internal store interface defined in stores.go. Stores:

  • Query only their own table (no cross-table JOINs)
  • Return errors via fmt.Errorf (no logging, no error classification)
  • Use metrics.Begin/Complete for latency and success/failure tracking

The subscriber layer orchestrates cross-store operations (e.g., watermark advancement queries both messageStore and deliveryStateStore) and owns all logging and error classification.

Goroutine Model

Each subscription has a supervisor goroutine (managePartitions) that discovers partitions, acquires leases, sends heartbeats, rebalances, and reconciles per-partition worker goroutines.

Subscribe()
  └── managePartitions (supervisor)       ← tracked by sub.wg
        ├── partitionWorker("part-1")     ← tracked by sub.workerWg
        ├── partitionWorker("part-2")
        └── partitionWorker("part-3")

Each partition worker runs independently — polls the DB on a ticker, checks deliverability via GetDeliveryState per message, and sends deliveries to the shared channel. A slow or blocked partition does not affect other partitions.

Shutdown Sequence

When Close() is called:

  1. Subscription context is cancelled
  2. managePartitions calls stopAllWorkers — cancels each worker's context, waits up to 30s
  3. Partition leases are released (fresh context, not cancelled)
  4. Subscriber heartbeat is deregistered
  5. workerWg.Wait() — blocks until all workers have fully exited
  6. deliveryCh is closed — safe because no senders remain after step 5
  7. managePartitions returns → wg.Done()Close() unblocks

The workerWg.Wait() before close(deliveryCh) prevents a race where a slow worker could send on a closed channel.

Worker Stop Behavior

When a partition worker is stopped (lease lost or shutdown):

  • Immediately removed from workers map and context cancelled
  • Caller waits up to 30s for exit confirmation (warning logged on timeout)
  • workerWg tracks the goroutine regardless — Close() always waits for full exit
  • Reconciliation can start a replacement immediately — brief overlap is harmless with at-least-once semantics
Logger Hierarchy

sql.go creates a root queue_mysql logger and passes named children to each component:

queue_mysql
  ├── .publisher
  ├── .subscriber
  ├── .message_store
  ├── .delivery_state_store
  ├── .offset_store
  ├── .partition_lease_store
  └── .subscriber_heartbeat_store

Stores do not log errors — they return them. The subscriber propagates all errors to the top call site (managePartitions or run), which logs once with full context (topic, consumer_group, subscriber_name).

Testing

Unit Tests
bazel test //platform/extension/messagequeue/mysql:mysql_test --test_output=streamed
bazel test //platform/extension/messagequeue/mysql/ctl/...:all --test_output=streamed
Integration Tests

Requires Docker running:

bazel test //test/integration/extension/messagequeue/... --test_output=streamed

Integration tests cover: publish/subscribe, partition isolation, ordering, visibility timeout, nack with delay, idempotent publish, concurrent publishers, crash recovery, multiple consumer groups, rebalancing, DLQ, graceful shutdown, non-blocking nack, strict serialization (BatchSize=1), and independent consumer group state.

Documentation

Overview

Package mysql is a generated GoMock package.

Index

Constants

View Source
const (
	// Fixed table names for single-table design
	MessagesTableName             = "queue_messages"
	PartitionLeasesTableName      = "queue_partition_leases"
	OffsetsTableName              = "queue_offsets"
	SubscriberHeartbeatsTableName = "queue_subscriber_heartbeats"
	DeliveryStateTableName        = "queue_delivery_state"
)

Variables

View Source
var ErrPublisherClosed = errors.New("publisher is closed")

ErrPublisherClosed is returned when attempting to publish after the publisher has been closed. This is a graceful error, not a programming bug — concurrent goroutines may still hold references to the publisher when Close() is called, and their subsequent Publish calls return this error to signal they should stop.

View Source
var ErrSubscriberClosed = errors.New("subscriber is closed")

ErrSubscriberClosed is returned when attempting to subscribe after the subscriber has been closed.

Functions

func NewPublisher

func NewPublisher(logger *zap.SugaredLogger, scope tally.Scope, messageStore messageStore) *publisher

NewPublisher creates a publisher with the given dependencies

func NewQueue

func NewQueue(params Params) (extqueue.Queue, error)

NewQueue creates a new SQL-based queue

func NewSubscriber

func NewSubscriber(logger *zap.SugaredLogger, scope tally.Scope, messageStore messageStore, offsetStore offsetStore, leaseStore partitionLeaseStore, heartbeatStore subscriberHeartbeatStore, deliveryStateStore deliveryStateStore) *subscriber

Types

type DeliveryState

type DeliveryState struct {
	// Acked indicates whether this consumer group has processed the message
	Acked bool
	// InvisibleUntil is the epoch milliseconds until which the message is hidden
	InvisibleUntil int64
	// RetryCount tracks how many times the message has been delivered
	RetryCount int
}

DeliveryState represents the full per-message delivery tracking state.

type ErrAlreadyAcknowledged

type ErrAlreadyAcknowledged struct {
	DeliveryID string
}

ErrAlreadyAcknowledged is returned when attempting to ack/nack a delivery that was already processed

func (*ErrAlreadyAcknowledged) Error

func (e *ErrAlreadyAcknowledged) Error() string

type ErrLeaseExpired

type ErrLeaseExpired struct {
	// Topic is the topic the lease was for.
	Topic string
	// PartitionKey is the partition the lease was for.
	PartitionKey string
}

ErrLeaseExpired is returned when a lease renewal fails because the lease is no longer owned by this worker (rows affected == 0).

func (*ErrLeaseExpired) Error

func (e *ErrLeaseExpired) Error() string

type HookSignal

type HookSignal int

HookSignal identifies the type of subscriber lifecycle event. Named after behavioral concerns (what happened) rather than implementation details (which loop ran), so signal names remain stable across refactors.

const (
	// SignalDeliveryCheck is sent after the subscriber checks a partition for
	// deliverable messages (including watermark advancement).
	SignalDeliveryCheck HookSignal = iota

	// SignalPartitionUpdate is sent after the subscriber evaluates partition
	// ownership (discovery, rebalance, lease renewal, heartbeat).
	SignalPartitionUpdate
)

type MockdeliveryStateStore

type MockdeliveryStateStore struct {
	// contains filtered or unexported fields
}

MockdeliveryStateStore is a mock of deliveryStateStore interface.

func NewMockdeliveryStateStore

func NewMockdeliveryStateStore(ctrl *gomock.Controller) *MockdeliveryStateStore

NewMockdeliveryStateStore creates a new mock instance.

func (*MockdeliveryStateStore) AdvanceWatermark

func (m *MockdeliveryStateStore) AdvanceWatermark(ctx context.Context, consumerGroup, topic, partitionKey string, currentWatermark int64, offsets []int64) (int64, error)

AdvanceWatermark mocks base method.

func (*MockdeliveryStateStore) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockdeliveryStateStore) ExtendVisibility

func (m *MockdeliveryStateStore) ExtendVisibility(ctx context.Context, consumerGroup, topic, partitionKey string, offset, visibilityTimeoutMs int64) error

ExtendVisibility mocks base method.

func (*MockdeliveryStateStore) GetDeliveryState

func (m *MockdeliveryStateStore) GetDeliveryState(ctx context.Context, consumerGroup, topic, partitionKey string, offset int64) (DeliveryState, bool, error)

GetDeliveryState mocks base method.

func (*MockdeliveryStateStore) MarkAcked

func (m *MockdeliveryStateStore) MarkAcked(ctx context.Context, consumerGroup, topic, partitionKey string, offset int64) error

MarkAcked mocks base method.

func (*MockdeliveryStateStore) MarkDelivered

func (m *MockdeliveryStateStore) MarkDelivered(ctx context.Context, consumerGroup, topic, partitionKey string, offset, visibilityTimeoutMs int64) (int, error)

MarkDelivered mocks base method.

func (*MockdeliveryStateStore) MarkNacked

func (m *MockdeliveryStateStore) MarkNacked(ctx context.Context, consumerGroup, topic, partitionKey string, offset, delayMs int64) error

MarkNacked mocks base method.

type MockdeliveryStateStoreMockRecorder

type MockdeliveryStateStoreMockRecorder struct {
	// contains filtered or unexported fields
}

MockdeliveryStateStoreMockRecorder is the mock recorder for MockdeliveryStateStore.

func (*MockdeliveryStateStoreMockRecorder) AdvanceWatermark

func (mr *MockdeliveryStateStoreMockRecorder) AdvanceWatermark(ctx, consumerGroup, topic, partitionKey, currentWatermark, offsets any) *gomock.Call

AdvanceWatermark indicates an expected call of AdvanceWatermark.

func (*MockdeliveryStateStoreMockRecorder) ExtendVisibility

func (mr *MockdeliveryStateStoreMockRecorder) ExtendVisibility(ctx, consumerGroup, topic, partitionKey, offset, visibilityTimeoutMs any) *gomock.Call

ExtendVisibility indicates an expected call of ExtendVisibility.

func (*MockdeliveryStateStoreMockRecorder) GetDeliveryState

func (mr *MockdeliveryStateStoreMockRecorder) GetDeliveryState(ctx, consumerGroup, topic, partitionKey, offset any) *gomock.Call

GetDeliveryState indicates an expected call of GetDeliveryState.

func (*MockdeliveryStateStoreMockRecorder) MarkAcked

func (mr *MockdeliveryStateStoreMockRecorder) MarkAcked(ctx, consumerGroup, topic, partitionKey, offset any) *gomock.Call

MarkAcked indicates an expected call of MarkAcked.

func (*MockdeliveryStateStoreMockRecorder) MarkDelivered

func (mr *MockdeliveryStateStoreMockRecorder) MarkDelivered(ctx, consumerGroup, topic, partitionKey, offset, visibilityTimeoutMs any) *gomock.Call

MarkDelivered indicates an expected call of MarkDelivered.

func (*MockdeliveryStateStoreMockRecorder) MarkNacked

func (mr *MockdeliveryStateStoreMockRecorder) MarkNacked(ctx, consumerGroup, topic, partitionKey, offset, delayMs any) *gomock.Call

MarkNacked indicates an expected call of MarkNacked.

type MockmessageStore

type MockmessageStore struct {
	// contains filtered or unexported fields
}

MockmessageStore is a mock of messageStore interface.

func NewMockmessageStore

func NewMockmessageStore(ctrl *gomock.Controller) *MockmessageStore

NewMockmessageStore creates a new mock instance.

func (*MockmessageStore) Delete

func (m *MockmessageStore) Delete(ctx context.Context, topic, partitionKey, messageID string) error

Delete mocks base method.

func (*MockmessageStore) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockmessageStore) FetchByOffset

func (m *MockmessageStore) FetchByOffset(ctx context.Context, topic, partitionKey string, currentOffset, nowMs int64, limit int) ([]messageRow, error)

FetchByOffset mocks base method.

func (*MockmessageStore) GarbageCollect

func (m *MockmessageStore) GarbageCollect(ctx context.Context, topic, partitionKey string, minAckedOffset int64) (int64, error)

GarbageCollect mocks base method.

func (*MockmessageStore) GetOffsetsAbove

func (m *MockmessageStore) GetOffsetsAbove(ctx context.Context, topic, partitionKey string, afterOffset int64, limit int) ([]int64, error)

GetOffsetsAbove mocks base method.

func (*MockmessageStore) Insert

func (m *MockmessageStore) Insert(ctx context.Context, topic string, messages []messagequeue.Message) error

Insert mocks base method.

func (*MockmessageStore) InsertDelayed

func (m *MockmessageStore) InsertDelayed(ctx context.Context, topic string, messages []messagequeue.Message, visibleAfterMs int64) error

InsertDelayed mocks base method.

func (*MockmessageStore) MoveToDLQ

func (m *MockmessageStore) MoveToDLQ(ctx context.Context, topic, partitionKey, messageID string, failureCount int, lastError, dlqTopicSuffix string) error

MoveToDLQ mocks base method.

type MockmessageStoreMockRecorder

type MockmessageStoreMockRecorder struct {
	// contains filtered or unexported fields
}

MockmessageStoreMockRecorder is the mock recorder for MockmessageStore.

func (*MockmessageStoreMockRecorder) Delete

func (mr *MockmessageStoreMockRecorder) Delete(ctx, topic, partitionKey, messageID any) *gomock.Call

Delete indicates an expected call of Delete.

func (*MockmessageStoreMockRecorder) FetchByOffset

func (mr *MockmessageStoreMockRecorder) FetchByOffset(ctx, topic, partitionKey, currentOffset, nowMs, limit any) *gomock.Call

FetchByOffset indicates an expected call of FetchByOffset.

func (*MockmessageStoreMockRecorder) GarbageCollect

func (mr *MockmessageStoreMockRecorder) GarbageCollect(ctx, topic, partitionKey, minAckedOffset any) *gomock.Call

GarbageCollect indicates an expected call of GarbageCollect.

func (*MockmessageStoreMockRecorder) GetOffsetsAbove

func (mr *MockmessageStoreMockRecorder) GetOffsetsAbove(ctx, topic, partitionKey, afterOffset, limit any) *gomock.Call

GetOffsetsAbove indicates an expected call of GetOffsetsAbove.

func (*MockmessageStoreMockRecorder) Insert

func (mr *MockmessageStoreMockRecorder) Insert(ctx, topic, messages any) *gomock.Call

Insert indicates an expected call of Insert.

func (*MockmessageStoreMockRecorder) InsertDelayed

func (mr *MockmessageStoreMockRecorder) InsertDelayed(ctx, topic, messages, visibleAfterMs any) *gomock.Call

InsertDelayed indicates an expected call of InsertDelayed.

func (*MockmessageStoreMockRecorder) MoveToDLQ

func (mr *MockmessageStoreMockRecorder) MoveToDLQ(ctx, topic, partitionKey, messageID, failureCount, lastError, dlqTopicSuffix any) *gomock.Call

MoveToDLQ indicates an expected call of MoveToDLQ.

type MockoffsetStore

type MockoffsetStore struct {
	// contains filtered or unexported fields
}

MockoffsetStore is a mock of offsetStore interface.

func NewMockoffsetStore

func NewMockoffsetStore(ctrl *gomock.Controller) *MockoffsetStore

NewMockoffsetStore creates a new mock instance.

func (*MockoffsetStore) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockoffsetStore) GetAckedOffset

func (m *MockoffsetStore) GetAckedOffset(ctx context.Context, topic, partitionKey, consumerGroup string) (int64, error)

GetAckedOffset mocks base method.

func (*MockoffsetStore) GetMinAckedOffset

func (m *MockoffsetStore) GetMinAckedOffset(ctx context.Context, topic, partitionKey string) (int64, bool, error)

GetMinAckedOffset mocks base method.

func (*MockoffsetStore) Initialize

func (m *MockoffsetStore) Initialize(ctx context.Context, topic, partitionKey, consumerGroup string) error

Initialize mocks base method.

func (*MockoffsetStore) UpdateAckedOffset

func (m *MockoffsetStore) UpdateAckedOffset(ctx context.Context, topic, partitionKey string, offset int64, consumerGroup string) error

UpdateAckedOffset mocks base method.

type MockoffsetStoreMockRecorder

type MockoffsetStoreMockRecorder struct {
	// contains filtered or unexported fields
}

MockoffsetStoreMockRecorder is the mock recorder for MockoffsetStore.

func (*MockoffsetStoreMockRecorder) GetAckedOffset

func (mr *MockoffsetStoreMockRecorder) GetAckedOffset(ctx, topic, partitionKey, consumerGroup any) *gomock.Call

GetAckedOffset indicates an expected call of GetAckedOffset.

func (*MockoffsetStoreMockRecorder) GetMinAckedOffset

func (mr *MockoffsetStoreMockRecorder) GetMinAckedOffset(ctx, topic, partitionKey any) *gomock.Call

GetMinAckedOffset indicates an expected call of GetMinAckedOffset.

func (*MockoffsetStoreMockRecorder) Initialize

func (mr *MockoffsetStoreMockRecorder) Initialize(ctx, topic, partitionKey, consumerGroup any) *gomock.Call

Initialize indicates an expected call of Initialize.

func (*MockoffsetStoreMockRecorder) UpdateAckedOffset

func (mr *MockoffsetStoreMockRecorder) UpdateAckedOffset(ctx, topic, partitionKey, offset, consumerGroup any) *gomock.Call

UpdateAckedOffset indicates an expected call of UpdateAckedOffset.

type MockpartitionLeaseStore

type MockpartitionLeaseStore struct {
	// contains filtered or unexported fields
}

MockpartitionLeaseStore is a mock of partitionLeaseStore interface.

func NewMockpartitionLeaseStore

func NewMockpartitionLeaseStore(ctrl *gomock.Controller) *MockpartitionLeaseStore

NewMockpartitionLeaseStore creates a new mock instance.

func (*MockpartitionLeaseStore) DiscoverAndAcquirePartitions

func (m *MockpartitionLeaseStore) DiscoverAndAcquirePartitions(ctx context.Context, topic, subscriberName, consumerGroup string, leaseDurationMs int64, maxPartitions int) (int, []string, error)

DiscoverAndAcquirePartitions mocks base method.

func (*MockpartitionLeaseStore) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockpartitionLeaseStore) GetLeasedPartitions

func (m *MockpartitionLeaseStore) GetLeasedPartitions(ctx context.Context, topic, subscriberName, consumerGroup string) ([]string, error)

GetLeasedPartitions mocks base method.

func (*MockpartitionLeaseStore) ReleaseLease

func (m *MockpartitionLeaseStore) ReleaseLease(ctx context.Context, topic, partitionKey, subscriberName, consumerGroup string) error

ReleaseLease mocks base method.

func (*MockpartitionLeaseStore) RenewLease

func (m *MockpartitionLeaseStore) RenewLease(ctx context.Context, topic, partitionKey, subscriberName, consumerGroup string, leaseDurationMs int64) error

RenewLease mocks base method.

func (*MockpartitionLeaseStore) TryAcquireLease

func (m *MockpartitionLeaseStore) TryAcquireLease(ctx context.Context, topic, partitionKey, subscriberName, consumerGroup string, leaseDurationMs int64) (bool, error)

TryAcquireLease mocks base method.

type MockpartitionLeaseStoreMockRecorder

type MockpartitionLeaseStoreMockRecorder struct {
	// contains filtered or unexported fields
}

MockpartitionLeaseStoreMockRecorder is the mock recorder for MockpartitionLeaseStore.

func (*MockpartitionLeaseStoreMockRecorder) DiscoverAndAcquirePartitions

func (mr *MockpartitionLeaseStoreMockRecorder) DiscoverAndAcquirePartitions(ctx, topic, subscriberName, consumerGroup, leaseDurationMs, maxPartitions any) *gomock.Call

DiscoverAndAcquirePartitions indicates an expected call of DiscoverAndAcquirePartitions.

func (*MockpartitionLeaseStoreMockRecorder) GetLeasedPartitions

func (mr *MockpartitionLeaseStoreMockRecorder) GetLeasedPartitions(ctx, topic, subscriberName, consumerGroup any) *gomock.Call

GetLeasedPartitions indicates an expected call of GetLeasedPartitions.

func (*MockpartitionLeaseStoreMockRecorder) ReleaseLease

func (mr *MockpartitionLeaseStoreMockRecorder) ReleaseLease(ctx, topic, partitionKey, subscriberName, consumerGroup any) *gomock.Call

ReleaseLease indicates an expected call of ReleaseLease.

func (*MockpartitionLeaseStoreMockRecorder) RenewLease

func (mr *MockpartitionLeaseStoreMockRecorder) RenewLease(ctx, topic, partitionKey, subscriberName, consumerGroup, leaseDurationMs any) *gomock.Call

RenewLease indicates an expected call of RenewLease.

func (*MockpartitionLeaseStoreMockRecorder) TryAcquireLease

func (mr *MockpartitionLeaseStoreMockRecorder) TryAcquireLease(ctx, topic, partitionKey, subscriberName, consumerGroup, leaseDurationMs any) *gomock.Call

TryAcquireLease indicates an expected call of TryAcquireLease.

type MocksubscriberHeartbeatStore

type MocksubscriberHeartbeatStore struct {
	// contains filtered or unexported fields
}

MocksubscriberHeartbeatStore is a mock of subscriberHeartbeatStore interface.

func NewMocksubscriberHeartbeatStore

func NewMocksubscriberHeartbeatStore(ctrl *gomock.Controller) *MocksubscriberHeartbeatStore

NewMocksubscriberHeartbeatStore creates a new mock instance.

func (*MocksubscriberHeartbeatStore) ActiveSubscribers

func (m *MocksubscriberHeartbeatStore) ActiveSubscribers(ctx context.Context, topic, consumerGroup string, staleDurationMs int64) ([]string, error)

ActiveSubscribers mocks base method.

func (*MocksubscriberHeartbeatStore) Deregister

func (m *MocksubscriberHeartbeatStore) Deregister(ctx context.Context, topic, subscriberName, consumerGroup string) error

Deregister mocks base method.

func (*MocksubscriberHeartbeatStore) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MocksubscriberHeartbeatStore) Heartbeat

func (m *MocksubscriberHeartbeatStore) Heartbeat(ctx context.Context, topic, subscriberName, consumerGroup string) error

Heartbeat mocks base method.

type MocksubscriberHeartbeatStoreMockRecorder

type MocksubscriberHeartbeatStoreMockRecorder struct {
	// contains filtered or unexported fields
}

MocksubscriberHeartbeatStoreMockRecorder is the mock recorder for MocksubscriberHeartbeatStore.

func (*MocksubscriberHeartbeatStoreMockRecorder) ActiveSubscribers

func (mr *MocksubscriberHeartbeatStoreMockRecorder) ActiveSubscribers(ctx, topic, consumerGroup, staleDurationMs any) *gomock.Call

ActiveSubscribers indicates an expected call of ActiveSubscribers.

func (*MocksubscriberHeartbeatStoreMockRecorder) Deregister

func (mr *MocksubscriberHeartbeatStoreMockRecorder) Deregister(ctx, topic, subscriberName, consumerGroup any) *gomock.Call

Deregister indicates an expected call of Deregister.

func (*MocksubscriberHeartbeatStoreMockRecorder) Heartbeat

func (mr *MocksubscriberHeartbeatStoreMockRecorder) Heartbeat(ctx, topic, subscriberName, consumerGroup any) *gomock.Call

Heartbeat indicates an expected call of Heartbeat.

type Params

type Params struct {
	// DB is the database connection (required)
	DB *sql.DB

	// Logger for debugging and observability (required)
	Logger *zap.Logger

	// MetricsScope for metrics collection (required)
	MetricsScope tally.Scope

	// OnSignal receives typed subscriber lifecycle signals (HookSignal).
	// Nil in production; used by integration tests for event-driven waits.
	OnSignal chan HookSignal
}

Params holds dependencies for creating a SQL queue

Directories

Path Synopsis
ctl
lib

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL