From e36aaeea36457a4c6d93d01c4f5131efb12c1d34 Mon Sep 17 00:00:00 2001 From: Erik Brakkee Date: Fri, 16 Aug 2024 00:27:42 +0200 Subject: [PATCH] Small comment updates. --- pkg/models/state.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/pkg/models/state.go b/pkg/models/state.go index 8fefd8e..b55e406 100644 --- a/pkg/models/state.go +++ b/pkg/models/state.go @@ -7,12 +7,6 @@ import ( "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 AgentGuid string type ClientGuid string @@ -53,8 +47,15 @@ type Client struct { } // 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. +// +// 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 { Agents map[AgentGuid]*Agent Clients map[ClientGuid]*Client @@ -79,6 +80,7 @@ func (state *State) Copy() *State { return res } +// Return agents and clients slices sorted on starttime ascending. func (state *State) Slices() ([]*Agent, []*Client) { agents := make([]*Agent, 0, len(state.Agents)) clients := make([]*Client, 0, len(state.Clients))