ssmongo

package
v0.0.0-...-008069a Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2018 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package ssmongo provides a ss.MultihomeBackend interface that uses MongoDB for synchronizing broadcasts and roomcasts between multiple Sacrificial Socket instances.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MMHB

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

MMHB implements ss.MultihomeBackend and uses MongoDB to syncronize between multiple machines running ss.SocketServer

func NewBackend

func NewBackend(mongoURL, serverName, serverGroup string, pollFrequency time.Duration) *MMHB

NewBackend returns a new instance of MMHB which satisfies the ss.MultihomeBackend interface. A new database "SSMultihome" will be created at the specified mongoURL, and under it 3 collections "ss.activeServers", "ss.roomcasts", and "ss.broadcasts" will be created if they don't already exist.

serverName must be unique per running ss.SocketServer instance, otherwise broadcasts, and roomcasts will not propogate correctly to the other running instances

serverGroup is used to break up broadcast and roomcast domains between multiple ss.SocketServer instances. Most of the time you will want this to be the same for all of your running ss.SocketServer instances

pollFrequency is used to determine how frequently MongoDB is queried for broadcasts or roomcasts

func (*MMHB) BroadcastFromBackend

func (mmhb *MMHB) BroadcastFromBackend(b chan<- *ss.BroadcastMsg)

BroadcastFromBackend polls the ss.broadcasts collection, based on the pollFrequency provided to NewBackend, for new messages designated to this serverName and inserts a ss.BroadcastMsg into b to be dispatched by the server

See documentation on the ss.MultihomeBackend interface for more information

func (*MMHB) BroadcastToBackend

func (mmhb *MMHB) BroadcastToBackend(b *ss.BroadcastMsg)

BroadcastToBackend will insert one broadcast document into the ss.broadcasts collection for each server in the activeServers collection excluding itself, each time BroadcastToBackend is called.

See documentation on the ss.MultihomeBackend interface for more information

func (*MMHB) Init

func (mmhb *MMHB) Init()

Init will create the "SSMultihome" database along with the "ss.activeServers", "ss.broadcasts", and "ss.roomcasts" collections, as well as any neccessary indexes

func (*MMHB) RoomcastFromBackend

func (mmhb *MMHB) RoomcastFromBackend(r chan<- *ss.RoomMsg)

RoomcastFromBackend polls the roomcasts collection, based on the pollFrequency provided to NewBackend, for new messages designated to this serverName and inserts a ss.RoomMsg into r to be dispatched by the ss.SocketServer

See documentation on the ss.MultihomeBackend interface for more information

func (*MMHB) RoomcastToBackend

func (mmhb *MMHB) RoomcastToBackend(r *ss.RoomMsg)

RoomcastToBackend will insert one roomcast document into the roomcasts collection for each server in the activeServers collection excluding itself, each time RoomcastToBackend is called.

See documentation on the ss.MultihomeBackend interface for more information

func (*MMHB) Shutdown

func (mmhb *MMHB) Shutdown()

Shutdown will remove this server from the activeServers collection

Jump to

Keyboard shortcuts

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