gcp

package
v1.3.6 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2020 License: Apache-2.0 Imports: 13 Imported by: 13

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHTTPPublisher

func NewHTTPPublisher(ctx context.Context, projID, topic string, src oauth2.TokenSource) (pubsub.MultiPublisher, error)

NewHTTPPublisher will instantiate a new GCP MultiPublisher that utilizes the HTTP client. This client is useful mainly for the App Engine standard environment as the gRPC client counts against the socket quota for some reason.

func NewPublisher

func NewPublisher(ctx context.Context, cfg Config, opts ...option.ClientOption) (pubsub.MultiPublisher, error)

NewPublisher will instantiate a new GCP MultiPublisher.

Types

type Config

type Config struct {
	ProjectID string `envconfig:"GOOGLE_CLOUD_PROJECT"`

	// For publishing
	Topic string `envconfig:"GCP_PUBSUB_TOPIC"`

	// Batch settings for GCP publisher
	// See: https://godoc.org/cloud.google.com/go/pubsub#PublishSettings
	// Notes:
	// This config will not allow you to set zero values for PublishSettings.
	// Applications using these settings should be aware that Publish requests
	// will block until the lowest of the thresholds in PublishSettings is met.
	PublishSettings gpubsub.PublishSettings

	// For subscribing
	Subscription string `envconfig:"GCP_PUBSUB_SUBSCRIPTION"`
}

Config holds common credentials and config values for working with GCP PubSub.

func LoadConfigFromEnv

func LoadConfigFromEnv() Config

LoadConfigFromEnv will attempt to load a PubSub config from environment variables.

type SubMessage

type SubMessage struct {
	Attributes map[string]string
	// contains filtered or unexported fields
}

SubMessage pubsub implementation of pubsub.SubscriberMessage.

func (*SubMessage) Done

func (m *SubMessage) Done() error

Done will acknowledge the pubsub Message.

func (*SubMessage) ExtendDoneDeadline

func (m *SubMessage) ExtendDoneDeadline(dur time.Duration) error

ExtendDoneDeadline will call the deprecated ModifyAckDeadline for a pubsub Message. This likely should not be called.

func (*SubMessage) Message

func (m *SubMessage) Message() []byte

Message will return the data of the pubsub Message.

type Subscriber

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

Subscriber is a Google Cloud Platform PubSub client that allows a user to consume messages via the pubsub.Subscriber interface.

func NewSubscriber

func NewSubscriber(ctx context.Context, projID, subscription string, opts ...option.ClientOption) (*Subscriber, error)

NewSubscriber will instantiate a new Subscriber that wraps a pubsub.Iterator.

func (*Subscriber) Err

func (s *Subscriber) Err() error

Err will contain any error the Subscriber has encountered while processing.

func (*Subscriber) SetReceiveSettings

func (s *Subscriber) SetReceiveSettings(settings gpubsub.ReceiveSettings)

SetReceiveSettings sets the ReceivedSettings on the google pubsub Subscription. Should be called before Start().

func (*Subscriber) Start

func (s *Subscriber) Start() <-chan pubsub.SubscriberMessage

Start will start pulling from pubsub via a pubsub.Iterator.

func (*Subscriber) Stop

func (s *Subscriber) Stop() error

Stop will block until the consumer has stopped consuming messages.

Jump to

Keyboard shortcuts

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