pubsub

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package pubsub provides an in-memory mock implementation of GCP Pub/Sub.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FunctionTrigger

type FunctionTrigger func(queueURL string, message driver.Message)

FunctionTrigger is a function that gets called when a message is published to a topic.

type Mock

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

Mock is an in-memory mock implementation of the GCP Pub/Sub service.

func New

func New(opts *config.Options) *Mock

New creates a new Pub/Sub mock with the given configuration options.

func (*Mock) ChangeVisibility

func (m *Mock) ChangeVisibility(_ context.Context, queueURL, receiptHandle string, timeout int) error

ChangeVisibility modifies the ack deadline (visibility timeout) of a message in the subscription.

func (*Mock) CreateQueue

func (m *Mock) CreateQueue(_ context.Context, cfg driver.QueueConfig) (*driver.QueueInfo, error)

CreateQueue creates a new Pub/Sub topic and subscription pair.

func (*Mock) DeleteMessage

func (m *Mock) DeleteMessage(ctx context.Context, queueURL, receiptHandle string) error

DeleteMessage acknowledges and removes a message from the subscription using its ack ID (receipt handle).

func (*Mock) DeleteMessageBatch added in v1.2.0

func (m *Mock) DeleteMessageBatch(
	ctx context.Context, queue string, entries []driver.BatchDeleteEntry,
) (*driver.BatchDeleteResult, error)

DeleteMessageBatch deletes up to 10 messages from the specified Pub/Sub subscription.

func (*Mock) DeleteQueue

func (m *Mock) DeleteQueue(_ context.Context, url string) error

DeleteQueue deletes a Pub/Sub topic and subscription pair by URL.

func (*Mock) GetQueueAttributes added in v1.2.0

func (m *Mock) GetQueueAttributes(
	_ context.Context, queue string,
) (*driver.QueueAttributes, error)

GetQueueAttributes returns detailed attributes of the specified topic/subscription.

func (*Mock) GetQueueInfo

func (m *Mock) GetQueueInfo(_ context.Context, url string) (*driver.QueueInfo, error)

GetQueueInfo retrieves information about a Pub/Sub topic/subscription by URL.

func (*Mock) ListQueues

func (m *Mock) ListQueues(_ context.Context, prefix string) ([]driver.QueueInfo, error)

ListQueues returns all topics whose names match the given prefix. If prefix is empty, all topics are returned.

func (*Mock) PurgeQueue added in v1.2.0

func (m *Mock) PurgeQueue(_ context.Context, queue string) error

PurgeQueue removes all messages from the specified topic/subscription.

func (*Mock) ReceiveMessages

func (m *Mock) ReceiveMessages(ctx context.Context, input driver.ReceiveMessageInput) ([]driver.Message, error)

ReceiveMessages pulls messages from the specified Pub/Sub subscription. Returns messages where VisibleAt <= now, and sets a new VisibleAt based on the ack deadline (visibility timeout).

func (*Mock) ReceiveMessagesWithOptions added in v1.2.0

func (m *Mock) ReceiveMessagesWithOptions(
	_ context.Context, queue string, opts driver.ReceiveOptions,
) ([]driver.Message, error)

ReceiveMessagesWithOptions pulls messages with configurable options.

func (*Mock) RemoveTrigger

func (m *Mock) RemoveTrigger(queueURL string)

RemoveTrigger removes a Cloud Function trigger from a subscription.

func (*Mock) SendMessage

func (m *Mock) SendMessage(ctx context.Context, input driver.SendMessageInput) (*driver.SendMessageOutput, error)

SendMessage publishes a message to the specified Pub/Sub topic.

func (*Mock) SendMessageBatch added in v1.2.0

func (m *Mock) SendMessageBatch(
	ctx context.Context, queue string, entries []driver.BatchSendEntry,
) (*driver.BatchSendResult, error)

SendMessageBatch publishes up to 10 messages to the specified Pub/Sub topic.

func (*Mock) SetMonitoring added in v1.2.0

func (m *Mock) SetMonitoring(mon mondriver.Monitoring)

SetMonitoring sets the monitoring backend for auto-metric generation.

func (*Mock) SetQueueAttributes added in v1.2.0

func (m *Mock) SetQueueAttributes(
	_ context.Context, queue string, attrs map[string]int,
) error

SetQueueAttributes updates the attributes of the specified topic/subscription.

func (*Mock) SetTrigger

func (m *Mock) SetTrigger(queueURL string, fn FunctionTrigger)

SetTrigger registers a Cloud Function trigger for a subscription.

Jump to

Keyboard shortcuts

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