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))
|
||||
guidLabels := prometheus.Labels{"agent_guid": agent.Guid}
|
||||
ok2 := agentStartTime.Delete(guidLabels)
|
||||
ok3 := agentDuration.Delete(guidLabels)
|
||||
if !ok1 || !ok2 || !ok3 {
|
||||
// delayed deletion of the duration sow we are sure the prometheus has the last data.
|
||||
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)
|
||||
}
|
||||
}
|
||||
@ -267,8 +274,15 @@ func removeClientMetrics(client *models.Client) {
|
||||
ok1 := clientInfo.Delete(clientLabels(*client))
|
||||
guidLabels := prometheus.Labels{"client_guid": client.Guid}
|
||||
ok2 := clientStartTime.Delete(guidLabels)
|
||||
ok3 := clientDuration.Delete(guidLabels)
|
||||
if !ok1 || !ok2 || !ok3 {
|
||||
// delayed deletion of the duration sow we are sure the prometheus has the last data.
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
@ -26,8 +26,8 @@ var clientIdGenerator = concurrency.NewAtomicCounter()
|
||||
|
||||
type ClientConnection struct {
|
||||
models.Client
|
||||
AgentConnection net.Conn
|
||||
ClientConnection iowrappers2.ReadWriteAddrCloser
|
||||
agentConnection net.Conn
|
||||
clientConnection iowrappers2.ReadWriteAddrCloser
|
||||
}
|
||||
|
||||
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()),
|
||||
StartTime: time.Now(),
|
||||
},
|
||||
AgentConnection: agentConn,
|
||||
ClientConnection: clientConn,
|
||||
agentConnection: agentConn,
|
||||
clientConnection: clientConn,
|
||||
}
|
||||
}
|
||||
|
||||
func (match *ClientConnection) Synchronize() {
|
||||
iowrappers2.SynchronizeStreams("client -- agent", match.clientConnection, match.agentConnection)
|
||||
}
|
||||
|
||||
type Admin struct {
|
||||
// map of public id to agent
|
||||
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,
|
||||
client.StartTime.Format(time.DateTime))
|
||||
// try to explicitly close connection to the agent.
|
||||
_ = client.AgentConnection.Close()
|
||||
_ = client.ClientConnection.Close()
|
||||
_ = client.agentConnection.Close()
|
||||
_ = client.clientConnection.Close()
|
||||
|
||||
for i, _client := range admin.clients {
|
||||
if _client.ClientId == client.ClientId {
|
||||
|
@ -117,7 +117,7 @@ func (converge *MatchMaker) Connect(wsProxyMode bool, publicId string, conn iowr
|
||||
client.EnvironmentInfo = clientEnvironment
|
||||
}
|
||||
converge.logStatus()
|
||||
iowrappers2.SynchronizeStreams("client -- agent", client.ClientConnection, client.AgentConnection)
|
||||
client.Synchronize()
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user