pubsub

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: May 15, 2023 License: Apache-2.0 Imports: 19 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultSubscriberClient

func DefaultSubscriberClient(ctx context.Context) (*gcppubsub.SubscriberClient, error)

Types

type Client

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

func NewConsumer

func NewConsumer(projectID, subscriptionID string, opts ...ConsumerOption) (*Client, error)

NewConsumer returns a pubsub task queue client.

func (*Client) Backlog added in v0.4.0

func (c *Client) Backlog(ctx context.Context) (int64, error)

Backlog implements interface.autoscaler.qbas.Queue

func (*Client) Process

func (c *Client) Process(ctx context.Context, cb messaging.Callback) error

func (*Client) Pull

func (c *Client) Pull(ctx context.Context, cb messaging.Callback) error

Pull implements Messaging.Consumer

func (*Client) SetProcessOption

func (c *Client) SetProcessOption(opts ...ProcessOption)

type ConsumerOption

type ConsumerOption func(o *consumerOptions)

func WithMonitoringClient

func WithMonitoringClient(m *monitoring.MetricClient) ConsumerOption

func WithSubscriberClient

func WithSubscriberClient(ps *gcppubsub.SubscriberClient) ConsumerOption

type ProcessOption

type ProcessOption func(o *processOptions)

func ExitOnExtensionError

func ExitOnExtensionError() ProcessOption

ExitOnExtensionError will make Process return an error immediately if the pubsub extension/ acknowledgement process failed, without waiting for the callback to return its success/failure (i.e. the callback is still runnning in a goroutine until it checks that it's context has been cancelled. This option can/should be used when Process() will be calling long-running cgo calls where we cannot ensure that context cancellation can be checked or acted upon (it is not possible to interrupt a cgo call). When using this option, and to avoid ressource leaks, it is highly recommended that the caller of Process() ensures that the whole program exits as soon as possible after it receives a non nil error return value.

func ExtensionPeriod

func ExtensionPeriod(t time.Duration) ProcessOption

ExtensionPeriod is the duration by which to extend the ack deadline at a time. The ack deadline will continue to be extended by up to this duration until MaxExtension is reached. Setting ExtensionPeriod bounds the maximum amount of time before a message redelivery in the event the subscriber fails to extend the deadline.

ExtensionPeriod configuration can be disabled by specifying a duration less than (or equal to) 0.

func OnErrorRetryDelay

func OnErrorRetryDelay(t time.Duration) ProcessOption

func ReturnImmediately

func ReturnImmediately() ProcessOption

ReturnImmediately will return nil immediately if there are no messages to process. If not set, Process will block until a message becomes available

type Publisher

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

Publisher implements messaging.Publisher

func NewPublisher

func NewPublisher(ctx context.Context, projectID, topic string, opts ...PublisherOption) (*Publisher, error)

NewPublisher creates a pubsub publisher

func (*Publisher) Publish

func (p *Publisher) Publish(ctx context.Context, data ...[]byte) error

Publish implements messaging.Publisher

func (*Publisher) Stop

func (p *Publisher) Stop()

type PublisherOption

type PublisherOption func(o *publisherOptions)

func WithMaxRetries

func WithMaxRetries(maxRetries int) PublisherOption

Jump to

Keyboard shortcuts

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