diff --git a/.github/workflows/test-redis-enterprise.yml b/.github/workflows/test-redis-enterprise.yml index d4d15514..d14766fb 100644 --- a/.github/workflows/test-redis-enterprise.yml +++ b/.github/workflows/test-redis-enterprise.yml @@ -40,8 +40,8 @@ jobs: RE_USERNAME: ${{ secrets.RE_USERNAME }} RE_PASS: ${{ secrets.RE_PASS }} RE_CLUSTER_NAME: ${{ secrets.RE_CLUSTER_NAME }} - OSS_CLUSTER: false - DB_PORT: ${{ secrets.RE_DB_PORT }} + RE_USE_OSS_CLUSTER: false + RE_DB_PORT: ${{ secrets.RE_DB_PORT }} DOCKER_ACCESS_TOKEN: ${{ secrets.DOCKER_ACCESS_TOKEN }} DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} run: ./build.sh diff --git a/command.go b/command.go index 4ef335a9..06ed86ed 100644 --- a/command.go +++ b/command.go @@ -854,7 +854,7 @@ func (cmd *StringCmd) Val() string { } func (cmd *StringCmd) Result() (string, error) { - return cmd.Val(), cmd.err + return cmd.val, cmd.err } func (cmd *StringCmd) Bytes() ([]byte, error) { @@ -958,7 +958,7 @@ func (cmd *FloatCmd) Val() float64 { } func (cmd *FloatCmd) Result() (float64, error) { - return cmd.Val(), cmd.Err() + return cmd.val, cmd.err } func (cmd *FloatCmd) String() string { @@ -1053,7 +1053,7 @@ func (cmd *StringSliceCmd) Val() []string { } func (cmd *StringSliceCmd) Result() ([]string, error) { - return cmd.Val(), cmd.Err() + return cmd.val, cmd.err } func (cmd *StringSliceCmd) String() string { @@ -2715,7 +2715,7 @@ func (cmd *ZWithKeyCmd) Val() *ZWithKey { } func (cmd *ZWithKeyCmd) Result() (*ZWithKey, error) { - return cmd.Val(), cmd.Err() + return cmd.val, cmd.err } func (cmd *ZWithKeyCmd) String() string { @@ -2853,7 +2853,7 @@ func (cmd *ClusterSlotsCmd) Val() []ClusterSlot { } func (cmd *ClusterSlotsCmd) Result() ([]ClusterSlot, error) { - return cmd.Val(), cmd.Err() + return cmd.val, cmd.err } func (cmd *ClusterSlotsCmd) String() string { @@ -3313,7 +3313,7 @@ func (cmd *GeoPosCmd) Val() []*GeoPos { } func (cmd *GeoPosCmd) Result() ([]*GeoPos, error) { - return cmd.Val(), cmd.Err() + return cmd.val, cmd.err } func (cmd *GeoPosCmd) String() string { @@ -3394,7 +3394,7 @@ func (cmd *CommandsInfoCmd) Val() map[string]*CommandInfo { } func (cmd *CommandsInfoCmd) Result() (map[string]*CommandInfo, error) { - return cmd.Val(), cmd.Err() + return cmd.val, cmd.err } func (cmd *CommandsInfoCmd) String() string { @@ -3584,7 +3584,7 @@ func (cmd *SlowLogCmd) Val() []SlowLog { } func (cmd *SlowLogCmd) Result() ([]SlowLog, error) { - return cmd.Val(), cmd.Err() + return cmd.val, cmd.err } func (cmd *SlowLogCmd) String() string { @@ -3683,7 +3683,7 @@ func (cmd *MapStringInterfaceCmd) Val() map[string]interface{} { } func (cmd *MapStringInterfaceCmd) Result() (map[string]interface{}, error) { - return cmd.Val(), cmd.Err() + return cmd.val, cmd.err } func (cmd *MapStringInterfaceCmd) String() string { @@ -3747,7 +3747,7 @@ func (cmd *MapStringStringSliceCmd) Val() []map[string]string { } func (cmd *MapStringStringSliceCmd) Result() ([]map[string]string, error) { - return cmd.Val(), cmd.Err() + return cmd.val, cmd.err } func (cmd *MapStringStringSliceCmd) String() string { @@ -3811,7 +3811,7 @@ func (cmd *MapStringInterfaceSliceCmd) Val() []map[string]interface{} { } func (cmd *MapStringInterfaceSliceCmd) Result() ([]map[string]interface{}, error) { - return cmd.Val(), cmd.Err() + return cmd.val, cmd.err } func (cmd *MapStringInterfaceSliceCmd) String() string { @@ -4661,7 +4661,7 @@ func (cmd *ClusterLinksCmd) Val() []ClusterLink { } func (cmd *ClusterLinksCmd) Result() ([]ClusterLink, error) { - return cmd.Val(), cmd.Err() + return cmd.val, cmd.err } func (cmd *ClusterLinksCmd) String() string { @@ -4763,7 +4763,7 @@ func (cmd *ClusterShardsCmd) Val() []ClusterShard { } func (cmd *ClusterShardsCmd) Result() ([]ClusterShard, error) { - return cmd.Val(), cmd.Err() + return cmd.val, cmd.err } func (cmd *ClusterShardsCmd) String() string { @@ -5236,7 +5236,7 @@ func (cmd *ACLLogCmd) Val() []*ACLLogEntry { } func (cmd *ACLLogCmd) Result() ([]*ACLLogEntry, error) { - return cmd.Val(), cmd.Err() + return cmd.val, cmd.err } func (cmd *ACLLogCmd) String() string { @@ -5337,7 +5337,7 @@ func (cmd *InfoCmd) Val() map[string]map[string]string { } func (cmd *InfoCmd) Result() (map[string]map[string]string, error) { - return cmd.Val(), cmd.Err() + return cmd.val, cmd.err } func (cmd *InfoCmd) String() string { diff --git a/commands_test.go b/commands_test.go index 4e9cf195..af8b0c62 100644 --- a/commands_test.go +++ b/commands_test.go @@ -291,6 +291,17 @@ var _ = Describe("Commands", func() { }() pipe.ClientSetInfo(ctx, libInfo) }).To(Panic()) + // Test setting the default options for libName, libName suffix and libVer + clientInfo := client.ClientInfo(ctx).Val() + Expect(clientInfo.LibName).To(ContainSubstring("go-redis(go-redis,")) + // Test setting the libName suffix in options + opt := redisOptions() + opt.IdentitySuffix = "suffix" + client2 := redis.NewClient(opt) + defer client2.Close() + clientInfo = client2.ClientInfo(ctx).Val() + Expect(clientInfo.LibName).To(ContainSubstring("go-redis(suffix,")) + }) It("should ConfigGet", func() { diff --git a/json.go b/json.go index f0d3abbd..ca731db3 100644 --- a/json.go +++ b/json.go @@ -178,7 +178,7 @@ func (cmd *JSONSliceCmd) Val() []interface{} { } func (cmd *JSONSliceCmd) Result() ([]interface{}, error) { - return cmd.Val(), cmd.Err() + return cmd.val, cmd.err } func (cmd *JSONSliceCmd) readReply(rd *proto.Reader) error { @@ -252,7 +252,7 @@ func (cmd *IntPointerSliceCmd) Val() []*int64 { } func (cmd *IntPointerSliceCmd) Result() ([]*int64, error) { - return cmd.Val(), cmd.Err() + return cmd.val, cmd.err } func (cmd *IntPointerSliceCmd) readReply(rd *proto.Reader) error { diff --git a/options.go b/options.go index 449a9252..dff52ae8 100644 --- a/options.go +++ b/options.go @@ -144,6 +144,9 @@ type Options struct { // Disable set-lib on connect. Default is false. DisableIndentity bool + + // Add suffix to client name. Default is empty. + IdentitySuffix string } func (opt *Options) init() { diff --git a/osscluster.go b/osscluster.go index b8a82d9b..9e5eb046 100644 --- a/osscluster.go +++ b/osscluster.go @@ -86,6 +86,8 @@ type ClusterOptions struct { TLSConfig *tls.Config DisableIndentity bool // Disable set-lib on connect. Default is false. + + IdentitySuffix string // Add suffix to client name. Default is empty. } func (opt *ClusterOptions) init() { @@ -291,6 +293,7 @@ func (opt *ClusterOptions) clientOptions() *Options { ConnMaxIdleTime: opt.ConnMaxIdleTime, ConnMaxLifetime: opt.ConnMaxLifetime, DisableIndentity: opt.DisableIndentity, + IdentitySuffix: opt.IdentitySuffix, TLSConfig: opt.TLSConfig, // If ClusterSlots is populated, then we probably have an artificial // cluster whose nodes are not in clustering mode (otherwise there isn't diff --git a/redis.go b/redis.go index 9792af76..4dd862b8 100644 --- a/redis.go +++ b/redis.go @@ -315,6 +315,9 @@ func (c *baseClient) initConn(ctx context.Context, cn *pool.Conn) error { if !c.opt.DisableIndentity { libName := "" libVer := Version() + if c.opt.IdentitySuffix != "" { + libName = c.opt.IdentitySuffix + } libInfo := LibraryInfo{LibName: &libName} conn.ClientSetInfo(ctx, libInfo) libInfo = LibraryInfo{LibVer: &libVer} diff --git a/ring.go b/ring.go index 0c031b5a..4ae00542 100644 --- a/ring.go +++ b/ring.go @@ -99,6 +99,7 @@ type RingOptions struct { Limiter Limiter DisableIndentity bool + IdentitySuffix string } func (opt *RingOptions) init() { @@ -166,6 +167,7 @@ func (opt *RingOptions) clientOptions() *Options { Limiter: opt.Limiter, DisableIndentity: opt.DisableIndentity, + IdentitySuffix: opt.IdentitySuffix, } } diff --git a/sentinel.go b/sentinel.go index 31ea3c77..9ace0886 100644 --- a/sentinel.go +++ b/sentinel.go @@ -81,6 +81,7 @@ type FailoverOptions struct { TLSConfig *tls.Config DisableIndentity bool + IdentitySuffix string } func (opt *FailoverOptions) clientOptions() *Options { @@ -117,6 +118,7 @@ func (opt *FailoverOptions) clientOptions() *Options { TLSConfig: opt.TLSConfig, DisableIndentity: opt.DisableIndentity, + IdentitySuffix: opt.IdentitySuffix, } } diff --git a/universal.go b/universal.go index 1e48d7b9..275bef3d 100644 --- a/universal.go +++ b/universal.go @@ -67,6 +67,7 @@ type UniversalOptions struct { MasterName string DisableIndentity bool + IdentitySuffix string } // Cluster returns cluster options created from the universal options. @@ -112,6 +113,7 @@ func (o *UniversalOptions) Cluster() *ClusterOptions { TLSConfig: o.TLSConfig, DisableIndentity: o.DisableIndentity, + IdentitySuffix: o.IdentitySuffix, } } @@ -157,6 +159,7 @@ func (o *UniversalOptions) Failover() *FailoverOptions { TLSConfig: o.TLSConfig, DisableIndentity: o.DisableIndentity, + IdentitySuffix: o.IdentitySuffix, } } @@ -199,6 +202,7 @@ func (o *UniversalOptions) Simple() *Options { TLSConfig: o.TLSConfig, DisableIndentity: o.DisableIndentity, + IdentitySuffix: o.IdentitySuffix, } }