share

package
v0.0.2 Latest Latest
Warning

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

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

Documentation

Overview

共享订阅

共享订阅

共享订阅

Index

Constants

View Source
const (
	// MWC is the multi-level wildcard
	MWC = "#"

	// SWC is the single level wildcard
	SWC = "+"

	// SEP is the topic level separator
	SEP = "/"

	// SYS is the starting character of the system level topics
	//SYS是系统级主题的起始字符
	SYS = "$"
)

Variables

View Source
var (
	// ErrAuthFailure is returned when the user/pass supplied are invalid
	ErrAuthFailure = errors.New("auth: Authentication failure")

	// ErrAuthProviderNotFound is returned when the requested provider does not exist.
	// It probably hasn't been registered yet.
	ErrAuthProviderNotFound = errors.New("auth: Authentication provider not found")
)
View Source
var Default = "default"
View Source
var (
	// MaxQosAllowed is the maximum QOS supported by this server
	MaxQosAllowed = messagev5.QosExactlyOnce
)

Functions

func NewMemProvider

func NewMemProvider() *memTopics

NewMemProvider returns an new instance of the memTopics, which is implements the TopicsProvider interface. memProvider is a hidden struct that stores the topic subscriptions and retained messages in memory. The content is not persistend so when the server goes, everything will be gone. Use with care. NewMemProvider返回memTopics的一个新实例,该实例实现了 TopicsProvider接口。memProvider是存储主题的隐藏结构 订阅并保留内存中的消息。内容不是这样持久化的 当服务器关闭时,所有东西都将消失。小心使用。

func Register

func Register(name string, provider ShareTopicsProvider)

func ShareTopicInit

func ShareTopicInit()

func Unregister

func Unregister(name string)

Types

type Manager

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

func NewManager

func NewManager(providerName string) (*Manager, error)

func (*Manager) AllSubInfo

func (this *Manager) AllSubInfo() (map[string][]string, error)

func (*Manager) Close

func (this *Manager) Close() error

func (*Manager) Retain

func (this *Manager) Retain(msg *messagev5.PublishMessage, shareName []byte) error

func (*Manager) Retained

func (this *Manager) Retained(topic, shareName []byte, msgs *[]*messagev5.PublishMessage) error

func (*Manager) Subscribe

func (this *Manager) Subscribe(topic, shareName []byte, qos byte, subscriber interface{}) (byte, error)

func (*Manager) Subscribers

func (this *Manager) Subscribers(topic, shareName []byte, qos byte, subs *[]interface{}, qoss *[]byte) error

func (*Manager) Unsubscribe

func (this *Manager) Unsubscribe(topic, shareName []byte, subscriber interface{}) error

type ShareTopicsProvider

type ShareTopicsProvider interface {
	Subscribe(topic, shareName []byte, qos byte, subscriber interface{}) (byte, error)
	Unsubscribe(topic, shareName []byte, subscriber interface{}) error
	Subscribers(topic, shareName []byte, qos byte, subs *[]interface{}, qoss *[]byte) error
	AllSubInfo() (map[string][]string, error) // 获取所有的共享订阅,k: 主题,v: 该主题的所有共享组
	Retain(msg *messagev5.PublishMessage, shareName []byte) error
	Retained(topic, shareName []byte, msgs *[]*messagev5.PublishMessage) error
	Close() error
}

TopicsProvider

Jump to

Keyboard shortcuts

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