- AfterFuncWithRecover
This commit is contained in:
@@ -4,6 +4,8 @@ import (
|
||||
"fmt"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
)
|
||||
|
||||
func TestLimitSpeed(t *testing.T) {
|
||||
@@ -21,29 +23,29 @@ func TestLimitSpeed(t *testing.T) {
|
||||
TimeGapMilliSecond: 2000,
|
||||
})
|
||||
|
||||
go func() {
|
||||
utils.CallFuncAsync(func() {
|
||||
count := 0
|
||||
for {
|
||||
limiter.AccessAPI("limited1persecond")
|
||||
fmt.Printf("limited1persecond, time:%s, count:%d\n", time.Now().Format("2006-01-02 15:04:05.00000"), count)
|
||||
count++
|
||||
}
|
||||
}()
|
||||
go func() {
|
||||
})
|
||||
utils.CallFuncAsync(func() {
|
||||
count := 0
|
||||
for {
|
||||
limiter.AccessAPI("limited10per10second")
|
||||
fmt.Printf("limited10per10second, time:%s, count:%d\n", time.Now().Format("2006-01-02 15:04:05.00000"), count)
|
||||
count++
|
||||
}
|
||||
}()
|
||||
go func() {
|
||||
})
|
||||
utils.CallFuncAsync(func() {
|
||||
count := 0
|
||||
for {
|
||||
limiter.AccessAPI("otherAPI")
|
||||
fmt.Printf("otherAPI, time:%s, count:%d\n", time.Now().Format("2006-01-02 15:04:05.00000"), count)
|
||||
count++
|
||||
}
|
||||
}()
|
||||
})
|
||||
time.Sleep(30 * time.Second)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user