mirror of https://github.com/go-redis/redis.git
Speed up connections by sending SetInfo via a pipeline (#2880)
* Send Client SetInfo via pipe * Fix ACL test * Add client set info to acl command rules
This commit is contained in:
parent
8afc2b9314
commit
35de49a8da
|
@ -2105,7 +2105,7 @@ var _ = Describe("Commands", func() {
|
||||||
|
|
||||||
logEntries, err := client.ACLLog(ctx, 10).Result()
|
logEntries, err := client.ACLLog(ctx, 10).Result()
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(len(logEntries)).To(Equal(4))
|
Expect(len(logEntries)).To(Equal(1))
|
||||||
|
|
||||||
for _, entry := range logEntries {
|
for _, entry := range logEntries {
|
||||||
Expect(entry.Reason).To(Equal("command"))
|
Expect(entry.Reason).To(Equal("command"))
|
||||||
|
@ -2121,7 +2121,7 @@ var _ = Describe("Commands", func() {
|
||||||
|
|
||||||
limitedLogEntries, err := client.ACLLog(ctx, 2).Result()
|
limitedLogEntries, err := client.ACLLog(ctx, 2).Result()
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(len(limitedLogEntries)).To(Equal(2))
|
Expect(len(limitedLogEntries)).To(Equal(1))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("should ACL LOG RESET", Label("NonRedisEnterprise"), func() {
|
It("should ACL LOG RESET", Label("NonRedisEnterprise"), func() {
|
||||||
|
|
19
redis.go
19
redis.go
|
@ -312,16 +312,7 @@ func (c *baseClient) initConn(ctx context.Context, cn *pool.Conn) error {
|
||||||
// difficult to rely on error strings to determine all results.
|
// difficult to rely on error strings to determine all results.
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if !c.opt.DisableIndentity {
|
|
||||||
libName := ""
|
|
||||||
libVer := Version()
|
|
||||||
|
|
||||||
if c.opt.IdentitySuffix != "" {
|
|
||||||
libName = c.opt.IdentitySuffix
|
|
||||||
}
|
|
||||||
conn.ClientSetInfo(ctx, WithLibraryName(libName))
|
|
||||||
conn.ClientSetInfo(ctx, WithLibraryVersion(libVer))
|
|
||||||
}
|
|
||||||
_, err := conn.Pipelined(ctx, func(pipe Pipeliner) error {
|
_, err := conn.Pipelined(ctx, func(pipe Pipeliner) error {
|
||||||
if !auth && password != "" {
|
if !auth && password != "" {
|
||||||
if username != "" {
|
if username != "" {
|
||||||
|
@ -343,6 +334,16 @@ func (c *baseClient) initConn(ctx context.Context, cn *pool.Conn) error {
|
||||||
pipe.ClientSetName(ctx, c.opt.ClientName)
|
pipe.ClientSetName(ctx, c.opt.ClientName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !c.opt.DisableIndentity {
|
||||||
|
libName := ""
|
||||||
|
libVer := Version()
|
||||||
|
if c.opt.IdentitySuffix != "" {
|
||||||
|
libName = c.opt.IdentitySuffix
|
||||||
|
}
|
||||||
|
pipe.ClientSetInfo(ctx, WithLibraryName(libName))
|
||||||
|
pipe.ClientSetInfo(ctx, WithLibraryVersion(libVer))
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -324,7 +324,7 @@ var _ = Describe("SentinelAclAuth", func() {
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
authCmd := redis.NewStatusCmd(ctx, "ACL", "SETUSER", aclSentinelUsername, "ON",
|
authCmd := redis.NewStatusCmd(ctx, "ACL", "SETUSER", aclSentinelUsername, "ON",
|
||||||
">"+aclSentinelPassword, "-@all", "+auth", "+client|getname", "+client|id", "+client|setname",
|
">"+aclSentinelPassword, "-@all", "+auth", "+client|getname", "+client|id", "+client|setname",
|
||||||
"+command", "+hello", "+ping", "+role", "+sentinel|get-master-addr-by-name", "+sentinel|master",
|
"+command", "+hello", "+ping", "+client|setinfo", "+role", "+sentinel|get-master-addr-by-name", "+sentinel|master",
|
||||||
"+sentinel|myid", "+sentinel|replicas", "+sentinel|sentinels")
|
"+sentinel|myid", "+sentinel|replicas", "+sentinel|sentinels")
|
||||||
|
|
||||||
for _, process := range sentinels() {
|
for _, process := range sentinels() {
|
||||||
|
|
Loading…
Reference in New Issue