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:
ofekshenawa 2024-02-15 12:48:56 +02:00 committed by GitHub
parent 8afc2b9314
commit 35de49a8da
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 13 additions and 12 deletions

View File

@ -2105,7 +2105,7 @@ var _ = Describe("Commands", func() {
logEntries, err := client.ACLLog(ctx, 10).Result()
Expect(err).NotTo(HaveOccurred())
Expect(len(logEntries)).To(Equal(4))
Expect(len(logEntries)).To(Equal(1))
for _, entry := range logEntries {
Expect(entry.Reason).To(Equal("command"))
@ -2121,7 +2121,7 @@ var _ = Describe("Commands", func() {
limitedLogEntries, err := client.ACLLog(ctx, 2).Result()
Expect(err).NotTo(HaveOccurred())
Expect(len(limitedLogEntries)).To(Equal(2))
Expect(len(limitedLogEntries)).To(Equal(1))
})
It("should ACL LOG RESET", Label("NonRedisEnterprise"), func() {

View File

@ -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.
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 {
if !auth && password != "" {
if username != "" {
@ -343,6 +334,16 @@ func (c *baseClient) initConn(ctx context.Context, cn *pool.Conn) error {
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
})
if err != nil {

View File

@ -324,7 +324,7 @@ var _ = Describe("SentinelAclAuth", func() {
BeforeEach(func() {
authCmd := redis.NewStatusCmd(ctx, "ACL", "SETUSER", aclSentinelUsername, "ON",
">"+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")
for _, process := range sentinels() {