subscription_impl

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2023 License: MIT Imports: 12 Imported by: 3

Documentation

Index

Constants

View Source
const (

	// TypeNotify is the notification message type.
	TypeNotify

	// TypeMessage is the chat message type.
	TypeMessage

	// TypeSystem is the system message type.
	TypeSystem
)
View Source
const (
	MaskPermRead   PermMask = 1 << iota
	MaskPermWrite           = 1 << iota
	MaskPermAdmin           = 1 << iota
	MaskPermSystem          = 1 << iota
)

Variables

This section is empty.

Functions

func IsUnknownMessageType

func IsUnknownMessageType(err error) bool

Types

type Channel

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

func NewChannel

func NewChannel(chanID subscription.ChanID, gate gate.DefaultGateway,
	store store.SubscriptionStore, seqStore ChannelSequenceStore) (*Channel, error)

func (*Channel) Close

func (g *Channel) Close() error

func (*Channel) Publish

func (g *Channel) Publish(msg subscription.Message) error

func (*Channel) Subscribe

func (g *Channel) Subscribe(id subscription.SubscriberID, extra interface{}) error

func (*Channel) Unsubscribe

func (g *Channel) Unsubscribe(id subscription.SubscriberID) error

func (*Channel) Update

func (g *Channel) Update(ci *subscription.ChanInfo) error

type ChannelSequenceStore

type ChannelSequenceStore interface {

	// NextSegmentSequence return the next segment of specified channel, and segment length.
	NextSegmentSequence(id subscription.ChanID, info subscription.ChanInfo) (int64, int64, error)
}

ChannelSequenceStore .

type PermMask

type PermMask int

type Permission

type Permission int64
const (
	PermNone  Permission = 0
	PermRead  Permission = 1 << MaskPermRead
	PermWrite Permission = 1 << MaskPermWrite
	PermAdmin Permission = 1 << MaskPermAdmin
)

type PublishMessage

type PublishMessage struct {
	// From the message sender.
	From subscription.SubscriberID
	// To specified receiver, empty express all subscribers will be received.
	To  []subscription.SubscriberID
	Seq int64
	// Type the message type.
	Type    int
	Message *messages.GlideMessage
}

PublishMessage is the message published to the channel.

func (*PublishMessage) GetChatMessage added in v1.4.7

func (p *PublishMessage) GetChatMessage() (*messages.ChatMessage, error)

func (*PublishMessage) GetFrom

type SubscribeWrap

type SubscribeWrap interface {
	Subscribe(ch subscription.ChanID, id subscription.SubscriberID, extra interface{}) error

	UnSubscribe(ch subscription.ChanID, id subscription.SubscriberID) error

	UpdateSubscriber(ch subscription.ChanID, id subscription.SubscriberID, extra interface{}) error

	RemoveChannel(ch subscription.ChanID) error

	CreateChannel(ch subscription.ChanID, update *subscription.ChanInfo) error

	UpdateChannel(ch subscription.ChanID, update *subscription.ChanInfo) error

	Publish(ch subscription.ChanID, msg subscription.Message) error
}

SubscribeWrap the wrapper for subscription.Subscribe implementation, for convenience.

func NewSubscribeWrap

func NewSubscribeWrap(subscribe subscription.Subscribe) SubscribeWrap

type SubscriberInfo

type SubscriberInfo struct {
	Perm Permission
}

func NewSubscriberInfo

func NewSubscriberInfo(so *SubscriberOptions) *SubscriberInfo

type SubscriberOptions

type SubscriberOptions struct {
	Perm Permission
}

SubscriberOptions is the options for the subscriber

Jump to

Keyboard shortcuts

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