@@ -61,16 +61,20 @@ type pool struct {
6161 httpCodeInfo sync.Pool
6262}
6363
64+ //http request count info
6465type RequestInfo struct {
6566 Url string
6667 Num uint64
6768}
69+
70+ //error count info
6871type ErrorInfo struct {
6972 Url string
7073 ErrMsg string
7174 Num uint64
7275}
7376
77+ //httpcode count info
7478type HttpCodeInfo struct {
7579 Url string
7680 Code int
@@ -96,7 +100,7 @@ type ServerStateInfo struct {
96100 //明细异常数据 - 以不带参数的访问url为key
97101 DetailErrorData * ItemContext
98102 //明细Http状态码数据 - 以HttpCode为key,例如200、500等
99- DetailHttpCodeData * ItemContext
103+ DetailHTTPCodeData * ItemContext
100104
101105 dataChan_Request chan * RequestInfo
102106 dataChan_Error chan * ErrorInfo
@@ -134,9 +138,9 @@ func (state *ServerStateInfo) ShowHtmlData() string {
134138 data += "DetailErrorData : " + jsonutil .GetJsonString (state .DetailErrorData .GetCurrentMap ())
135139 state .DetailErrorData .RUnlock ()
136140 data += "<br>"
137- state .DetailHttpCodeData .RLock ()
138- data += "DetailHttpCodeData : " + jsonutil .GetJsonString (state .DetailHttpCodeData .GetCurrentMap ())
139- state .DetailHttpCodeData .RUnlock ()
141+ state .DetailHTTPCodeData .RLock ()
142+ data += "DetailHttpCodeData : " + jsonutil .GetJsonString (state .DetailHTTPCodeData .GetCurrentMap ())
143+ state .DetailHTTPCodeData .RUnlock ()
140144 data += "</div></body></html>"
141145 return data
142146}
@@ -151,7 +155,7 @@ func (state *ServerStateInfo) QueryIntervalErrorData(queryKey string) uint64 {
151155 return state .IntervalErrorData .GetUInt64 (queryKey )
152156}
153157
154- //增加请求数
158+ //AddRequestCount 增加请求数
155159func (state * ServerStateInfo ) AddRequestCount (page string , num uint64 ) uint64 {
156160 if strings .Index (page , "/dotweb/" ) != 0 {
157161 atomic .AddUint64 (& state .TotalRequestCount , num )
@@ -160,15 +164,15 @@ func (state *ServerStateInfo) AddRequestCount(page string, num uint64) uint64 {
160164 return state .TotalRequestCount
161165}
162166
163- //增加Http状态码数据
164- func (state * ServerStateInfo ) AddHttpCodeCount (page string , code int , num uint64 ) uint64 {
167+ //AddHttpCodeCount 增加Http状态码数据
168+ func (state * ServerStateInfo ) AddTTPCodeCount (page string , code int , num uint64 ) uint64 {
165169 if strings .Index (page , "/dotweb/" ) != 0 {
166- state .addHttpCodeData (page , code , num )
170+ state .addHTTPCodeData (page , code , num )
167171 }
168172 return state .TotalErrorCount
169173}
170174
171- //增加错误数
175+ //AddErrorCount 增加错误数
172176func (state * ServerStateInfo ) AddErrorCount (page string , err error , num uint64 ) uint64 {
173177 atomic .AddUint64 (& state .TotalErrorCount , num )
174178 state .addErrorData (page , err , num )
@@ -192,7 +196,7 @@ func (state *ServerStateInfo) addErrorData(page string, err error, num uint64) {
192196 state .dataChan_Error <- info
193197}
194198
195- func (state * ServerStateInfo ) addHttpCodeData (page string , code int , num uint64 ) {
199+ func (state * ServerStateInfo ) addHTTPCodeData (page string , code int , num uint64 ) {
196200 //get from pool
197201 info := state .infoPool .httpCodeInfo .Get ().(* HttpCodeInfo )
198202 info .Url = page
@@ -244,8 +248,8 @@ func (state *ServerStateInfo) handleInfo() {
244248 {
245249 //set detail error page data
246250 key := strconv .Itoa (info .Code )
247- val := state .DetailHttpCodeData .GetUInt64 (key )
248- state .DetailHttpCodeData .Set (key , val + info .Num )
251+ val := state .DetailHTTPCodeData .GetUInt64 (key )
252+ state .DetailHTTPCodeData .Set (key , val + info .Num )
249253
250254 //put info obj
251255 state .infoPool .httpCodeInfo .Put (info )
@@ -261,7 +265,7 @@ func (state *ServerStateInfo) checkAndRemoveIntervalData() {
261265 //check IntervalRequestData
262266 state .IntervalRequestData .RLock ()
263267 if state .IntervalRequestData .Len () > 10 {
264- for k , _ := range state .IntervalRequestData .GetCurrentMap () {
268+ for k := range state .IntervalRequestData .GetCurrentMap () {
265269 if t , err := time .Parse (minuteTimeLayout , k ); err != nil {
266270 needRemoveKey = append (needRemoveKey , k )
267271 } else {
@@ -281,7 +285,7 @@ func (state *ServerStateInfo) checkAndRemoveIntervalData() {
281285 needRemoveKey = []string {}
282286 state .IntervalErrorData .RLock ()
283287 if state .IntervalErrorData .Len () > 10 {
284- for k , _ := range state .IntervalErrorData .GetCurrentMap () {
288+ for k := range state .IntervalErrorData .GetCurrentMap () {
285289 if t , err := time .Parse (minuteTimeLayout , k ); err != nil {
286290 needRemoveKey = append (needRemoveKey , k )
287291 } else {
0 commit comments