pubsublite

package module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2020 License: Apache-2.0 Imports: 12 Imported by: 4

README

Cloud Pub/Sub Lite GoDoc

This library is under development and will not provide a delightful user experience until v1.0.0 has been released.

Documentation

Overview

Package pubsublite provides an interface for publishing and receiving messages using Google Pub/Sub Lite.

More information about Google Pub/Sub Lite is available at https://cloud.google.com/pubsub/lite.

This library is under development and will not provdie a delightful user experience until v1.0.0 has been released.

Index

Constants

View Source
const (
	// UnspecifiedDeliveryRequirement represents and unset delivery requirement.
	UnspecifiedDeliveryRequirement = DeliveryRequirement(pb.Subscription_DeliveryConfig_DELIVERY_REQUIREMENT_UNSPECIFIED)

	// DeliverImmediately means the server will not not wait for a published
	// message to be successfully written to storage before delivering it to
	// subscribers.
	DeliverImmediately = DeliveryRequirement(pb.Subscription_DeliveryConfig_DELIVER_IMMEDIATELY)

	// DeliverAfterStored means the server will not deliver a published message to
	// subscribers until the message has been successfully written to storage.
	// This will result in higher end-to-end latency, but consistent delivery.
	DeliverAfterStored = DeliveryRequirement(pb.Subscription_DeliveryConfig_DELIVER_AFTER_STORED)
)
View Source
const InfiniteRetention = time.Duration(-1)

InfiniteRetention is a sentinel used in topic configs to denote an infinite retention duration (i.e. retain messages as long as there is available storage).

Variables

This section is empty.

Functions

func ZoneToRegion

func ZoneToRegion(zone string) (string, error)

ZoneToRegion returns the region that the given zone is in.

Types

type AdminClient

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

AdminClient provides admin operations for Cloud Pub/Sub Lite resources within a Google Cloud region. An AdminClient may be shared by multiple goroutines.

func NewAdminClient

func NewAdminClient(ctx context.Context, region string, opts ...option.ClientOption) (*AdminClient, error)

NewAdminClient creates a new Cloud Pub/Sub Lite client to perform admin operations for resources within a given region. See https://cloud.google.com/pubsub/lite/docs/locations for the list of regions and zones where Cloud Pub/Sub Lite is available.

func (*AdminClient) Close

func (ac *AdminClient) Close() error

Close releases any resources held by the client when it is no longer required. If the client is available for the lifetime of the program, then Close need not be called at exit.

func (*AdminClient) CreateSubscription

func (ac *AdminClient) CreateSubscription(ctx context.Context, config SubscriptionConfig) (*SubscriptionConfig, error)

CreateSubscription creates a new subscription from the given config.

func (*AdminClient) CreateTopic

func (ac *AdminClient) CreateTopic(ctx context.Context, config TopicConfig) (*TopicConfig, error)

CreateTopic creates a new topic from the given config.

func (*AdminClient) DeleteSubscription

func (ac *AdminClient) DeleteSubscription(ctx context.Context, subscription SubscriptionPath) error

DeleteSubscription deletes a subscription.

func (*AdminClient) DeleteTopic

func (ac *AdminClient) DeleteTopic(ctx context.Context, topic TopicPath) error

DeleteTopic deletes a topic.

func (*AdminClient) Subscription

func (ac *AdminClient) Subscription(ctx context.Context, subscription SubscriptionPath) (*SubscriptionConfig, error)

Subscription retrieves the configuration of a subscription.

func (*AdminClient) Subscriptions

func (ac *AdminClient) Subscriptions(ctx context.Context, location LocationPath) *SubscriptionIterator

Subscriptions retrieves the list of subscription configs for a given project and zone.

func (*AdminClient) Topic

func (ac *AdminClient) Topic(ctx context.Context, topic TopicPath) (*TopicConfig, error)

Topic retrieves the configuration of a topic.

func (*AdminClient) TopicPartitions

func (ac *AdminClient) TopicPartitions(ctx context.Context, topic TopicPath) (int, error)

TopicPartitions returns the number of partitions for a topic.

func (*AdminClient) TopicSubscriptions

func (ac *AdminClient) TopicSubscriptions(ctx context.Context, topic TopicPath) *SubscriptionPathIterator

TopicSubscriptions retrieves the list of subscription paths for a topic.

func (*AdminClient) Topics

func (ac *AdminClient) Topics(ctx context.Context, location LocationPath) *TopicIterator

Topics retrieves the list of topic configs for a given project and zone.

func (*AdminClient) UpdateSubscription

func (ac *AdminClient) UpdateSubscription(ctx context.Context, config SubscriptionConfigToUpdate) (*SubscriptionConfig, error)

UpdateSubscription updates an existing subscription from the given config and returns the new subscription config.

func (*AdminClient) UpdateTopic

func (ac *AdminClient) UpdateTopic(ctx context.Context, config TopicConfigToUpdate) (*TopicConfig, error)

UpdateTopic updates an existing topic from the given config and returns the new topic config.

type DeliveryRequirement

type DeliveryRequirement int32

DeliveryRequirement specifies when a subscription should send messages to subscribers relative to persistence in storage.

type LocationPath

type LocationPath struct {
	// A Google Cloud project. The project ID (e.g. "my-project") or the project
	// number (e.g. "987654321") can be provided.
	Project string

	// A Google Cloud zone, for example "us-central1-a".
	// See https://cloud.google.com/pubsub/lite/docs/locations for the list of
	// zones where Cloud Pub/Sub Lite is available.
	Zone string
}

LocationPath stores a path consisting of a project and zone.

