pubsub

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Topics added in v0.5.0

func Topics(o *Option) ([]string, error)

Types

type Consumer

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

func (*Consumer) Info

func (c *Consumer) Info() (i info.Consumer)

func (*Consumer) Msg

func (c *Consumer) Msg() (msg []byte, done bool, err error)

Msg never blocks sets subscription to only have, at max, one message in memory at a time sets subscription to synchronous to only allow one message in memory at a time

func (*Consumer) Stop

func (c *Consumer) Stop() (err error)

Once Stop has been called subsequent calls to Msg should not block and immediately return with msgChan == nil (or len == 0), done == true and err == nil.

type Option

type Option struct {
	// host should only be set for emulator
	Host         string `uri:"host"`
	ProjectID    string `uri:"project"`
	Subscription string `uri:"subscription"`
	Topic        string `uri:"topic" required:"true"`
	JSONAuth     string `uri:"jsonauth"`
	// if nil then the default nsq logger is used
	Logger *log.Logger
}

Option are the settings to connect to a pubsub project instance.

func NewOption

func NewOption(host, project, subscription, topic, jsonauth string) *Option

NewOption creates a set of default options for pubsub, host is only used for the fake emulator project is the google project (id) name subscription is the name of the pubsub subscription will be created if it doesn't exit topic is the pubsub topic, will be created if it doesn't exist jsonauth is the generated json string authorization settings for access to pubsub

func (*Option) NewConsumer

func (o *Option) NewConsumer() (c *Consumer, err error)

NewConsumer creates a new consumer for reading messages from pubsub

func (*Option) NewProducer

func (o *Option) NewProducer() (p *Producer, err error)

NewProducer will create a new pubsub producer for publishing messages to pubsub

type Producer

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

func (*Producer) Info

func (p *Producer) Info() (i info.Producer)

func (*Producer) Send

func (p *Producer) Send(topic string, msg []byte) (err error)

Send will send one message to the topic Settings are for publishing one message at a time with a 100 millisecond delay locking is used to update the topic count of published messages.

func (*Producer) Stop

func (p *Producer) Stop() (err error)

Jump to

Keyboard shortcuts

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