代码拉取完成,页面将自动刷新
package ericMetrics
import (
"gitee.com/tym_hmm/eric-metrics/internal/plot"
"time"
"github.com/gorilla/websocket"
)
var plots plot.List
// sendStats indefinitely send runtime statistics on the websocket connection.
func sendStats(conn *websocket.Conn, frequency time.Duration) error {
tick := time.NewTicker(frequency)
defer tick.Stop()
// If the websocket connection is initiated by an already open web ui
// (started by a previous process for example) then plotsdef.js won't be
// requested. So, call plots.config manually to ensure that the data
// structures inside 'plots' are correctly initialized.
plots.Config()
for range tick.C {
w, err := conn.NextWriter(websocket.TextMessage)
if err != nil {
return err
}
if err := plots.WriteValues(w); err != nil {
return err
}
if err := w.Close(); err != nil {
return err
}
}
panic("unreachable")
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。