| 120 | } |
| 121 | |
| 122 | func floodThePool(ctx context.Context, rdb *redis.Client, wg *sync.WaitGroup) { |
| 123 | defer wg.Done() |
| 124 | for { |
| 125 | select { |
| 126 | case <-ctx.Done(): |
| 127 | return |
| 128 | default: |
| 129 | } |
| 130 | err := rdb.Publish(ctx, "test2", "hello").Err() |
| 131 | if err != nil { |
| 132 | if err.Error() != "context canceled" { |
| 133 | log.Println("publish error:", err) |
| 134 | cntErrors.Add(1) |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | err = rdb.Incr(ctx, "published").Err() |
| 139 | if err != nil { |
| 140 | if err.Error() != "context canceled" { |
| 141 | log.Println("incr error:", err) |
| 142 | cntErrors.Add(1) |
| 143 | } |
| 144 | } |
| 145 | time.Sleep(10 * time.Nanosecond) |
| 146 | } |
| 147 | } |
| 148 | |
| 149 | func subscribe(ctx context.Context, rdb *redis.Client, topic string, subscriberId int, wg *sync.WaitGroup) { |
| 150 | defer wg.Done() |