subscription

package
v1.3.5 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2022 License: MIT Imports: 2 Imported by: 2

Documentation

Index

Constants

View Source
const (
	SubscriberSubscribe   int64 = 1
	SubscriberUnsubscribe       = 2
	SubscriberUpdate            = 5
)
View Source
const (
	ChanCreate int64 = 1
	ChanDelete       = 2
	ChanUpdate       = 3
)

Variables

View Source
var (
	ErrChanNotExist      = "channel does not exist"
	ErrChanAlreadyExists = "channel already exists"
	ErrChanClosed        = "subscribe channel is closed"
	ErrAlreadySubscribed = "already subscribed"
	ErrNotSubscribed     = "not subscribed"
	ErrNotPublisher      = "not publisher"
)
View Source
var (
	ErrUnknownFlag = errors.New("unknown flag")
)

Functions

This section is empty.

Types

type Chan added in v1.1.0

type Chan struct {
}

type ChanID

type ChanID string

ChanID is a unique identifier for a channel.

type ChanInfo added in v1.1.0

type ChanInfo struct {
	ID   ChanID
	Type ChanType

	Muted   bool
	Blocked bool
	Closed  bool

	Parent *ChanID
	Child  []ChanID
}

func NewChanInfo added in v1.1.0

func NewChanInfo(id ChanID, type_ ChanType) *ChanInfo

type ChanType added in v1.1.0

type ChanType int32
const (
	ChanTypeUnknown ChanType = 0
)

type Channel

type Channel interface {
	Subscribe(id SubscriberID, extra interface{}) error

	Unsubscribe(id SubscriberID) error

	Update(i *ChanInfo) error

	Publish(msg Message) error

	Close() error
}

type ChannelUpdate

type ChannelUpdate struct {
	Flag int64

	Extra interface{}
}

type Interface

type Interface interface {
	PublishMessage(id ChanID, message Message) error
}

type Message

type Message interface {
	GetFrom() SubscriberID
}

Message is a message that can be sent to a subscriber.

type Server

type Server interface {
	Subscribe

	Run() error
}

type Subscribe

type Subscribe interface {
	Interface

	SetGateInterface(gate gate.Interface)

	UpdateSubscriber(id ChanID, updates []Update) error

	UpdateChannel(id ChanID, update ChannelUpdate) error
}

type Subscriber

type Subscriber struct {
	ID   string
	Type string
}

func (*Subscriber) Notify

func (s *Subscriber) Notify(msg Message) error

type SubscriberID added in v1.1.0

type SubscriberID string

type Update added in v1.1.0

type Update struct {
	Flag int64
	ID   SubscriberID

	Extra interface{}
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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