重命名包 client 为 edge;重命名包 server 为 gateway
This commit is contained in:
51
gateway/debug/debug.go
Normal file
51
gateway/debug/debug.go
Normal file
@@ -0,0 +1,51 @@
|
||||
package debug
|
||||
|
||||
import (
|
||||
"container/ring"
|
||||
"context"
|
||||
"time"
|
||||
)
|
||||
|
||||
func Start(ctx context.Context) {
|
||||
go startReceiveConsuming(ctx)
|
||||
}
|
||||
|
||||
type Consuming struct {
|
||||
Auth time.Duration
|
||||
Data time.Duration
|
||||
Proxy time.Duration
|
||||
Total time.Duration
|
||||
}
|
||||
|
||||
var ConsumingCh = make(chan Consuming, 1024)
|
||||
var consumingList = ring.New(3000)
|
||||
|
||||
func startReceiveConsuming(ctx context.Context) {
|
||||
InitConsumingList()
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
case c := <-ConsumingCh:
|
||||
consumingList.Value = c
|
||||
consumingList = consumingList.Next()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func InitConsumingList() {
|
||||
for i := 0; i < consumingList.Len(); i++ {
|
||||
consumingList.Value = nil
|
||||
consumingList = consumingList.Next()
|
||||
}
|
||||
}
|
||||
|
||||
func ConsumingList() []Consuming {
|
||||
consuming := make([]Consuming, 0, consumingList.Len())
|
||||
consumingList.Do(func(value interface{}) {
|
||||
if value != nil {
|
||||
consuming = append(consuming, value.(Consuming))
|
||||
}
|
||||
})
|
||||
return consuming
|
||||
}
|
||||
Reference in New Issue
Block a user