diff --git a/cache.go b/cache.go index 5c643dba..ef5ca860 100644 --- a/cache.go +++ b/cache.go @@ -60,9 +60,9 @@ func NewSimpleCacheAdapter(store SimpleCache) CacheStore { } type adapter struct { - mu sync.RWMutex store SimpleCache flights map[string]map[string]CacheEntry + mu sync.RWMutex } func (a *adapter) Flight(key, cmd string, ttl time.Duration, now time.Time) (RedisMessage, CacheEntry) { diff --git a/cluster.go b/cluster.go index 772b5864..ef1fb5b5 100644 --- a/cluster.go +++ b/cluster.go @@ -152,8 +152,8 @@ func (c *clusterClient) lazyRefresh() { } type clusterslots struct { - reply RedisResult addr string + reply RedisResult ver int } diff --git a/message.go b/message.go index f5864b09..a59cb4dd 100644 --- a/message.go +++ b/message.go @@ -460,8 +460,8 @@ type prettyRedisResult RedisResult // MarshalJSON implements json.Marshaler interface func (r *prettyRedisResult) MarshalJSON() ([]byte, error) { type PrettyRedisResult struct { - Error string `json:"Error,omitempty"` Message *prettyRedisMessage `json:"Message,omitempty"` + Error string `json:"Error,omitempty"` } obj := PrettyRedisResult{} if r.err != nil { @@ -857,8 +857,8 @@ func (m *RedisMessage) AsZScores() ([]ZScore, error) { // ScanEntry is the element type of both SCAN, SSCAN, HSCAN and ZSCAN command response. type ScanEntry struct { - Cursor uint64 Elements []string + Cursor uint64 } // AsScanEntry check if message is a redis array/set response of length 2, and convert to ScanEntry. @@ -1271,10 +1271,10 @@ type prettyRedisMessage RedisMessage // MarshalJSON implements json.Marshaler interface func (m *prettyRedisMessage) MarshalJSON() ([]byte, error) { type PrettyRedisMessage struct { + Value any `json:"Value,omitempty"` Type string `json:"Type,omitempty"` Error string `json:"Error,omitempty"` Ttl string `json:"TTL,omitempty"` - Value any `json:"Value,omitempty"` } org := (*RedisMessage)(m) strType, ok := typeNames[m.typ] diff --git a/message_test.go b/message_test.go index d9b95ff7..8da653ba 100644 --- a/message_test.go +++ b/message_test.go @@ -1140,7 +1140,7 @@ func TestRedisResult(t *testing.T) { }}, }}, }, - expected: `{"Message":{"Type":"array","Value":[{"Type":"array","Value":[{"Type":"int64","Value":0},{"Type":"int64","Value":0},{"Type":"array","Value":[{"Type":"simple string","Value":"127.0.3.1"},{"Type":"int64","Value":3},{"Type":"simple string","Value":""}]}]}]}}`, + expected: `{"Message":{"Value":[{"Value":[{"Value":0,"Type":"int64"},{"Value":0,"Type":"int64"},{"Value":[{"Value":"127.0.3.1","Type":"simple string"},{"Value":3,"Type":"int64"},{"Value":"","Type":"simple string"}],"Type":"array"}],"Type":"array"}],"Type":"array"}}`, }, { input: RedisResult{err: errors.New("foo")}, @@ -1724,11 +1724,11 @@ func TestRedisMessage(t *testing.T) { }}, }}, }}, - expected: `{"Type":"array","Value":[{"Type":"array","Value":[{"Type":"int64","Value":0},{"Type":"int64","Value":0},{"Type":"array","Value":[{"Type":"simple string","Value":"127.0.3.1"},{"Type":"int64","Value":3},{"Type":"simple string","Value":""}]}]}]}`, + expected: `{"Value":[{"Value":[{"Value":0,"Type":"int64"},{"Value":0,"Type":"int64"},{"Value":[{"Value":"127.0.3.1","Type":"simple string"},{"Value":3,"Type":"int64"},{"Value":"","Type":"simple string"}],"Type":"array"}],"Type":"array"}],"Type":"array"}`, }, { input: RedisMessage{typ: '+', string: "127.0.3.1", ttl: [7]byte{97, 77, 74, 61, 138, 1, 0}}, - expected: `{"Type":"simple string","TTL":"2023-08-28 17:56:34.273 +0000 UTC","Value":"127.0.3.1"}`, + expected: `{"Value":"127.0.3.1","Type":"simple string","TTL":"2023-08-28 17:56:34.273 +0000 UTC"}`, }, { input: RedisMessage{typ: '0'}, @@ -1736,7 +1736,7 @@ func TestRedisMessage(t *testing.T) { }, { input: RedisMessage{typ: typeBool, integer: 1}, - expected: `{"Type":"boolean","Value":true}`, + expected: `{"Value":true,"Type":"boolean"}`, }, { input: RedisMessage{typ: typeNull}, diff --git a/mux.go b/mux.go index c9be2d8b..b3e0dd51 100644 --- a/mux.go +++ b/mux.go @@ -67,13 +67,13 @@ var _ conn = (*mux)(nil) type mux struct { init wire dead wire + clhks atomic.Value pool *pool wireFn wireFn dst string wire []atomic.Value sc []*singleconnect mu []sync.Mutex - clhks atomic.Value maxp int } diff --git a/rueidisaside/aside.go b/rueidisaside/aside.go index 41296fe2..e9add1b4 100644 --- a/rueidisaside/aside.go +++ b/rueidisaside/aside.go @@ -47,10 +47,10 @@ func NewClient(option ClientOption) (cc CacheAsideClient, err error) { type Client struct { client rueidis.Client - id string - waits map[string]chan struct{} ctx context.Context + waits map[string]chan struct{} cancel context.CancelFunc + id string ttl time.Duration mu sync.Mutex } diff --git a/rueidiscompat/command.go b/rueidiscompat/command.go index 657009cc..4234c1cb 100644 --- a/rueidiscompat/command.go +++ b/rueidiscompat/command.go @@ -2184,11 +2184,11 @@ type Node struct { Endpoint string IP string Hostname string + Role string + Health string Port int64 TLSPort int64 - Role string ReplicationOffset int64 - Health string } type ClusterShard struct { Slots []SlotRange @@ -2691,8 +2691,8 @@ type Function struct { type Library struct { Name string Engine string - Functions []Function Code string + Functions []Function } type FunctionListQuery struct { @@ -2795,14 +2795,14 @@ func formatSec(dur time.Duration) int64 { // https://github.com/redis/go-redis/blob/f994ff1cd96299a5c8029ae3403af7b17ef06e8a/gears_commands.go#L21C1-L35C2 type TFunctionLoadOptions struct { - Replace bool Config string + Replace bool } type TFunctionListOptions struct { - Withcode bool - Verbose int Library string + Verbose int + Withcode bool } type TFCallOptions struct { @@ -2948,8 +2948,8 @@ func newBFInfoCmd(res rueidis.RedisResult) *BFInfoCmd { } type ScanDump struct { - Iter int64 Data string + Iter int64 } type ScanDumpCmd struct { diff --git a/rueidiscompat/structmap.go b/rueidiscompat/structmap.go index 8eeae496..59dbc3bc 100644 --- a/rueidiscompat/structmap.go +++ b/rueidiscompat/structmap.go @@ -90,7 +90,6 @@ func newStructSpec(t reflect.Type, fieldTag string) *structSpec { // v.Set(reflect.New(v.Type().Elem())) // } // A new value is set - if f.Type.Kind() == reflect.Pointer { out.set(tag, &structField{index: i, fn: decoders[f.Type.Elem().Kind()]}) } else { @@ -106,8 +105,8 @@ func newStructSpec(t reflect.Type, fieldTag string) *structSpec { // structField represents a single field in a target struct. type structField struct { - index int fn decoderFunc + index int } //------------------------------------------------------------------------------ diff --git a/rueidisotel/trace.go b/rueidisotel/trace.go index d7eedead..ac011ccd 100644 --- a/rueidisotel/trace.go +++ b/rueidisotel/trace.go @@ -78,14 +78,14 @@ func WithTracerProvider(provider trace.TracerProvider) Option { type otelclient struct { client rueidis.Client - mAttrs []attribute.KeyValue - tAttrs []attribute.KeyValue meterProvider metric.MeterProvider tracerProvider trace.TracerProvider tracer trace.Tracer meter metric.Meter cscMiss metric.Int64Counter cscHits metric.Int64Counter + mAttrs []attribute.KeyValue + tAttrs []attribute.KeyValue } func (o *otelclient) B() rueidis.Builder { @@ -196,12 +196,12 @@ var _ rueidis.DedicatedClient = (*dedicated)(nil) type dedicated struct { client rueidis.DedicatedClient - mAttrs []attribute.KeyValue - tAttrs []attribute.KeyValue tracer trace.Tracer meter metric.Meter cscMiss metric.Int64Counter cscHits metric.Int64Counter + mAttrs []attribute.KeyValue + tAttrs []attribute.KeyValue } func (d *dedicated) B() rueidis.Builder { diff --git a/singleflight.go b/singleflight.go index 752890e7..49840cd7 100644 --- a/singleflight.go +++ b/singleflight.go @@ -7,10 +7,10 @@ import ( ) type call struct { - ch chan struct{} - mu sync.Mutex ts time.Time + ch chan struct{} cn int + mu sync.Mutex } func (c *call) Do(ctx context.Context, fn func() error) error {