pubsub

package
v3.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2022 License: MIT Imports: 2 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Broadcaster

type Broadcaster interface {
	GetDriver(key string) (SubReader, error)
}

type Constructor

type Constructor interface {
	PubSubFromConfig(key string) (PubSub, error)
}

Constructor is a special pub-sub interface made to return a constructed PubSub type

type Message

type Message interface {
	MarshalBinary() (data []byte, err error)
	Topic() string
	Payload() []byte
}

Message represents message

type Msg

type Msg struct {
	// Topic (channel in terms of redis)
	Topic_ string `json:"topic"`
	// Payload (on some decode stages might be represented as base64 string)
	Payload_ []byte `json:"payload"`
}

Msg represents a single message with payload bound to a particular topic

func (*Msg) MarshalBinary

func (m *Msg) MarshalBinary() (data []byte, err error)

func (*Msg) Payload

func (m *Msg) Payload() []byte

func (*Msg) Topic

func (m *Msg) Topic() string

type PubSub

type PubSub interface {
	Publisher
	Subscriber
	Reader
}

PubSub interface designed to implement on any storage type to provide pub-sub abilities Publisher used to receive messages from the PHP app via RPC Subscriber should be implemented to subscribe to a topics and provide a connections list per topic Reader return next message from the channel

type Publisher

type Publisher interface {
	// Publish one or multiple Channel.
	Publish(Message) error

	// PublishAsync publish message and return immediately
	// If error occurred it will be printed into the logger
	PublishAsync(Message)
}

Publisher publish one or more messages BETA interface

type Reader

type Reader interface {
	Next(ctx context.Context) (Message, error)
}

Reader interface should return next message

type SubReader

type SubReader interface {
	Subscriber
	Reader
}

type Subscriber

type Subscriber interface {
	// Subscribe broker to one or multiple topics.
	Subscribe(connectionID string, topics ...string) error

	// Unsubscribe from one or multiply topics
	Unsubscribe(connectionID string, topics ...string) error

	// Connections returns all connections associated with the particular topic
	Connections(topic string, ret map[string]struct{})

	// Stop used to stop the driver and free up the connection
	Stop()
}

Subscriber defines the ability to operate as message passing broker. BETA interface

Jump to

Keyboard shortcuts

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