subscription

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 27, 2022 License: MIT Imports: 2 Imported by: 2

Documentation

Index

Constants

View Source
const (
	SubscriberSubscribe   int64 = 1
	SubscriberUnsubscribe       = 2
	SubscriberMute              = 3
	SubscriberUnmute            = 4
)
View Source
const (
	ChanCreate int64 = 1
	ChanDelete       = 2
	ChanMute         = 3
	ChanUnmute       = 4
)

Variables

View Source
var (
	ErrChanClosed        = errors.New("subscribe channel is closed")
	ErrAlreadySubscribed = errors.New("already subscribed")
	ErrNotSubscribed     = errors.New("not subscribed")
	ErrNotPublisher      = errors.New("not publisher")
)

Functions

This section is empty.

Types

type ChanID

type ChanID string

ChanID is a unique identifier for a channel.

type Channel

type Channel interface {
	GetSubscriber(id string) (Subscriber, error)

	Subscribe(id string, subscriber Subscriber) error

	Unsubscribe(id string) error

	UnsubscribeAll() 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 {
	SetGateInterface(gate gate.Interface)

	UpdateSubscriber(id ChanID, updates []SubscriberUpdate) 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 SubscriberUpdate

type SubscriberUpdate struct {
	Flag int64
	ID   gate.ID

	Extra interface{}
}

Jump to

Keyboard shortcuts

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