cloudpubsub

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2019 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package cloudpubsub provides a transport for Google Cloud Publisher/Subscriber.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodeJSONMessage

func EncodeJSONMessage(_ context.Context, msg interface{}) ([]byte, error)

EncodeJSONMessage is an EncodeMessageFunc that serializes the message as a JSON object

Types

type DecodeMessageFunc

type DecodeMessageFunc func(context.Context, []byte) (interface{}, error)

DecodeMessageFunc decodes a message coming from a subscription

type EncodeMessageFunc

type EncodeMessageFunc func(context.Context, interface{}) ([]byte, error)

EncodeMessageFunc encodes a message being published

type Publisher

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

Publisher publishes messages to Google cloud pubsub

func NewPublisher

func NewPublisher(client *pubsub.Client, enc EncodeMessageFunc, topic string) *Publisher

NewPublisher creates a publisher that will publish to the given topic

func (*Publisher) Endpoint

func (p *Publisher) Endpoint() endpoint.Endpoint

Endpoint returns a useable endpoint for publishing messages on the publisher transport

func (*Publisher) Stop

func (p *Publisher) Stop() error

Stop the publication

type Subscriber

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

Subscriber receives messages from Google cloud pubsub

func NewSubscriber

func NewSubscriber(client *pubsub.Client, e endpoint.Endpoint, dec DecodeMessageFunc, topicName string, options ...SubscriberOption) (*Subscriber, error)

NewSubscriber create a subscription of the endpoint to the given event

func (*Subscriber) Unsubscribe

func (s *Subscriber) Unsubscribe()

Unsubscribe gracefully stops the subscriber from receiving messages

type SubscriberOption

type SubscriberOption func(*Subscriber)

SubscriberOption sets an optional parameter for clients

func WithErrorEndpoint

func WithErrorEndpoint(endpoint endpoint.Endpoint) SubscriberOption

WithErrorEndpoint specifies an endpoint to use for sending errors returned by the subscriber endpoint

func WithLogger

func WithLogger(logger log.Logger) SubscriberOption

WithLogger specifies the logger to use

Jump to

Keyboard shortcuts

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