Skip to content

Commit 420d095

Browse files
committed
Merge branch 'master' of github.com:manisharma/go-redis
2 parents bb43ec7 + 92e957a commit 420d095

File tree

10 files changed

+354
-27
lines changed

10 files changed

+354
-27
lines changed

.github/actions/run-tests/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ runs:
2424
2525
# Mapping of redis version to redis testing containers
2626
declare -A redis_version_mapping=(
27-
["8.4.x"]="8.4-RC1-pre"
27+
["8.4.x"]="8.4-RC1-pre.2"
2828
["8.2.x"]="8.2.1-pre"
2929
["8.0.x"]="8.0.2"
3030
)

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
4545
# Mapping of redis version to redis testing containers
4646
declare -A redis_version_mapping=(
47-
["8.4.x"]="8.4-RC1-pre"
47+
["8.4.x"]="8.4-RC1-pre.2"
4848
["8.2.x"]="8.2.1-pre"
4949
["8.0.x"]="8.0.2"
5050
)

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ GO_MOD_DIRS := $(shell find . -type f -name 'go.mod' -exec dirname {} \; | sort)
22
REDIS_VERSION ?= 8.4
33
RE_CLUSTER ?= false
44
RCE_DOCKER ?= true
5-
CLIENT_LIBS_TEST_IMAGE ?= redislabs/client-libs-test:8.4-RC1-pre
5+
CLIENT_LIBS_TEST_IMAGE ?= redislabs/client-libs-test:8.4-RC1-pre.2
66

77
docker.start:
88
export RE_CLUSTER=$(RE_CLUSTER) && \

acl_commands.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@ type ACLCmdable interface {
88
ACLLog(ctx context.Context, count int64) *ACLLogCmd
99
ACLLogReset(ctx context.Context) *StatusCmd
1010

11+
ACLGenPass(ctx context.Context, bit int) *StringCmd
12+
1113
ACLSetUser(ctx context.Context, username string, rules ...string) *StatusCmd
1214
ACLDelUser(ctx context.Context, username string) *IntCmd
15+
ACLUsers(ctx context.Context) *StringSliceCmd
16+
ACLWhoAmI(ctx context.Context) *StringCmd
1317
ACLList(ctx context.Context) *StringSliceCmd
1418

1519
ACLCat(ctx context.Context) *StringSliceCmd
@@ -65,6 +69,24 @@ func (c cmdable) ACLSetUser(ctx context.Context, username string, rules ...strin
6569
return cmd
6670
}
6771

72+
func (c cmdable) ACLGenPass(ctx context.Context, bit int) *StringCmd {
73+
cmd := NewStringCmd(ctx, "acl", "genpass")
74+
_ = c(ctx, cmd)
75+
return cmd
76+
}
77+
78+
func (c cmdable) ACLUsers(ctx context.Context) *StringSliceCmd {
79+
cmd := NewStringSliceCmd(ctx, "acl", "users")
80+
_ = c(ctx, cmd)
81+
return cmd
82+
}
83+
84+
func (c cmdable) ACLWhoAmI(ctx context.Context) *StringCmd {
85+
cmd := NewStringCmd(ctx, "acl", "whoami")
86+
_ = c(ctx, cmd)
87+
return cmd
88+
}
89+
6890
func (c cmdable) ACLList(ctx context.Context) *StringSliceCmd {
6991
cmd := NewStringSliceCmd(ctx, "acl", "list")
7092
_ = c(ctx, cmd)

acl_commands_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,21 @@ var _ = Describe("ACL user commands", Label("NonRedisEnterprise"), func() {
9292
Expect(err).NotTo(HaveOccurred())
9393
Expect(res).To(HaveLen(1))
9494
Expect(res[0]).To(ContainSubstring("default"))
95+
96+
res, err = client.ACLUsers(ctx).Result()
97+
Expect(err).NotTo(HaveOccurred())
98+
Expect(res).To(HaveLen(1))
99+
Expect(res[0]).To(Equal("default"))
100+
101+
res1, err := client.ACLWhoAmI(ctx).Result()
102+
Expect(err).NotTo(HaveOccurred())
103+
Expect(res1).To(Equal("default"))
104+
})
105+
106+
It("gen password", func() {
107+
password, err := client.ACLGenPass(ctx, 0).Result()
108+
Expect(err).NotTo(HaveOccurred())
109+
Expect(password).NotTo(BeEmpty())
95110
})
96111

97112
It("setuser and deluser", func() {

command.go

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1585,6 +1585,12 @@ func (cmd *StringStructMapCmd) readReply(rd *proto.Reader) error {
15851585
type XMessage struct {
15861586
ID string
15871587
Values map[string]interface{}
1588+
// MillisElapsedFromDelivery is the number of milliseconds since the entry was last delivered.
1589+
// Only populated when using XREADGROUP with CLAIM argument for claimed entries.
1590+
MillisElapsedFromDelivery int64
1591+
// DeliveredCount is the number of times the entry was delivered.
1592+
// Only populated when using XREADGROUP with CLAIM argument for claimed entries.
1593+
DeliveredCount int64
15881594
}
15891595

15901596
type XMessageSliceCmd struct {
@@ -1641,10 +1647,16 @@ func readXMessageSlice(rd *proto.Reader) ([]XMessage, error) {
16411647
}
16421648

16431649
func readXMessage(rd *proto.Reader) (XMessage, error) {
1644-
if err := rd.ReadFixedArrayLen(2); err != nil {
1650+
// Read array length can be 2 or 4 (with CLAIM metadata)
1651+
n, err := rd.ReadArrayLen()
1652+
if err != nil {
16451653
return XMessage{}, err
16461654
}
16471655

1656+
if n != 2 && n != 4 {
1657+
return XMessage{}, fmt.Errorf("redis: got %d elements in the XMessage array, expected 2 or 4", n)
1658+
}
1659+
16481660
id, err := rd.ReadString()
16491661
if err != nil {
16501662
return XMessage{}, err
@@ -1657,10 +1669,24 @@ func readXMessage(rd *proto.Reader) (XMessage, error) {
16571669
}
16581670
}
16591671

1660-
return XMessage{
1672+
msg := XMessage{
16611673
ID: id,
16621674
Values: v,
1663-
}, nil
1675+
}
1676+
1677+
if n == 4 {
1678+
msg.MillisElapsedFromDelivery, err = rd.ReadInt()
1679+
if err != nil {
1680+
return XMessage{}, err
1681+
}
1682+
1683+
msg.DeliveredCount, err = rd.ReadInt()
1684+
if err != nil {
1685+
return XMessage{}, err
1686+
}
1687+
}
1688+
1689+
return msg, nil
16641690
}
16651691

16661692
func stringInterfaceMapParser(rd *proto.Reader) (map[string]interface{}, error) {

0 commit comments

Comments
 (0)