Using LinkedMap that preserves insertion order for the implementation and also added unit tests for that.
53 lines
1.1 KiB
Go
53 lines
1.1 KiB
Go
package models
|
|
|
|
import (
|
|
"git.wamblee.org/converge/pkg/comms"
|
|
"git.wamblee.org/converge/pkg/support/collections"
|
|
"time"
|
|
)
|
|
|
|
type RendezVousId string
|
|
type AgentGuid string
|
|
type ClientGuid string
|
|
type ClientId string
|
|
type SessionType string
|
|
type RemoteAddr string
|
|
|
|
type Agent struct {
|
|
Guid AgentGuid
|
|
RemoteAddr RemoteAddr
|
|
PublicId RendezVousId
|
|
StartTime time.Time
|
|
|
|
// TODO add remote address.
|
|
|
|
EnvironmentInfo comms.EnvironmentInfo
|
|
ExpiryTime time.Time
|
|
}
|
|
|
|
type Client struct {
|
|
Guid ClientGuid
|
|
RemoteAddr RemoteAddr
|
|
PublicId RendezVousId
|
|
ClientId ClientId
|
|
AgentGuid AgentGuid
|
|
StartTime time.Time
|
|
SessionType SessionType
|
|
EnvironmentInfo comms.EnvironmentInfo
|
|
}
|
|
|
|
// State is a description of the current state of converge.
|
|
// Created by the server and used for updating the web client
|
|
// and prometheus metrics.
|
|
type State struct {
|
|
Agents *collections.LinkedMap[AgentGuid, *Agent]
|
|
Clients *collections.LinkedMap[ClientGuid, *Client]
|
|
}
|
|
|
|
func NewState() *State {
|
|
return &State{
|
|
Agents: collections.NewLinkedMap[AgentGuid, *Agent](),
|
|
Clients: collections.NewLinkedMap[ClientGuid, *Client](),
|
|
}
|
|
}
|