forked from syariatifaris/throtto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetter.go
48 lines (45 loc) · 868 Bytes
/
getter.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package throtto
//GetCounts gets the current running counter request
func GetCounts() (success, fail, drop, request int64) {
if lmt == nil {
return
}
if lmt.lcount == nil {
return
}
lmt.lcount.Lock()
defer lmt.lcount.Unlock()
success = lmt.lcount.scount
fail = lmt.lcount.fcount
drop = lmt.lcount.dcount
request = lmt.lcount.count
return
}
//GetCaps gets window and threshold capacity
func GetCaps() (win float64, thres float64) {
if lmt == nil {
return
}
if lmt.lcap == nil {
return
}
lmt.lcap.Lock()
defer lmt.lcap.Unlock()
win = lmt.lcap.window
thres = lmt.lcap.thres
return
}
//GetWeights gets the current lb weight
func GetWeights() (success, fail float64) {
if lmt == nil {
return
}
if lmt.lweight == nil {
return
}
lmt.lweight.Lock()
defer lmt.lweight.Unlock()
success = lmt.lweight.sw
fail = lmt.lweight.fw
return
}