MCPcopy
hub / github.com/redis/go-redis / floodThePool

Function floodThePool

example/maintnotifiations-pubsub/main.go:122–147  ·  view source on GitHub ↗
(ctx context.Context, rdb *redis.Client, wg *sync.WaitGroup)

Source from the content-addressed store, hash-verified

120}
121
122func 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
149func subscribe(ctx context.Context, rdb *redis.Client, topic string, subscriberId int, wg *sync.WaitGroup) {
150 defer wg.Done()

Callers 1

mainFunction · 0.85

Calls 5

ErrMethod · 0.65
PublishMethod · 0.65
AddMethod · 0.65
IncrMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected