ClientConnection no longer has public fields.
This commit is contained in:
parent
60e7cac61b
commit
17f5e10547
@ -257,8 +257,15 @@ func removeAgentMetrics(agent *models.Agent) {
|
|||||||
ok1 := agentInfo.Delete(agentLabels(*agent))
|
ok1 := agentInfo.Delete(agentLabels(*agent))
|
||||||
guidLabels := prometheus.Labels{"agent_guid": agent.Guid}
|
guidLabels := prometheus.Labels{"agent_guid": agent.Guid}
|
||||||
ok2 := agentStartTime.Delete(guidLabels)
|
ok2 := agentStartTime.Delete(guidLabels)
|
||||||
ok3 := agentDuration.Delete(guidLabels)
|
// delayed deletion of the duration sow we are sure the prometheus has the last data.
|
||||||
if !ok1 || !ok2 || !ok3 {
|
go func() {
|
||||||
|
time.Sleep(60 * time.Second)
|
||||||
|
ok := agentDuration.Delete(guidLabels)
|
||||||
|
if !ok {
|
||||||
|
log.Printf("Could not delete duration timeseries for agent %s", agent.Guid)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
if !ok1 || !ok2 {
|
||||||
log.Printf("Could not delete all timeseries for agent %s", agent.Guid)
|
log.Printf("Could not delete all timeseries for agent %s", agent.Guid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -267,8 +274,15 @@ func removeClientMetrics(client *models.Client) {
|
|||||||
ok1 := clientInfo.Delete(clientLabels(*client))
|
ok1 := clientInfo.Delete(clientLabels(*client))
|
||||||
guidLabels := prometheus.Labels{"client_guid": client.Guid}
|
guidLabels := prometheus.Labels{"client_guid": client.Guid}
|
||||||
ok2 := clientStartTime.Delete(guidLabels)
|
ok2 := clientStartTime.Delete(guidLabels)
|
||||||
ok3 := clientDuration.Delete(guidLabels)
|
// delayed deletion of the duration sow we are sure the prometheus has the last data.
|
||||||
if !ok1 || !ok2 || !ok3 {
|
go func() {
|
||||||
|
time.Sleep(60 * time.Second)
|
||||||
|
ok := clientDuration.Delete(guidLabels)
|
||||||
|
if !ok {
|
||||||
|
log.Printf("Could not delete duration timeseries for client %s", client.Guid)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
if !ok1 || !ok2 {
|
||||||
log.Printf("Could not delete all timeseries for client %s", client.Guid)
|
log.Printf("Could not delete all timeseries for client %s", client.Guid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,8 +26,8 @@ var clientIdGenerator = concurrency.NewAtomicCounter()
|
|||||||
|
|
||||||
type ClientConnection struct {
|
type ClientConnection struct {
|
||||||
models.Client
|
models.Client
|
||||||
AgentConnection net.Conn
|
agentConnection net.Conn
|
||||||
ClientConnection iowrappers2.ReadWriteAddrCloser
|
clientConnection iowrappers2.ReadWriteAddrCloser
|
||||||
}
|
}
|
||||||
|
|
||||||
func newAgent(commChannel comms.CommChannel, publicId string, agentInfo comms.EnvironmentInfo) *agentConnection {
|
func newAgent(commChannel comms.CommChannel, publicId string, agentInfo comms.EnvironmentInfo) *agentConnection {
|
||||||
@ -53,11 +53,15 @@ func newClient(publicId string, clientConn iowrappers2.ReadWriteAddrCloser,
|
|||||||
ClientId: strconv.Itoa(clientIdGenerator.IncrementAndGet()),
|
ClientId: strconv.Itoa(clientIdGenerator.IncrementAndGet()),
|
||||||
StartTime: time.Now(),
|
StartTime: time.Now(),
|
||||||
},
|
},
|
||||||
AgentConnection: agentConn,
|
agentConnection: agentConn,
|
||||||
ClientConnection: clientConn,
|
clientConnection: clientConn,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (match *ClientConnection) Synchronize() {
|
||||||
|
iowrappers2.SynchronizeStreams("client -- agent", match.clientConnection, match.agentConnection)
|
||||||
|
}
|
||||||
|
|
||||||
type Admin struct {
|
type Admin struct {
|
||||||
// map of public id to agent
|
// map of public id to agent
|
||||||
mutex sync.Mutex
|
mutex sync.Mutex
|
||||||
@ -213,8 +217,8 @@ func (admin *Admin) RemoveClient(client *ClientConnection) error {
|
|||||||
log.Printf("Removing client: '%s' created at %s\n", client.ClientId,
|
log.Printf("Removing client: '%s' created at %s\n", client.ClientId,
|
||||||
client.StartTime.Format(time.DateTime))
|
client.StartTime.Format(time.DateTime))
|
||||||
// try to explicitly close connection to the agent.
|
// try to explicitly close connection to the agent.
|
||||||
_ = client.AgentConnection.Close()
|
_ = client.agentConnection.Close()
|
||||||
_ = client.ClientConnection.Close()
|
_ = client.clientConnection.Close()
|
||||||
|
|
||||||
for i, _client := range admin.clients {
|
for i, _client := range admin.clients {
|
||||||
if _client.ClientId == client.ClientId {
|
if _client.ClientId == client.ClientId {
|
||||||
|
@ -117,7 +117,7 @@ func (converge *MatchMaker) Connect(wsProxyMode bool, publicId string, conn iowr
|
|||||||
client.EnvironmentInfo = clientEnvironment
|
client.EnvironmentInfo = clientEnvironment
|
||||||
}
|
}
|
||||||
converge.logStatus()
|
converge.logStatus()
|
||||||
iowrappers2.SynchronizeStreams("client -- agent", client.ClientConnection, client.AgentConnection)
|
client.Synchronize()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user