pubsub

package
v0.0.0-...-b8d87c7 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2017 License: MIT Imports: 7 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CloudCodePublisher

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

CloudCodePublisher 云代码发布者,当前支持发布 afterSave 与 afterDelete 通知

func NewCloudCodePublisher

func NewCloudCodePublisher(pubType, pubURL, pubConfig string) *CloudCodePublisher

NewCloudCodePublisher 创建云代码发布者,其中的 Publisher 当前仅支持实验性质的 EventEmitter

func (*CloudCodePublisher) OnCloudCodeAfterDelete

func (c *CloudCodePublisher) OnCloudCodeAfterDelete(request t.M)

OnCloudCodeAfterDelete 对象删除时调用,request 中包含要删除的数据

func (*CloudCodePublisher) OnCloudCodeAfterSave

func (c *CloudCodePublisher) OnCloudCodeAfterSave(request t.M)

OnCloudCodeAfterSave 对象保存时调用,request 中包含修改前与修改后的数据

type EventEmitter

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

EventEmitter 事件发射器

func NewEventEmitter

func NewEventEmitter() *EventEmitter

NewEventEmitter ...

func (*EventEmitter) AddListener

func (e *EventEmitter) AddListener(messageType string, listener HandlerType) *EventEmitter

AddListener 向指定通道添加订阅者的消息监听器

func (*EventEmitter) Emit

func (e *EventEmitter) Emit(messageType string, args ...string) bool

Emit 向指定通道中的所有订阅者发送事件消息

func (*EventEmitter) Init

func (e *EventEmitter) Init()

Init ...

func (*EventEmitter) ListenerCount

func (e *EventEmitter) ListenerCount(messageType string) int

ListenerCount ...

func (*EventEmitter) Listeners

func (e *EventEmitter) Listeners(messageType string) map[int]HandlerType

Listeners ...

func (*EventEmitter) On

func (e *EventEmitter) On(messageType string, listener HandlerType) *EventEmitter

On 向指定通道添加订阅者的消息监听器,同 AddListener

func (*EventEmitter) Once

func (e *EventEmitter) Once(messageType string, listener HandlerType) *EventEmitter

Once 添加只执行一次的监听器

func (*EventEmitter) RemoveAllListeners

func (e *EventEmitter) RemoveAllListeners(messageType string) *EventEmitter

RemoveAllListeners 删除指定通道上类所有监听器,当不指定时,删除所有通道上的所有监听器

func (*EventEmitter) RemoveListener

func (e *EventEmitter) RemoveListener(messageType string, listener HandlerType) *EventEmitter

RemoveListener 删除指定通道上的指定监听器

type HandlerType

type HandlerType func(args ...string)

HandlerType ...

type Publisher

type Publisher interface {
	// Publish 向指定通道发送消息。当有对象保存或删除时,由 tomato 调用
	// channel 当前支持的通道包括:afterSave、afterDelete
	// message json 字符串,格式如下:
	// {
	// 	"currentParseObject": {...},
	// 	"originalParseObject": {...}
	// }
	Publish(channel, message string)
}

Publisher ...

func CreatePublisher

func CreatePublisher(pubType, pubURL, pubConfig string) Publisher

CreatePublisher 创建发布者,当前支持 EventEmitter 、 Redis

type Subscriber

type Subscriber interface {
	// Subscribe 订阅指定通道。由 LiveQueryServer 在初始化时调用
	// channel 当前支持的通道包括:afterSave、afterDelete
	Subscribe(channel string)

	// Unsubscribe 取消订阅指定通道
	Unsubscribe(channel string)

	// On 设置 从指定通道接收到消息时 的 回调函数
	// 统一从 message 通道获取数据
	// 传入 listener 的参数包含两个:
	// 第一个为已订阅的通道名称,当前为 afterSave 或者 afterDelete
	// 第二个为实际的对象数据,格式如下:
	// {
	// 	"currentParseObject": {...},
	// 	"originalParseObject": {...}
	// }
	On(channel string, listener HandlerType)
}

Subscriber ...

func CreateSubscriber

func CreateSubscriber(subType, subURL, subConfig string) Subscriber

CreateSubscriber 创建订阅者,当前支持 EventEmitter 、 Redis

Jump to

Keyboard shortcuts

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