rsub

package
v0.0.0-...-88f3d6a Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

README

设计

  • clientid+topic 作为一个Key,value 为订阅信息存放在Redis中
  • topic 作为一个key, value 为set 类型,其中的值为 clientid;这样可以通过topic 找到所有相关订阅者
  • 查找的时候通过 topic 进行切分,分别查找 topic 对应的 clientid, 再找到 clientid对应该topic的订阅信息.
  • key: clientid, value 是一个set集合,用于保存该clientid所有的订阅topic

数据结构

  • 两个set集合,一个key是topic(value 是订阅该topic的所有clientid),一个key 是 clientid(value 是记录该clientid订阅的所有topic)
  • 一个普通key-value数据,key: clientid+topic; value 是具体的订阅信息.

需要发送的离线消息记录

  • key: clientid+offline, set集合; value: msgid

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseRSub

func CloseRSub(s *RSub) error

CloseRSub close redis sub conn

Types

type RSub

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

func NewRSub

func NewRSub(c svc.RedisConf) (s *RSub)

NewRSub connect redis server

func (*RSub) AddOfflineMsgID

func (s *RSub) AddOfflineMsgID(clientid, msgid string) (err error)

AddOfflineMsgID .

func (*RSub) ClearSub

func (s *RSub) ClearSub(clientid string) (err error)

ClearSub .

func (*RSub) GetOfflineMsgID

func (s *RSub) GetOfflineMsgID(clientid string) (msgids []string, err error)

GetOfflineMsgID .

func (*RSub) GetSubByTopic

func (s *RSub) GetSubByTopic(topic string) (subs []Sub, err error)

GetSubByTopic .

func (*RSub) RemoveOfflineMsgID

func (s *RSub) RemoveOfflineMsgID(clientid, msgid string) (err error)

RemoveOfflineMsgID .

func (*RSub) Sub

func (s *RSub) Sub(account, clientid string, topics []*PPMQSubscribe.TopicInfo) (err error)

Sub .

func (*RSub) UnSub

func (s *RSub) UnSub(clientid string, topics []string) (err error)

UnSub .

type Sub

type Sub struct {
	Account      string
	ClientID     string
	Cluster      uint32
	ClusterSubid string
	Qos          uint32
}

Jump to

Keyboard shortcuts

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