func (LocationPath) String

func (l LocationPath) String() string

type SubscriptionConfig

type SubscriptionConfig struct {
	// The full path of a subscription.
	Name SubscriptionPath

	// The name of the topic this subscription is attached to. This cannot be
	// changed after creation.
	Topic TopicPath

	// Whether a message should be delivered to subscribers immediately after it
	// has been published or after it has been successfully written to storage.
	DeliveryRequirement DeliveryRequirement
}

SubscriptionConfig describes the properties of a Google Pub/Sub Lite subscription, which is attached to a topic. See https://cloud.google.com/pubsub/lite/docs/subscriptions for more information about how subscriptions are configured.

type SubscriptionConfigToUpdate

type SubscriptionConfigToUpdate struct {
	// The full path of the subscription to update. Required.
	Name SubscriptionPath

	// If non-zero, updates the message delivery requirement.
	DeliveryRequirement DeliveryRequirement
}

SubscriptionConfigToUpdate specifies the properties to update for a subscription.

type SubscriptionIterator

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

SubscriptionIterator is an iterator that returns a list of subscription configs.

func (*SubscriptionIterator) Next

Next returns the next subscription config. The second return value will be iterator.Done if there are no more subscription configs.

type SubscriptionPath

type SubscriptionPath struct {
	// A Google Cloud project. The project ID (e.g. "my-project") or the project
	// number (e.g. "987654321") can be provided.
	Project string

	// A Google Cloud zone. An example zone is "us-central1-a".
	// See https://cloud.google.com/pubsub/lite/docs/locations for the list of
	// zones where Cloud Pub/Sub Lite is available.
	Zone string

	// The ID of the Cloud Pub/Sub Lite subscription, for example
	// "my-subscription-name".
	// See https://cloud.google.com/pubsub/docs/admin#resource_names for more
	// information.
	SubscriptionID string
}

SubscriptionPath stores the full path of a Cloud Pub/Sub Lite subscription. See https://cloud.google.com/pubsub/lite/docs/subscriptions for more information.

func (SubscriptionPath) String

func (s SubscriptionPath) String() string

type SubscriptionPathIterator

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

SubscriptionPathIterator is an iterator that returns a list of subscription paths.

func (*SubscriptionPathIterator) Next

Next returns the next subscription path. The second return value will be iterator.Done if there are no more subscription paths.

type TopicConfig

type TopicConfig struct {
	// The full path of a topic.
	Name TopicPath

	// The number of partitions in the topic. Must be at least 1. Cannot be
	// changed after creation.
	PartitionCount int

	// Publish throughput capacity per partition in MiB/s.
	// Must be >= 4 and <= 16.
	PublishCapacityMiBPerSec int

	// Subscribe throughput capacity per partition in MiB/s.
	// Must be >= 4 and <= 32.
	SubscribeCapacityMiBPerSec int

	// The provisioned storage, in bytes, per partition. If the number of bytes
	// stored in any of the topic's partitions grows beyond this value, older
	// messages will be dropped to make room for newer ones, regardless of the
	// value of `RetentionDuration`. Must be > 0.
	PerPartitionBytes int64

	// How long a published message is retained. If set to `InfiniteRetention`,
	// messages will be retained as long as the bytes retained for each partition
	// is below `PerPartitionBytes`. Otherwise, must be > 0.
	RetentionDuration time.Duration
}

TopicConfig describes the properties of a Google Pub/Sub Lite topic. See https://cloud.google.com/pubsub/lite/docs/topics for more information about how topics are configured.

type TopicConfigToUpdate

type TopicConfigToUpdate struct {
	// The full path of the topic to update. Required.
	Name TopicPath

	// If non-zero, will update the publish throughput capacity per partition.
	PublishCapacityMiBPerSec int

	// If non-zero, will update the subscribe throughput capacity per partition.
	SubscribeCapacityMiBPerSec int

	// If non-zero, will update the provisioned storage per partition.
	PerPartitionBytes int64

	// If specified, will update how long a published message is retained. To
	// clear a retention duration (i.e. retain messages as long as there is
	// available storage), set this to `InfiniteRetention`.
	RetentionDuration optional.Duration
}

TopicConfigToUpdate specifies the properties to update for a topic.

type TopicIterator

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

TopicIterator is an iterator that returns a list of topic configs.

func (*TopicIterator) Next

func (t *TopicIterator) Next() (*TopicConfig, error)

Next returns the next topic config. The second return value will be iterator.Done if there are no more topic configs.

type TopicPath

type TopicPath struct {
	// A Google Cloud project. The project ID (e.g. "my-project") or the project
	// number (e.g. "987654321") can be provided.
	Project string

	// A Google Cloud zone, for example "us-central1-a".
	// See https://cloud.google.com/pubsub/lite/docs/locations for the list of
	// zones where Cloud Pub/Sub Lite is available.
	Zone string

	// The ID of the Cloud Pub/Sub Lite topic, for example "my-topic-name".
	// See https://cloud.google.com/pubsub/docs/admin#resource_names for more
	// information.
	TopicID string
}

TopicPath stores the full path of a Cloud Pub/Sub Lite topic. See https://cloud.google.com/pubsub/lite/docs/topics for more information.

func (TopicPath) String

func (t TopicPath) String() string

Directories

Path Synopsis
Use of Context The ctx passed to NewClient is used for authentication requests and for creating the underlying connection, but is not used for subsequent calls.
Use of Context The ctx passed to NewClient is used for authentication requests and for creating the underlying connection, but is not used for subsequent calls.
internal

Jump to

Keyboard shortcuts

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