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

Method handleInfo

core/state.go:259–312  ·  view source on GitHub ↗

handle logging

()

Source from the content-addressed store, hash-verified

257
258// handle logging
259func (state *ServerStateInfo) handleInfo() {
260 for {
261 select {
262 case info := <-state.dataChan_Request:
263 {
264 if strings.Index(info.URL, "/dotweb/") != 0 {
265 atomic.AddUint64(&state.TotalRequestCount, info.Num)
266 }
267 // fixes #63 request statistics, high memory usage when URL number is high
268 if state.EnabledDetailRequestData {
269 // ignore 404 request
270 if info.Code != http.StatusNotFound {
271 // set detail url data
272 key := strings.ToLower(info.URL)
273 val := state.DetailRequestURLData.GetUInt64(key)
274 state.DetailRequestURLData.Set(key, val+info.Num)
275 }
276 }
277 // set interval data
278 key := time.Now().Format(minuteTimeLayout)
279 val := state.IntervalRequestData.GetUInt64(key)
280 state.IntervalRequestData.Set(key, val+info.Num)
281
282 // set code data
283 key = strconv.Itoa(info.Code)
284 val = state.DetailHTTPCodeData.GetUInt64(key)
285 state.DetailHTTPCodeData.Set(key, val+info.Num)
286
287 // put info obj
288 state.infoPool.requestInfo.Put(info)
289 }
290 case info := <-state.dataChan_Error:
291 {
292 // set detail error page data
293 key := strings.ToLower(info.URL)
294 val := state.DetailErrorPageData.GetUInt64(key)
295 state.DetailErrorPageData.Set(key, val+info.Num)
296
297 // set detail error data
298 key = info.ErrMsg
299 val = state.DetailErrorData.GetUInt64(key)
300 state.DetailErrorData.Set(key, val+info.Num)
301
302 // set interval data
303 key = time.Now().Format(minuteTimeLayout)
304 val = state.IntervalErrorData.GetUInt64(key)
305 state.IntervalErrorData.Set(key, val+info.Num)
306
307 // put info obj
308 state.infoPool.errorInfo.Put(info)
309 }
310 }
311 }
312}
313
314// check and remove need to remove interval data with request and error
315func (state *ServerStateInfo) checkAndRemoveIntervalData() {

Callers 1

NewServerStateInfoFunction · 0.95

Calls 2

GetUInt64Method · 0.65
SetMethod · 0.65

Tested by

no test coverage detected