wire

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2020 License: Apache-2.0 Imports: 23 Imported by: 0

README

Wire

This directory contains internal implementation details for Cloud Pub/Sub Lite. Its exported interface can change at any time.

Conventions

The following are general conventions used in this package:

  • Capitalized methods and fields of a struct denotes its public interface. They are safe to call from outside the struct (e.g. accesses immutable fields or guarded by a mutex). All other methods are considered internal implementation details that should not be called from outside the struct.
  • unsafeFoo() methods indicate that the caller is expected to have already acquired the struct's mutex. Since Go does not support re-entrant locks, they do not acquire the mutex. These are typically common util methods that need to be atomic with other operations.

Documentation

Index

Constants

View Source
const (
	// MaxPublishRequestCount is the maximum number of messages that can be
	// batched in a single publish request.
	MaxPublishRequestCount = 1000

	// MaxPublishMessageBytes is the maximum allowed serialized size of a single
	// Pub/Sub message in bytes.
	MaxPublishMessageBytes = 1000000

	// MaxPublishRequestBytes is the maximum allowed serialized size of a single
	// publish request (containing a batch of messages) in bytes.
	MaxPublishRequestBytes = 3500000
)

Variables

View Source
var DefaultPublishSettings = PublishSettings{
	DelayThreshold: 10 * time.Millisecond,
	CountThreshold: 100,
	ByteThreshold:  1e6,
	Timeout:        60 * time.Second,

	BufferedByteLimit: 1 << 30,
}

DefaultPublishSettings holds the default values for PublishSettings.

View Source
var (
	// ErrOverflow indicates that the publish buffers have overflowed. See
	// comments for PublishSettings.BufferedByteLimit.
	ErrOverflow = errors.New("pubsublite: client-side publish buffers have overflowed")
)

Functions

func NewAdminClient

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

NewAdminClient creates a new gapic AdminClient for a region.

func ValidateRegion

func ValidateRegion(input string) error

ValidateRegion verifies that the `input` string has the format of a valid Google Cloud region. An example region is "europe-west1". See https://cloud.google.com/compute/docs/regions-zones for more information.

func ValidateZone

func ValidateZone(input string) error

ValidateZone verifies that the `input` string has the format of a valid Google Cloud zone. An example zone is "europe-west1-b". See https://cloud.google.com/compute/docs/regions-zones for more information.

Types

type AckConsumer

type AckConsumer interface {
	Ack()
}

AckConsumer is the interface exported from this package for acking messages.

type PublishSettings

type PublishSettings struct {
	// Publish a non-empty batch after this delay has passed. Must be > 0.
	DelayThreshold time.Duration

	// Publish a batch when it has this many messages. Must be > 0. The maximum is
	// MaxPublishRequestCount.
	CountThreshold int

	// Publish a batch when its size in bytes reaches this value. Must be > 0. The
	// maximum is MaxPublishRequestBytes.
	ByteThreshold int

	// The maximum time that the client will attempt to establish a publish stream
	// connection to the server. Must be > 0.
	//
	// The timeout is exceeded, the publisher will terminate with the last error
	// that occurred while trying to reconnect. Note that if the timeout duration
	// is long, ErrOverflow may occur first.
	Timeout time.Duration

	// The maximum number of bytes that the publisher will keep in memory before
	// returning ErrOverflow. Must be > 0.
	//
	// Note that Pub/Sub Lite topics are provisioned a publishing throughput
	// capacity, per partition, shared by all publisher clients. Setting a large
	// buffer size can mitigate transient publish spikes. However, consistently
	// attempting to publish messages at a much higher rate than the publishing
	// throughput capacity can cause the buffers to overflow. For more
	// information, see https://cloud.google.com/pubsub/lite/docs/topics.
	BufferedByteLimit int
}

PublishSettings control the batching of published messages.

Jump to

Keyboard shortcuts

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