exchange

package
v0.0.0-...-f69eaad Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2020 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Initial

func Initial(ctx context.Context)

func NewRedisExchange

func NewRedisExchange(cfg Config) (*redisExchange, error)

func StopExchange

func StopExchange()

Types

type Config

type Config struct {
	// Defaults to "tcp".
	Network string
	// Addr of a single redis server instance.
	// See "Clusters" field for clusters support.
	// Defaults to "127.0.0.1:6379".
	Addr string
	// Clusters a list of network addresses for clusters.
	// If not empty "Addr" is ignored.
	Clusters []string

	Password    string
	DialTimeout time.Duration

	// MaxActive defines the size connection pool.
	// Defaults to 10.
	MaxActive int

	DBIndex uint64
}

type Exchanger

type Exchanger interface {
	CreateRoom(receiveChan chan<- model.RoomMessage, roomId string) Room

	DestroyRoom(Room)

	JoinRoom(receiveChan chan<- model.RoomMessage, roomId string) (Room, error)

	LeaveRoom(sub Room, roomId string)

	Close()
}

func GetExchange

func GetExchange() Exchanger

type LocalExchange

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

func NewLocalExchange

func NewLocalExchange() (*LocalExchange, error)

func (*LocalExchange) Close

func (exc *LocalExchange) Close()

func (*LocalExchange) CreateRoom

func (exc *LocalExchange) CreateRoom(receiveChan chan<- model.RoomMessage, roomId string) Room

func (*LocalExchange) DestroyRoom

func (exc *LocalExchange) DestroyRoom(exRoom Room)

func (*LocalExchange) JoinRoom

func (exc *LocalExchange) JoinRoom(receiveChan chan<- model.RoomMessage, roomId string) (Room, error)

func (*LocalExchange) LeaveRoom

func (exc *LocalExchange) LeaveRoom(exRoom Room, roomId string)

type Room

type Room interface {
	Publish(msg model.RoomMessage)
}

Jump to

Keyboard shortcuts

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