MCPcopy Create free account
hub / github.com/GoEdgeLab/EdgeNode / init

Function init

internal/nodes/client_conn_traffic.go:17–45  ·  view source on GitHub ↗

发送监控流量

()

Source from the content-addressed store, hash-verified

15
16// 发送监控流量
17func init() {
18 if !teaconst.IsMain {
19 return
20 }
21
22 events.On(events.EventStart, func() {
23 var ticker = time.NewTicker(1 * time.Minute)
24 goman.New(func() {
25 for range ticker.C {
26 // 加入到数据队列中
27 var inBytes = atomic.LoadUint64(&teaconst.InTrafficBytes)
28 atomic.StoreUint64(&teaconst.InTrafficBytes, 0) // 重置数据
29 if inBytes > 0 {
30 monitor.SharedValueQueue.Add(nodeconfigs.NodeValueItemTrafficIn, maps.Map{
31 "total": inBytes,
32 })
33 }
34
35 var outBytes = atomic.LoadUint64(&teaconst.OutTrafficBytes)
36 atomic.StoreUint64(&teaconst.OutTrafficBytes, 0) // 重置数据
37 if outBytes > 0 {
38 monitor.SharedValueQueue.Add(nodeconfigs.NodeValueItemTrafficOut, maps.Map{
39 "total": outBytes,
40 })
41 }
42 }
43 })
44 })
45}

Callers

nothing calls this directly

Calls 3

OnFunction · 0.92
NewFunction · 0.92
AddMethod · 0.65

Tested by

no test coverage detected