pubsub

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decoder

func Decoder(d DecodeRequestFunc) func(e *Endpoint)

Decoder sets the decode function for requests in the endpoint

func MaxExtension

func MaxExtension(d time.Duration) func(e *Endpoint)

MaxExtension sets the max extension duration

func MaxOutstandingMessages

func MaxOutstandingMessages(n int) func(e *Endpoint)

MaxOutstandingMessages sets the max outstanding messages

func NumGoRoutines added in v0.0.3

func NumGoRoutines(n int) func(e *Endpoint)

NumGoRoutines sets the number of Go routines

func PopulateRequestContext

func PopulateRequestContext(ctx context.Context, msg *pubsub.Message) context.Context

PopulateRequestContext is a RequestFunc that populates several values into the context from the pub/sub message. Those values may be extracted using the corresponding ContextKey type in this package.

func Synchronous added in v0.0.3

func Synchronous(b bool) func(e *Endpoint)

Synchronous sets the synchronous mode

Types

type Client added in v0.0.4

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

Client defines the attributes of the client

func NewClient added in v0.0.4

func NewClient(ctx context.Context, projectID, topic string, opts ...ClientOption) (*Client, error)

NewClient creates the client

func (*Client) Close added in v0.0.4

func (c *Client) Close() error

Close closes the client

func (*Client) Endpoint added in v0.0.4

func (c *Client) Endpoint() endpoint.Endpoint

Endpoint creates an endpoint

type ClientOption added in v0.0.4

type ClientOption func(*Client)

ClientOption sets an optional parameter for clients.

func EncodeRequest added in v0.0.4

func EncodeRequest(er EncodeRequestFunc) ClientOption

EncodeRequest sets the encode request function of the client

func SetClient added in v0.0.4

func SetClient(client *pubsub.Client) ClientOption

SetClient sets the pubsub client

type DecodeRequestFunc

type DecodeRequestFunc func(context.Context, *pubsub.Message) (interface{}, error)

DecodeRequestFunc is a function to decode pub/sub message and return structured data

type EncodeRequestFunc added in v0.0.4

type EncodeRequestFunc func(interface{}) ([]byte, error)

EncodeRequestFunc defines the encode request function

type Endpoint

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

Endpoint for this pubsub transport

type EndpointOption

type EndpointOption func(*Endpoint)

EndpointOption is a function to set option in endpoint

type Handler added in v0.0.3

type Handler func(ctx context.Context, msg *pubsub.Message) error

Handler is a function that processes a Pub/Sub message and returns an error

type Middleware added in v0.0.3

type Middleware func(Handler) Handler

Middleware is a Pub/Sub middleware

type Transport

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

Transport is a transport that receives requests from PubSub

func NewTransport

func NewTransport(ctx context.Context, projectID string) *Transport

NewTransport creates a new Transport for the related Google Cloud Project

func (*Transport) Endpoint

func (t *Transport) Endpoint(subscriptionName string, endpoint endpoint.Endpoint, options ...EndpointOption) *Transport

Endpoint creates a new Endpoint

func (*Transport) LogKeys

func (*Transport) LogKeys() map[string]interface{}

LogKeys returns the keys for logging

func (*Transport) Middleware added in v0.0.3

func (t *Transport) Middleware(m Middleware) *Transport

Middleware sets a Pub/Sub middleware for all endpoint handlers

func (*Transport) RegisterEndpoints

func (t *Transport) RegisterEndpoints(m endpoint.Middleware) error

RegisterEndpoints registers a middleware to all registered endpoints at that time

func (*Transport) Shutdown

func (t *Transport) Shutdown(ctx context.Context) error

Shutdown shutdowns the google pubsub client

func (*Transport) Start

func (t *Transport) Start(ctx context.Context) error

Start starts listening to PubSub

Jump to

Keyboard shortcuts

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