MCPcopy Create free account
hub / github.com/devfeel/dotweb / NewServerStateInfo

Function NewServerStateInfo

core/state.go:24–54  ·  view source on GitHub ↗

NewServerStateInfo return ServerStateInfo which is init

()

Source from the content-addressed store, hash-verified

22
23// NewServerStateInfo return ServerStateInfo which is init
24func NewServerStateInfo() *ServerStateInfo {
25 state := &ServerStateInfo{
26 ServerStartTime: time.Now(),
27 TotalRequestCount: 0,
28 TotalErrorCount: 0,
29 CurrentRequestCount: 0,
30 IntervalRequestData: NewItemMap(),
31 DetailRequestURLData: NewItemMap(),
32 IntervalErrorData: NewItemMap(),
33 DetailErrorPageData: NewItemMap(),
34 DetailErrorData: NewItemMap(),
35 DetailHTTPCodeData: NewItemMap(),
36 dataChan_Request: make(chan *RequestInfo, 2000),
37 dataChan_Error: make(chan *ErrorInfo, 1000),
38 infoPool: &pool{
39 requestInfo: sync.Pool{
40 New: func() interface{} {
41 return &RequestInfo{}
42 },
43 },
44 errorInfo: sync.Pool{
45 New: func() interface{} {
46 return &ErrorInfo{}
47 },
48 },
49 },
50 }
51 go state.handleInfo()
52 go time.AfterFunc(time.Duration(defaultCheckTimeMinutes)*time.Minute, state.checkAndRemoveIntervalData)
53 return state
54}
55
56type pool struct {
57 requestInfo sync.Pool

Callers 2

NewFunction · 0.92
state_test.goFile · 0.85

Calls 2

handleInfoMethod · 0.95
NewItemMapFunction · 0.85

Tested by

no test coverage detected