mirror of https://github.com/go-redis/redis.git
Merge branch 'master' into ankit/add-custom-label-support
This commit is contained in:
commit
eb8522ae1d
|
@ -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
|
||||
|
|
30
command.go
30
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 {
|
||||
|
|
|
@ -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() {
|
||||
|
|
4
json.go
4
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 {
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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
|
||||
|
|
3
redis.go
3
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}
|
||||
|
|
2
ring.go
2
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,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue