gpubsub

package
v0.0.0-...-269d6e4 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PubsubMsgBroker

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

PubsubMsgBroker is an implementation of MsgBroker for Google PubSub.

func New

func New(projectID, apiKey, topicPrefix, subsName string) (*PubsubMsgBroker, error)

New returns a new *PubsubMsgBroker.

func NewMetered

func NewMetered(projectID, apiKey, topicPrefix, subsName string, meter metric.MeterMust) (*PubsubMsgBroker, error)

NewMetered is the same as New but exporting some metrics.

func (*PubsubMsgBroker) Close

func (p *PubsubMsgBroker) Close() error

Close closes the client.

func (*PubsubMsgBroker) PublishMsg

func (p *PubsubMsgBroker) PublishMsg(ctx context.Context, tname mbroker.TopicName, data []byte) (err error)

PublishMsg publishes a payload to a topic. If the topic doesn't exist, it's created. The topic name is the same as described in RegisterTopicHandler method documentation.

func (*PubsubMsgBroker) RegisterTopicHandler

func (p *PubsubMsgBroker) RegisterTopicHandler(
	tname mbroker.TopicName,
	handler mbroker.TopicHandler,
	opts ...mbroker.Option) error

RegisterTopicHandler registers a handler for a topic.

  • If the topic doesn't exist in PubSub, it's automatically created. The topic name is defined as '<topic-prefix>-<topic-name>'.
  • If a subscription doesn't exist in PubSub it's automatically created. The subscription name is defined as '<topic-prefix>-<topic-name>-<subs-name>' (e.g: "staging-new-batch-created-brokerd")

Jump to

Keyboard shortcuts

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