Documentation ¶
Overview ¶
Package coordinator contains the coordinator definition
Index ¶
- Variables
- func ConnectClient(state *State, conn ws.IWebsocket)
- func ConnectCommServer(state *State, conn ws.IWebsocket, role protocol.Role)
- func Register(state *State, mux *http.ServeMux)
- func Start(state *State)
- func UpgradeRequest(state *State, role protocol.Role, w http.ResponseWriter, r *http.Request) (ws.IWebsocket, error)
- type ByAlias
- type Config
- type DefaultServerSelector
- type IServerSelector
- type Peer
- type State
- type Stats
Constants ¶
This section is empty.
Variables ¶
ErrUnauthorized indicates that a peer is not authorized for the role
Functions ¶
func ConnectClient ¶
func ConnectClient(state *State, conn ws.IWebsocket)
ConnectClient establish a ws connection to a client
func ConnectCommServer ¶
func ConnectCommServer(state *State, conn ws.IWebsocket, role protocol.Role)
ConnectCommServer establish a ws connection to a communication server
func UpgradeRequest ¶
func UpgradeRequest(state *State, role protocol.Role, w http.ResponseWriter, r *http.Request) (ws.IWebsocket, error)
UpgradeRequest upgrades a HTTP request to ws protocol and authenticates for the role
Types ¶
type Config ¶
type Config struct { Log *logging.Logger ServerSelector IServerSelector Auth authentication.CoordinatorAuthenticator Reporter func(stats Stats) ReportPeriod time.Duration }
Config is the coordinator config
type DefaultServerSelector ¶
DefaultServerSelector is the default server selector
func (*DefaultServerSelector) GetServerAliasList ¶
func (r *DefaultServerSelector) GetServerAliasList(role protocol.Role) []uint64
GetServerAliasList returns a list of tracked server aliases
func (*DefaultServerSelector) GetServerCount ¶
func (r *DefaultServerSelector) GetServerCount() int
GetServerCount return amount of servers registered
func (*DefaultServerSelector) ServerRegistered ¶
func (r *DefaultServerSelector) ServerRegistered(role protocol.Role, alias uint64)
ServerRegistered register a new server
func (*DefaultServerSelector) ServerUnregistered ¶
func (r *DefaultServerSelector) ServerUnregistered(alias uint64)
ServerUnregistered removes an unregistered server from the list
type IServerSelector ¶
type IServerSelector interface { ServerRegistered(role protocol.Role, alias uint64) ServerUnregistered(alias uint64) GetServerAliasList(forRole protocol.Role) []uint64 GetServerCount() int }
IServerSelector is in charge of tracking and processing the server list
type Peer ¶
type Peer struct { Alias uint64 // contains filtered or unexported fields }
Peer represents any peer, both server and clients