pubsub

package
v0.3.12 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init added in v0.0.6

func Init()

func Publish

func Publish(tag string, data map[string]interface{})

func PublishTopic

func PublishTopic(topic string, tag string, data map[string]interface{})

func SendEvent

func SendEvent(appId string, uid string, event string, v interface{})

func SendTagEvent added in v0.0.5

func SendTagEvent(tag string, appId string, uid string, event string, v interface{})

SendTagEvent the first param tag is used for filter events in a pubsub topic for a specific subscription

Types

type MessageCallback added in v0.0.9

type MessageCallback func(msg *pubsub.Message) error

type PubSub added in v0.0.9

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

func NewPubSub added in v0.0.9

func NewPubSub(proj string, topic string, subscription string) *PubSub

func (*PubSub) Publish added in v0.0.9

func (p *PubSub) Publish(data interface{}) (string, error)

Publish a message to the topic Notice: this function is synchronous, so it will block until the message is published the caller should call this function in a goroutine

func (*PubSub) PullMessage added in v0.0.9

func (p *PubSub) PullMessage(callback MessageCallback, timeout time.Duration) error

PullMessage will pull a message from the topic using synchronous method, so it will block until a message is pulled if callback function returns error, the message will not be consumed and will be pulled again callback 业务完成以后, 返回nil, 否则返回错误 一旦返回错误,在一段时间之内,消息会继续被重新推送 如果超过时间,还没有成功, 则消息会进入死信队列

Jump to

Keyboard shortcuts

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