redis / go-redis

Redis Go client
https://redis.uptrace.dev
BSD 2-Clause "Simplified" License
20.2k stars 2.38k forks source link

api XReadGroup #3194

Open ajchen-88 opened 2 days ago

ajchen-88 commented 2 days ago

Issue tracker is used for reporting bugs and discussing new features. Please use stackoverflow for supporting issues.

use XReadGroup read msg from stream:

            entries, err := client.XReadGroup(ctx1, &redis.XReadGroupArgs{
                Group:    group,
                Consumer: consumer,
                Streams:  []string{streamName, ">"},
                //Streams: []string{"mystream"},
                Count: 10,
                Block: 5000, //  Block for 5000 milliseconds
            }).Result()

Expected Behavior

Use XReadGroup to read messages from the specified consumer group, setting the Block parameter to 5000 milliseconds. If no new messages are available, the program will return after 5 seconds and continue the loop.

Current Behavior

if we set Block: 5000 the api is block and not return ,until the new message come

Possible Solution

Steps to Reproduce

            entries, err := client.XReadGroup(ctx1, &redis.XReadGroupArgs{
                Group:    group,
                Consumer: consumer,
                Streams:  []string{streamName, ">"},
                //Streams: []string{"mystream"},
                Count: 10,
                Block: 5000, //  Block for 5000 milliseconds
            }).Result()

1. 2. 3. 4.

Context (Environment)

Detailed Description

Possible Implementation