Merge branch 'master' into ankit/add-custom-label-support

This commit is contained in:
ofekshenawa 2024-01-06 15:12:23 +02:00 committed by GitHub
commit eb8522ae1d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 47 additions and 19 deletions

View File

@ -40,8 +40,8 @@ jobs:
RE_USERNAME: ${{ secrets.RE_USERNAME }} RE_USERNAME: ${{ secrets.RE_USERNAME }}
RE_PASS: ${{ secrets.RE_PASS }} RE_PASS: ${{ secrets.RE_PASS }}
RE_CLUSTER_NAME: ${{ secrets.RE_CLUSTER_NAME }} RE_CLUSTER_NAME: ${{ secrets.RE_CLUSTER_NAME }}
OSS_CLUSTER: false RE_USE_OSS_CLUSTER: false
DB_PORT: ${{ secrets.RE_DB_PORT }} RE_DB_PORT: ${{ secrets.RE_DB_PORT }}
DOCKER_ACCESS_TOKEN: ${{ secrets.DOCKER_ACCESS_TOKEN }} DOCKER_ACCESS_TOKEN: ${{ secrets.DOCKER_ACCESS_TOKEN }}
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
run: ./build.sh run: ./build.sh

View File

@ -854,7 +854,7 @@ func (cmd *StringCmd) Val() string {
} }
func (cmd *StringCmd) Result() (string, error) { func (cmd *StringCmd) Result() (string, error) {
return cmd.Val(), cmd.err return cmd.val, cmd.err
} }
func (cmd *StringCmd) Bytes() ([]byte, error) { func (cmd *StringCmd) Bytes() ([]byte, error) {
@ -958,7 +958,7 @@ func (cmd *FloatCmd) Val() float64 {
} }
func (cmd *FloatCmd) Result() (float64, error) { func (cmd *FloatCmd) Result() (float64, error) {
return cmd.Val(), cmd.Err() return cmd.val, cmd.err
} }
func (cmd *FloatCmd) String() string { func (cmd *FloatCmd) String() string {
@ -1053,7 +1053,7 @@ func (cmd *StringSliceCmd) Val() []string {
} }
func (cmd *StringSliceCmd) Result() ([]string, error) { func (cmd *StringSliceCmd) Result() ([]string, error) {
return cmd.Val(), cmd.Err() return cmd.val, cmd.err
} }
func (cmd *StringSliceCmd) String() string { func (cmd *StringSliceCmd) String() string {
@ -2715,7 +2715,7 @@ func (cmd *ZWithKeyCmd) Val() *ZWithKey {
} }
func (cmd *ZWithKeyCmd) Result() (*ZWithKey, error) { func (cmd *ZWithKeyCmd) Result() (*ZWithKey, error) {
return cmd.Val(), cmd.Err() return cmd.val, cmd.err
} }
func (cmd *ZWithKeyCmd) String() string { func (cmd *ZWithKeyCmd) String() string {
@ -2853,7 +2853,7 @@ func (cmd *ClusterSlotsCmd) Val() []ClusterSlot {
} }
func (cmd *ClusterSlotsCmd) Result() ([]ClusterSlot, error) { func (cmd *ClusterSlotsCmd) Result() ([]ClusterSlot, error) {
return cmd.Val(), cmd.Err() return cmd.val, cmd.err
} }
func (cmd *ClusterSlotsCmd) String() string { func (cmd *ClusterSlotsCmd) String() string {
@ -3313,7 +3313,7 @@ func (cmd *GeoPosCmd) Val() []*GeoPos {
} }
func (cmd *GeoPosCmd) Result() ([]*GeoPos, error) { func (cmd *GeoPosCmd) Result() ([]*GeoPos, error) {
return cmd.Val(), cmd.Err() return cmd.val, cmd.err
} }
func (cmd *GeoPosCmd) String() string { func (cmd *GeoPosCmd) String() string {
@ -3394,7 +3394,7 @@ func (cmd *CommandsInfoCmd) Val() map[string]*CommandInfo {
} }
func (cmd *CommandsInfoCmd) Result() (map[string]*CommandInfo, error) { func (cmd *CommandsInfoCmd) Result() (map[string]*CommandInfo, error) {
return cmd.Val(), cmd.Err() return cmd.val, cmd.err
} }
func (cmd *CommandsInfoCmd) String() string { func (cmd *CommandsInfoCmd) String() string {
@ -3584,7 +3584,7 @@ func (cmd *SlowLogCmd) Val() []SlowLog {
} }
func (cmd *SlowLogCmd) Result() ([]SlowLog, error) { func (cmd *SlowLogCmd) Result() ([]SlowLog, error) {
return cmd.Val(), cmd.Err() return cmd.val, cmd.err
} }
func (cmd *SlowLogCmd) String() string { func (cmd *SlowLogCmd) String() string {
@ -3683,7 +3683,7 @@ func (cmd *MapStringInterfaceCmd) Val() map[string]interface{} {
} }
func (cmd *MapStringInterfaceCmd) Result() (map[string]interface{}, error) { func (cmd *MapStringInterfaceCmd) Result() (map[string]interface{}, error) {
return cmd.Val(), cmd.Err() return cmd.val, cmd.err
} }
func (cmd *MapStringInterfaceCmd) String() string { func (cmd *MapStringInterfaceCmd) String() string {
@ -3747,7 +3747,7 @@ func (cmd *MapStringStringSliceCmd) Val() []map[string]string {
} }
func (cmd *MapStringStringSliceCmd) Result() ([]map[string]string, error) { func (cmd *MapStringStringSliceCmd) Result() ([]map[string]string, error) {
return cmd.Val(), cmd.Err() return cmd.val, cmd.err
} }
func (cmd *MapStringStringSliceCmd) String() string { func (cmd *MapStringStringSliceCmd) String() string {
@ -3811,7 +3811,7 @@ func (cmd *MapStringInterfaceSliceCmd) Val() []map[string]interface{} {
} }
func (cmd *MapStringInterfaceSliceCmd) Result() ([]map[string]interface{}, error) { func (cmd *MapStringInterfaceSliceCmd) Result() ([]map[string]interface{}, error) {
return cmd.Val(), cmd.Err() return cmd.val, cmd.err
} }
func (cmd *MapStringInterfaceSliceCmd) String() string { func (cmd *MapStringInterfaceSliceCmd) String() string {
@ -4661,7 +4661,7 @@ func (cmd *ClusterLinksCmd) Val() []ClusterLink {
} }
func (cmd *ClusterLinksCmd) Result() ([]ClusterLink, error) { func (cmd *ClusterLinksCmd) Result() ([]ClusterLink, error) {
return cmd.Val(), cmd.Err() return cmd.val, cmd.err
} }
func (cmd *ClusterLinksCmd) String() string { func (cmd *ClusterLinksCmd) String() string {
@ -4763,7 +4763,7 @@ func (cmd *ClusterShardsCmd) Val() []ClusterShard {
} }
func (cmd *ClusterShardsCmd) Result() ([]ClusterShard, error) { func (cmd *ClusterShardsCmd) Result() ([]ClusterShard, error) {
return cmd.Val(), cmd.Err() return cmd.val, cmd.err
} }
func (cmd *ClusterShardsCmd) String() string { func (cmd *ClusterShardsCmd) String() string {
@ -5236,7 +5236,7 @@ func (cmd *ACLLogCmd) Val() []*ACLLogEntry {
} }
func (cmd *ACLLogCmd) Result() ([]*ACLLogEntry, error) { func (cmd *ACLLogCmd) Result() ([]*ACLLogEntry, error) {
return cmd.Val(), cmd.Err() return cmd.val, cmd.err
} }
func (cmd *ACLLogCmd) String() string { 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) { 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 { func (cmd *InfoCmd) String() string {

View File

@ -291,6 +291,17 @@ var _ = Describe("Commands", func() {
}() }()
pipe.ClientSetInfo(ctx, libInfo) pipe.ClientSetInfo(ctx, libInfo)
}).To(Panic()) }).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() { It("should ConfigGet", func() {

View File

@ -178,7 +178,7 @@ func (cmd *JSONSliceCmd) Val() []interface{} {
} }
func (cmd *JSONSliceCmd) Result() ([]interface{}, error) { func (cmd *JSONSliceCmd) Result() ([]interface{}, error) {
return cmd.Val(), cmd.Err() return cmd.val, cmd.err
} }
func (cmd *JSONSliceCmd) readReply(rd *proto.Reader) error { func (cmd *JSONSliceCmd) readReply(rd *proto.Reader) error {
@ -252,7 +252,7 @@ func (cmd *IntPointerSliceCmd) Val() []*int64 {
} }
func (cmd *IntPointerSliceCmd) Result() ([]*int64, error) { func (cmd *IntPointerSliceCmd) Result() ([]*int64, error) {
return cmd.Val(), cmd.Err() return cmd.val, cmd.err
} }
func (cmd *IntPointerSliceCmd) readReply(rd *proto.Reader) error { func (cmd *IntPointerSliceCmd) readReply(rd *proto.Reader) error {

View File

@ -144,6 +144,9 @@ type Options struct {
// Disable set-lib on connect. Default is false. // Disable set-lib on connect. Default is false.
DisableIndentity bool DisableIndentity bool
// Add suffix to client name. Default is empty.
IdentitySuffix string
} }
func (opt *Options) init() { func (opt *Options) init() {

View File

@ -86,6 +86,8 @@ type ClusterOptions struct {
TLSConfig *tls.Config TLSConfig *tls.Config
DisableIndentity bool // Disable set-lib on connect. Default is false. DisableIndentity bool // Disable set-lib on connect. Default is false.
IdentitySuffix string // Add suffix to client name. Default is empty.
} }
func (opt *ClusterOptions) init() { func (opt *ClusterOptions) init() {
@ -291,6 +293,7 @@ func (opt *ClusterOptions) clientOptions() *Options {
ConnMaxIdleTime: opt.ConnMaxIdleTime, ConnMaxIdleTime: opt.ConnMaxIdleTime,
ConnMaxLifetime: opt.ConnMaxLifetime, ConnMaxLifetime: opt.ConnMaxLifetime,
DisableIndentity: opt.DisableIndentity, DisableIndentity: opt.DisableIndentity,
IdentitySuffix: opt.IdentitySuffix,
TLSConfig: opt.TLSConfig, TLSConfig: opt.TLSConfig,
// If ClusterSlots is populated, then we probably have an artificial // If ClusterSlots is populated, then we probably have an artificial
// cluster whose nodes are not in clustering mode (otherwise there isn't // cluster whose nodes are not in clustering mode (otherwise there isn't

View File

@ -315,6 +315,9 @@ func (c *baseClient) initConn(ctx context.Context, cn *pool.Conn) error {
if !c.opt.DisableIndentity { if !c.opt.DisableIndentity {
libName := "" libName := ""
libVer := Version() libVer := Version()
if c.opt.IdentitySuffix != "" {
libName = c.opt.IdentitySuffix
}
libInfo := LibraryInfo{LibName: &libName} libInfo := LibraryInfo{LibName: &libName}
conn.ClientSetInfo(ctx, libInfo) conn.ClientSetInfo(ctx, libInfo)
libInfo = LibraryInfo{LibVer: &libVer} libInfo = LibraryInfo{LibVer: &libVer}

View File

@ -99,6 +99,7 @@ type RingOptions struct {
Limiter Limiter Limiter Limiter
DisableIndentity bool DisableIndentity bool
IdentitySuffix string
} }
func (opt *RingOptions) init() { func (opt *RingOptions) init() {
@ -166,6 +167,7 @@ func (opt *RingOptions) clientOptions() *Options {
Limiter: opt.Limiter, Limiter: opt.Limiter,
DisableIndentity: opt.DisableIndentity, DisableIndentity: opt.DisableIndentity,
IdentitySuffix: opt.IdentitySuffix,
} }
} }

View File

@ -81,6 +81,7 @@ type FailoverOptions struct {
TLSConfig *tls.Config TLSConfig *tls.Config
DisableIndentity bool DisableIndentity bool
IdentitySuffix string
} }
func (opt *FailoverOptions) clientOptions() *Options { func (opt *FailoverOptions) clientOptions() *Options {
@ -117,6 +118,7 @@ func (opt *FailoverOptions) clientOptions() *Options {
TLSConfig: opt.TLSConfig, TLSConfig: opt.TLSConfig,
DisableIndentity: opt.DisableIndentity, DisableIndentity: opt.DisableIndentity,
IdentitySuffix: opt.IdentitySuffix,
} }
} }

View File

@ -67,6 +67,7 @@ type UniversalOptions struct {
MasterName string MasterName string
DisableIndentity bool DisableIndentity bool
IdentitySuffix string
} }
// Cluster returns cluster options created from the universal options. // Cluster returns cluster options created from the universal options.
@ -112,6 +113,7 @@ func (o *UniversalOptions) Cluster() *ClusterOptions {
TLSConfig: o.TLSConfig, TLSConfig: o.TLSConfig,
DisableIndentity: o.DisableIndentity, DisableIndentity: o.DisableIndentity,
IdentitySuffix: o.IdentitySuffix,
} }
} }
@ -157,6 +159,7 @@ func (o *UniversalOptions) Failover() *FailoverOptions {
TLSConfig: o.TLSConfig, TLSConfig: o.TLSConfig,
DisableIndentity: o.DisableIndentity, DisableIndentity: o.DisableIndentity,
IdentitySuffix: o.IdentitySuffix,
} }
} }
@ -199,6 +202,7 @@ func (o *UniversalOptions) Simple() *Options {
TLSConfig: o.TLSConfig, TLSConfig: o.TLSConfig,
DisableIndentity: o.DisableIndentity, DisableIndentity: o.DisableIndentity,
IdentitySuffix: o.IdentitySuffix,
} }
} }