snapshot of https://github.com/centrifugal/centrifugo.git (master, 2026-09-16; blobs > 131072B omitted)
This commit is contained in:
22
internal/redisqueue/stream.go
Normal file
22
internal/redisqueue/stream.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package redisqueue
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
|
||||
"github.com/centrifugal/centrifugo/v6/internal/redisshard"
|
||||
|
||||
"github.com/redis/rueidis"
|
||||
)
|
||||
|
||||
func CreateConsumerGroup(rds *redisshard.RedisShard, stream, groupName, id string) error {
|
||||
res := rds.RunOp(func(client rueidis.Client) rueidis.RedisResult {
|
||||
cmd := client.B().XgroupCreate().Key(stream).Group(groupName).Id(id).Mkstream().Build()
|
||||
return client.Do(context.Background(), cmd)
|
||||
})
|
||||
if res.Error() != nil && strings.Contains(res.Error().Error(), "BUSYGROUP") {
|
||||
// Group already exists.
|
||||
return nil
|
||||
}
|
||||
return res.Error()
|
||||
}
|
||||
Reference in New Issue
Block a user