pubsub

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package 发布订阅器对象

Package pubsub 发布订阅器对象 非常适合作为简单的广播模式的中间件

Index

Constants

This section is empty.

Variables

View Source
var ErrNeedToPointOutTopics = errors.New("需要指名发布订阅器")

ErrNeedToPointOutTopics 需要指名发布订阅器

View Source
var ErrPubSubAlreadyListened = errors.New("发布订阅器已经被监听了")

ErrPubSubAlreadyListened 发布订阅器已经被监听了

View Source
var ErrPubSubNotListeningYet = errors.New("发布订阅器未被监听")

ErrPubSubNotListeningYet 发布订阅器未被监听

Functions

This section is empty.

Types

type Consumer

type Consumer struct {
	*clientkeybatch.ClientKeyBatch
	*consumerabc.ConsumerABC
	// contains filtered or unexported fields
}

Consumer 发布订阅器消费者对象

func NewConsumer

func NewConsumer(kb *clientkeybatch.ClientKeyBatch, opts ...broker.Option) *Consumer

NewConsumer 创建一个新的发布订阅器消费者对象 @params k *clientkeybatch.ClientKeyBatch redis客户端的批键对象 @params opts ...broker.Option 消费者的配置

func (*Consumer) Listen

func (s *Consumer) Listen(asyncHanddler bool, p ...event.Parser) error

Listen 监听发布订阅器 @params asyncHanddler bool 是否并行执行回调 @params p ...Parser 解析输入消息为事件对象的函数

func (*Consumer) StopListening

func (s *Consumer) StopListening() error

StopListening 停止监听

type Producer

type Producer struct {
	*clientkey.ClientKey
	// contains filtered or unexported fields
}

Producer 发布订阅器生产者对象

func NewProducer

func NewProducer(k *clientkey.ClientKey, opts ...broker.Option) *Producer

NewProducer 创建一个新的发布订阅器的生产者 @params k *clientkey.ClientKey redis客户端的键对象 @params opts ...broker.Option 生产者的配置

func (*Producer) PubEvent

func (p *Producer) PubEvent(ctx context.Context, payload interface{}) (*event.Event, error)

PubEvent 向发布订阅器中放入事件数据 @params ctx context.Context 请求的上下文 @params payload []byte 发送的消息负载 @returns *event.Event 发送出去的消息对象

func (*Producer) Publish

func (p *Producer) Publish(ctx context.Context, payload interface{}) error

Publish 向队列中放入数据 @params ctx context.Context 请求的上下文 @params payload interface{} 发送的消息负载,负载支持string,bytes,bool,number,以及可以被json或者msgpack序列化的对象

Jump to

Keyboard shortcuts

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