mirror of
https://github.com/fosrl/olm.git
synced 2026-03-09 04:06:42 +00:00
Send an initial ping so we get online faster in the dashboard
This commit is contained in:
@@ -660,16 +660,8 @@ func (c *Client) setupPKCS12TLS() (*tls.Config, error) {
|
|||||||
return loadClientCertificate(c.tlsConfig.PKCS12File)
|
return loadClientCertificate(c.tlsConfig.PKCS12File)
|
||||||
}
|
}
|
||||||
|
|
||||||
// pingMonitor sends pings at a short interval and triggers reconnect on failure
|
// sendPing sends a single ping message
|
||||||
func (c *Client) pingMonitor() {
|
func (c *Client) sendPing() {
|
||||||
ticker := time.NewTicker(c.pingInterval)
|
|
||||||
defer ticker.Stop()
|
|
||||||
|
|
||||||
for {
|
|
||||||
select {
|
|
||||||
case <-c.done:
|
|
||||||
return
|
|
||||||
case <-ticker.C:
|
|
||||||
if c.isDisconnected || c.conn == nil {
|
if c.isDisconnected || c.conn == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -679,7 +671,7 @@ func (c *Client) pingMonitor() {
|
|||||||
c.processingMux.RUnlock()
|
c.processingMux.RUnlock()
|
||||||
if isProcessing {
|
if isProcessing {
|
||||||
logger.Debug("websocket: Skipping ping, message is being processed")
|
logger.Debug("websocket: Skipping ping, message is being processed")
|
||||||
continue
|
return
|
||||||
}
|
}
|
||||||
// Send application-level ping with config version
|
// Send application-level ping with config version
|
||||||
c.configVersionMux.RLock()
|
c.configVersionMux.RLock()
|
||||||
@@ -720,6 +712,19 @@ func (c *Client) pingMonitor() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// pingMonitor sends pings at a short interval and triggers reconnect on failure
|
||||||
|
func (c *Client) pingMonitor() {
|
||||||
|
ticker := time.NewTicker(c.pingInterval)
|
||||||
|
defer ticker.Stop()
|
||||||
|
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case <-c.done:
|
||||||
|
return
|
||||||
|
case <-ticker.C:
|
||||||
|
c.sendPing()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -734,7 +739,12 @@ func (c *Client) StartPingMonitor() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
c.pingStarted = true
|
c.pingStarted = true
|
||||||
go c.pingMonitor()
|
|
||||||
|
// Send an initial ping immediately
|
||||||
|
go func() {
|
||||||
|
c.sendPing()
|
||||||
|
c.pingMonitor()
|
||||||
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetConfigVersion returns the current config version
|
// GetConfigVersion returns the current config version
|
||||||
|
|||||||
Reference in New Issue
Block a user