Skip to content

Commit

Permalink
chore: apply fieldalignment
Browse files Browse the repository at this point in the history
  • Loading branch information
rueian committed Nov 13, 2023
1 parent 72146ca commit bb1f91a
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 27 deletions.
2 changes: 1 addition & 1 deletion cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ func (c *clusterClient) lazyRefresh() {
}

type clusterslots struct {
reply RedisResult
addr string
reply RedisResult
ver int
}

Expand Down
6 changes: 3 additions & 3 deletions message.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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]
Expand Down
8 changes: 4 additions & 4 deletions message_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")},
Expand Down Expand Up @@ -1724,19 +1724,19 @@ 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'},
expected: `{"Type":"unknown"}`,
},
{
input: RedisMessage{typ: typeBool, integer: 1},
expected: `{"Type":"boolean","Value":true}`,
expected: `{"Value":true,"Type":"boolean"}`,
},
{
input: RedisMessage{typ: typeNull},
Expand Down
2 changes: 1 addition & 1 deletion mux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
4 changes: 2 additions & 2 deletions rueidisaside/aside.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
14 changes: 7 additions & 7 deletions rueidiscompat/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -2691,8 +2691,8 @@ type Function struct {
type Library struct {
Name string
Engine string
Functions []Function
Code string
Functions []Function
}

type FunctionListQuery struct {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -2948,8 +2948,8 @@ func newBFInfoCmd(res rueidis.RedisResult) *BFInfoCmd {
}

type ScanDump struct {
Iter int64
Data string
Iter int64
}

type ScanDumpCmd struct {
Expand Down
3 changes: 1 addition & 2 deletions rueidiscompat/structmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}

//------------------------------------------------------------------------------
Expand Down
8 changes: 4 additions & 4 deletions rueidisotel/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions singleflight.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit bb1f91a

Please sign in to comment.