subscription

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 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      = errors.New("channel does not exist")
	ErrChanAlreadyExists = errors.New("channel already exists")
	ErrChanClosed        = errors.New("subscribe channel is closed")
	ErrAlreadySubscribed = errors.New("already subscribed")
	ErrNotSubscribed     = errors.New("not subscribed")
	ErrNotPublisher      = errors.New("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

	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

	UpdateSubscribe(id SubscriberID, extra interface{}) error

	Update(extra interface{}) 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 {
}

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