mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-02-03 00:38:40 +08:00
1.use local variable i; 2.make sure limiter larger than timer period (#218)
Co-authored-by: chris <feilee1987@163.com>
This commit is contained in:
parent
e0afe0b4bb
commit
bae66c49c2
@ -29,7 +29,7 @@ func main() {
|
|||||||
|
|
||||||
store := redis.NewRedis(*rdx, *rdxType, *rdxPass)
|
store := redis.NewRedis(*rdx, *rdxType, *rdxPass)
|
||||||
fmt.Println(store.Ping())
|
fmt.Println(store.Ping())
|
||||||
lmt := limit.NewPeriodLimit(seconds, 5, store, *rdxKey)
|
lmt := limit.NewPeriodLimit(seconds+1, 5, store, *rdxKey)
|
||||||
timer := time.NewTimer(time.Second * seconds)
|
timer := time.NewTimer(time.Second * seconds)
|
||||||
quit := make(chan struct{})
|
quit := make(chan struct{})
|
||||||
defer timer.Stop()
|
defer timer.Stop()
|
||||||
@ -42,6 +42,7 @@ func main() {
|
|||||||
var wait sync.WaitGroup
|
var wait sync.WaitGroup
|
||||||
for i := 0; i < *threads; i++ {
|
for i := 0; i < *threads; i++ {
|
||||||
wait.Add(1)
|
wait.Add(1)
|
||||||
|
i := i
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
|
Loading…
Reference in New Issue
Block a user