Small comment updates.
This commit is contained in:
parent
b6962e3cb6
commit
e36aaeea36
@ -7,12 +7,6 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Concurrency design:
|
|
||||||
// 1. State is immutable
|
|
||||||
// 2. The MatchMakers uses copy-on-write and never modifies a state directly.
|
|
||||||
// 3. the matchmaker modifies the expiry time of the agent. This is dealt with using the
|
|
||||||
// sync/atomic package by storing the expiry time as an int64 using time.Time.UnixNano()
|
|
||||||
|
|
||||||
type RendezVousId string
|
type RendezVousId string
|
||||||
type AgentGuid string
|
type AgentGuid string
|
||||||
type ClientGuid string
|
type ClientGuid string
|
||||||
@ -53,8 +47,15 @@ type Client struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// State is a description of the current state of converge.
|
// State is a description of the current state of converge.
|
||||||
// Created by the server and used for updating the web client
|
// Created by the matchmaker and used for updating the web client
|
||||||
// and prometheus metrics.
|
// and prometheus metrics.
|
||||||
|
//
|
||||||
|
// Concurrency design:
|
||||||
|
// 1. State is immutable
|
||||||
|
// 2. The MatchMakers uses copy-on-write and never modifies a state directly.
|
||||||
|
// 3. the matchmaker modifies the expiry time of the agent. This is dealt with using the
|
||||||
|
// sync/atomic package by storing the expiry time as an int64 using time.Time.UnixNano()
|
||||||
|
|
||||||
type State struct {
|
type State struct {
|
||||||
Agents map[AgentGuid]*Agent
|
Agents map[AgentGuid]*Agent
|
||||||
Clients map[ClientGuid]*Client
|
Clients map[ClientGuid]*Client
|
||||||
@ -79,6 +80,7 @@ func (state *State) Copy() *State {
|
|||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return agents and clients slices sorted on starttime ascending.
|
||||||
func (state *State) Slices() ([]*Agent, []*Client) {
|
func (state *State) Slices() ([]*Agent, []*Client) {
|
||||||
agents := make([]*Agent, 0, len(state.Agents))
|
agents := make([]*Agent, 0, len(state.Agents))
|
||||||
clients := make([]*Client, 0, len(state.Clients))
|
clients := make([]*Client, 0, len(state.Clients))
|
||||||
|
Loading…
Reference in New Issue
Block a user