pubsub

package
v0.0.0-...-c8d90df Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package pubsub contains utilities for working with Cloud PubSub.

Index

Constants

View Source
const ScopePubSub = pubsub.ScopePubSub

ScopePubSub aliases the same constant from the pubsub package to prevent callers from needing to import both packages.

Variables

This section is empty.

Functions

func EnsureNotEmulator

func EnsureNotEmulator()

EnsureNotEmulator panics if the PubSub emulator environment variable is set.

Types

type Client

type Client interface {
	Close() error
	CreateSubscription(ctx context.Context, id string, cfg pubsub.SubscriptionConfig) (Subscription, error)
	CreateTopic(ctx context.Context, topicID string) (Topic, error)
	CreateTopicWithConfig(ctx context.Context, topicID string, tc *pubsub.TopicConfig) (Topic, error)
	DetachSubscription(ctx context.Context, sub string) (*pubsub.DetachSubscriptionResult, error)
	Project() string

	Snapshot(id string) Snapshot
	Snapshots(ctx context.Context) *pubsub.SnapshotConfigIterator

	Subscription(id string) Subscription
	SubscriptionInProject(id, projectID string) Subscription
	Subscriptions(ctx context.Context) *pubsub.SubscriptionIterator

	Topic(id string) Topic
	TopicInProject(id, projectID string) Topic
	Topics(ctx context.Context) *pubsub.TopicIterator
}

Client represents a pubsub.Client in an interface which can be mocked for testing.

type PublishResult

type PublishResult interface {
	Get(ctx context.Context) (serverID string, err error)
	Ready() <-chan struct{}
}

PublishResult represents a pubsub.PublishResult in an interface which can be mocked for testing.

type Snapshot

type Snapshot interface {
	Delete(ctx context.Context) error
	ID() string
	SetLabels(ctx context.Context, label map[string]string) (*pubsub.SnapshotConfig, error)
}

Snapshot represents a pubsub.Snapshot in an interface which can be mocked for testing.

type Subscription

type Subscription interface {
	Config(ctx context.Context) (pubsub.SubscriptionConfig, error)
	CreateSnapshot(ctx context.Context, name string) (*pubsub.SnapshotConfig, error)
	Delete(ctx context.Context) error
	Exists(ctx context.Context) (bool, error)
	IAM() *iam.Handle
	ID() string
	Receive(ctx context.Context, f func(context.Context, *pubsub.Message)) error
	SeekToSnapshot(ctx context.Context, snap Snapshot) error
	SeekToTime(ctx context.Context, t time.Time) error
	String() string
	Update(ctx context.Context, cfg pubsub.SubscriptionConfigToUpdate) (pubsub.SubscriptionConfig, error)
}

Subscription represents a pubsub.Subscription in an interface which can be mocked for testing.

type Topic

type Topic interface {
	Config(ctx context.Context) (pubsub.TopicConfig, error)
	Delete(ctx context.Context) error
	Exists(ctx context.Context) (bool, error)
	Flush()
	IAM() *iam.Handle
	ID() string
	Publish(ctx context.Context, msg *pubsub.Message) PublishResult
	ResumePublish(orderingKey string)
	Stop()
	String() string
	Subscriptions(ctx context.Context) *pubsub.SubscriptionIterator
	Update(ctx context.Context, cfg pubsub.TopicConfigToUpdate) (pubsub.TopicConfig, error)
}

Topic represents a pubsub.Topic in an interface which can be mocked for testing.

type WrappedClient

type WrappedClient struct {
	*pubsub.Client
}

WrappedClient implements Client by wrapping a pubsub.Client.

func NewClient

func NewClient(ctx context.Context, projectID string, opts ...option.ClientOption) (*WrappedClient, error)

NewClient creates a new WrappedClient.

func NewClientWithConfig

func NewClientWithConfig(ctx context.Context, projectID string, config *pubsub.ClientConfig, opts ...option.ClientOption) (*WrappedClient, error)

NewClientWithConfig creates a new WrappedClient with the given config..

func (*WrappedClient) CreateSubscription

func (w *WrappedClient) CreateSubscription(ctx context.Context, id string, cfg pubsub.SubscriptionConfig) (Subscription, error)

CreateSubscription implements Client.

func (*WrappedClient) CreateTopic

func (w *WrappedClient) CreateTopic(ctx context.Context, topicID string) (Topic, error)

CreateTopic implements Client.

func (*WrappedClient) CreateTopicWithConfig

func (w *WrappedClient) CreateTopicWithConfig(ctx context.Context, topicID string, tc *pubsub.TopicConfig) (Topic, error)

CreateTopicWithConfig implements Client.

func (*WrappedClient) Snapshot

func (w *WrappedClient) Snapshot(id string) Snapshot

Snapshot implements Client.

func (*WrappedClient) Subscription

func (w *WrappedClient) Subscription(id string) Subscription

Subscription implements Client.

func (*WrappedClient) SubscriptionInProject

func (w *WrappedClient) SubscriptionInProject(id, projectID string) Subscription

SubscriptionInProject implements Client.

func (*WrappedClient) Topic

func (w *WrappedClient) Topic(id string) Topic

Topic implements Client.

func (*WrappedClient) TopicInProject

func (w *WrappedClient) TopicInProject(id, projectID string) Topic

TopicInProject implements Client.

type WrappedSubscription

type WrappedSubscription struct {
	*pubsub.Subscription
}

WrappedSubscription implements Subscription by wrapping a pubsub.Subscription.

func (*WrappedSubscription) SeekToSnapshot

func (w *WrappedSubscription) SeekToSnapshot(ctx context.Context, snap Snapshot) error

SeekToSnapshot implements Client.

type WrappedTopic

type WrappedTopic struct {
	*pubsub.Topic
}

WrappedTopic implements Topic by wrapping a pubsub.Topic.

func (*WrappedTopic) Publish

func (w *WrappedTopic) Publish(ctx context.Context, msg *pubsub.Message) PublishResult

Publish implements Client.

Directories

Path Synopsis
Package sub creates PubSub subscriptions.
Package sub creates PubSub subscriptions.

Jump to

Keyboard shortcuts

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