diff --git a/client.go b/client.go index d3159a83..b007fa40 100644 --- a/client.go +++ b/client.go @@ -11,9 +11,9 @@ import ( type singleClient struct { conn conn - cmd Builder retryHandler retryHandler stop uint32 + cmd Builder retry bool DisableCache bool } @@ -197,9 +197,9 @@ func (c *singleClient) Close() { type dedicatedSingleClient struct { conn conn wire wire - cmd Builder retryHandler retryHandler mark uint32 + cmd Builder retry bool } diff --git a/cluster.go b/cluster.go index 4cf04e88..e7b511d0 100644 --- a/cluster.go +++ b/cluster.go @@ -23,17 +23,17 @@ var ErrSendToReplicasNotSet = errors.New("SendToReplicas must be set when Replic type clusterClient struct { pslots [16384]conn - rslots []conn - sc call + retryHandler retryHandler + opt *ClientOption rOpt *ClientOption conns map[string]connrole connFn connFn - opt *ClientOption - retryHandler retryHandler stopCh chan struct{} - cmd Builder + sc call + rslots []conn mu sync.RWMutex stop uint32 + cmd Builder retry bool } @@ -1236,15 +1236,15 @@ func (c *clusterClient) shouldRefreshRetry(err error, ctx context.Context) (addr } type dedicatedClusterClient struct { - client *clusterClient conn conn wire wire + retryHandler retryHandler + client *clusterClient pshks *pshks mu sync.Mutex cmd Builder - retryHandler retryHandler - retry bool slot uint16 + retry bool mark bool } diff --git a/pubsub.go b/pubsub.go index 72eb3c30..abbfb298 100644 --- a/pubsub.go +++ b/pubsub.go @@ -42,9 +42,9 @@ func newSubs() *subs { } type subs struct { - cnt uint64 chs map[string]chs sub map[uint64]*sub + cnt uint64 mu sync.RWMutex } diff --git a/rueidis.go b/rueidis.go index 57d8dcbd..8f1d06a7 100644 --- a/rueidis.go +++ b/rueidis.go @@ -63,15 +63,6 @@ var ( // ClientOption should be passed to NewClient to construct a Client type ClientOption struct { - // TCP & TLS - // Dialer can be used to customized how rueidis connect to a redis instance via TCP, including: - // - Timeout, the default is DefaultDialTimeout - // - KeepAlive, the default is DefaultTCPKeepAlive - // The Dialer.KeepAlive interval is used to detect an unresponsive idle tcp connection. - // OS takes at least (tcp_keepalive_probes+1)*Dialer.KeepAlive time to conclude an idle connection to be unresponsive. - // For example: DefaultTCPKeepAlive = 1s and the default of tcp_keepalive_probes on Linux is 9. - // Therefore, it takes at least 10s to kill an idle and unresponsive tcp connection on Linux by default. - Dialer net.Dialer TLSConfig *tls.Config // DialFn allows for a custom function to be used to create net.Conn connections @@ -89,18 +80,45 @@ type ClientOption struct { // NOTE: This function can't be used with ReplicaOnly option. SendToReplicas func(cmd Completed) bool + // AuthCredentialsFn allows for setting the AUTH username and password dynamically on each connection attempt to + // support rotating credentials + AuthCredentialsFn func(AuthCredentialsContext) (AuthCredentials, error) + + // RetryDelay is the function that returns the delay that should be used before retrying the attempt. + // The default is an exponential backoff with a maximum delay of 1 second. + // Only used when DisableRetry is false. + RetryDelay RetryDelayFn + + // ReplicaSelector selects a replica node when `SendToReplicas` returns true. + // If the function is set, the client will send selected command to the replica node. + // Returned value is the index of the replica node in the replicas slice. + // If the returned value is out of range, the primary node will be selected. + // If primary node does not have any replica, the primary node will be selected + // and function will not be called. + // Currently only used for cluster client. + // Each ReplicaInfo must not be modified. + // NOTE: This function can't be used with ReplicaOnly option. + // NOTE: This function must be used with SendToReplicas function. + ReplicaSelector func(slot uint16, replicas []ReplicaInfo) int + // Sentinel options, including MasterSet and Auth options Sentinel SentinelOption + // TCP & TLS + // Dialer can be used to customized how rueidis connect to a redis instance via TCP, including: + // - Timeout, the default is DefaultDialTimeout + // - KeepAlive, the default is DefaultTCPKeepAlive + // The Dialer.KeepAlive interval is used to detect an unresponsive idle tcp connection. + // OS takes at least (tcp_keepalive_probes+1)*Dialer.KeepAlive time to conclude an idle connection to be unresponsive. + // For example: DefaultTCPKeepAlive = 1s and the default of tcp_keepalive_probes on Linux is 9. + // Therefore, it takes at least 10s to kill an idle and unresponsive tcp connection on Linux by default. + Dialer net.Dialer + // Redis AUTH parameters Username string Password string ClientName string - // AuthCredentialsFn allows for setting the AUTH username and password dynamically on each connection attempt to - // support rotating credentials - AuthCredentialsFn func(AuthCredentialsContext) (AuthCredentials, error) - // ClientSetInfo will assign various info attributes to the current connection. // Note that ClientSetInfo should have exactly 2 values, the lib name and the lib version respectively. ClientSetInfo []string @@ -170,6 +188,9 @@ type ClientOption struct { // produce notable CPU usage reduction under load. Ref: https://github.com/redis/rueidis/issues/156 MaxFlushDelay time.Duration + // ClusterOption is the options for the redis cluster client. + ClusterOption ClusterOption + // DisableTCPNoDelay turns on Nagle's algorithm in pipelining mode by using conn.SetNoDelay(false). // Turning this on can result in lower p99 latencies and lower CPU usages if all your requests are small. // But if you have large requests or fast network, this might degrade the performance. Ref: https://github.com/redis/rueidis/pull/650 @@ -181,10 +202,6 @@ type ClientOption struct { ClientNoTouch bool // DisableRetry disables retrying read-only commands under network errors DisableRetry bool - // RetryDelay is the function that returns the delay that should be used before retrying the attempt. - // The default is an exponential backoff with a maximum delay of 1 second. - // Only used when DisableRetry is false. - RetryDelay RetryDelayFn // DisableCache falls back Client.DoCache/Client.DoMultiCache to Client.Do/Client.DoMulti DisableCache bool // DisableAutoPipelining makes rueidis.Client always pick a connection from the BlockingPool to serve each request. @@ -206,21 +223,6 @@ type ClientOption struct { // even if we're above the configured client eviction threshold. ClientNoEvict bool - // ClusterOption is the options for the redis cluster client. - ClusterOption ClusterOption - - // ReplicaSelector selects a replica node when `SendToReplicas` returns true. - // If the function is set, the client will send selected command to the replica node. - // Returned value is the index of the replica node in the replicas slice. - // If the returned value is out of range, the primary node will be selected. - // If primary node does not have any replica, the primary node will be selected - // and function will not be called. - // Currently only used for cluster client. - // Each ReplicaInfo must not be modified. - // NOTE: This function can't be used with ReplicaOnly option. - // NOTE: This function must be used with SendToReplicas function. - ReplicaSelector func(slot uint16, replicas []ReplicaInfo) int - // EnableReplicaAZInfo enables the client to load the replica node's availability zone. // If true, the client will set the `AZ` field in `ReplicaInfo`. EnableReplicaAZInfo bool diff --git a/rueidiscompat/command.go b/rueidiscompat/command.go index 49abd741..793bc499 100644 --- a/rueidiscompat/command.go +++ b/rueidiscompat/command.go @@ -1686,8 +1686,8 @@ type Z struct { // ZWithKey represents sorted set member including the name of the key where it was popped. type ZWithKey struct { - Z Key string + Z } // ZStore is used as an arg to ZInter/ZInterStore and ZUnion/ZUnionStore. @@ -2172,8 +2172,8 @@ type SetArgs struct { } type BitCount struct { - Start, End int64 Unit string // Stores BIT or BYTE + Start, End int64 } //type BitPos struct { @@ -2892,25 +2892,25 @@ type TDigestMergeOptions struct { } type TSOptions struct { - Retention int - ChunkSize int + Labels map[string]string Encoding string DuplicatePolicy string - Labels map[string]string + Retention int + ChunkSize int } type TSIncrDecrOptions struct { + Labels map[string]string Timestamp int64 Retention int ChunkSize int Uncompressed bool - Labels map[string]string } type TSAlterOptions struct { + Labels map[string]string + DuplicatePolicy string Retention int ChunkSize int - DuplicatePolicy string - Labels map[string]string } type TSCreateRuleOptions struct { @@ -3128,81 +3128,81 @@ func newMapStringSliceInterfaceCmd(res rueidis.RedisResult) *MapStringSliceInter } type TSRangeOptions struct { - Latest bool + Align interface{} + BucketTimestamp interface{} FilterByTS []int FilterByValue []int Count int - Align interface{} Aggregator Aggregator BucketDuration int - BucketTimestamp interface{} + Latest bool Empty bool } type TSRevRangeOptions struct { - Latest bool + Align interface{} + BucketTimestamp interface{} FilterByTS []int FilterByValue []int Count int - Align interface{} Aggregator Aggregator BucketDuration int - BucketTimestamp interface{} + Latest bool Empty bool } type TSMRangeOptions struct { - Latest bool + Align interface{} + BucketTimestamp interface{} + GroupByLabel interface{} + Reducer interface{} FilterByTS []int FilterByValue []int - WithLabels bool SelectedLabels []interface{} Count int - Align interface{} Aggregator Aggregator BucketDuration int - BucketTimestamp interface{} + Latest bool + WithLabels bool Empty bool - GroupByLabel interface{} - Reducer interface{} } type TSMRevRangeOptions struct { - Latest bool + Align interface{} + BucketTimestamp interface{} + GroupByLabel interface{} + Reducer interface{} FilterByTS []int FilterByValue []int - WithLabels bool SelectedLabels []interface{} Count int - Align interface{} Aggregator Aggregator BucketDuration int - BucketTimestamp interface{} + Latest bool + WithLabels bool Empty bool - GroupByLabel interface{} - Reducer interface{} } type TSMGetOptions struct { + SelectedLabels []interface{} Latest bool WithLabels bool - SelectedLabels []interface{} } type JSONSetArgs struct { + Value interface{} Key string Path string - Value interface{} } type JSONArrIndexArgs struct { - Start int Stop *int + Start int } type JSONArrTrimArgs struct { - Start int Stop *int + Start int } type JSONCmd struct { @@ -3408,8 +3408,8 @@ func newMapMapStringInterfaceCmd(res rueidis.RedisResult) *MapMapStringInterface } type FTAggregateResult struct { - Total int Rows []AggregateRow + Total int } type AggregateRow struct { @@ -3419,9 +3419,9 @@ type AggregateRow struct { // Each AggregateReducer have different args. // Please follow https://redis.io/docs/interact/search-and-query/search/aggregations/#supported-groupby-reducers for more information. type FTAggregateReducer struct { - Reducer SearchAggregator - Args []interface{} As string + Args []interface{} + Reducer SearchAggregator } type FTAggregateGroupBy struct { @@ -3451,21 +3451,21 @@ type FTAggregateWithCursor struct { } type FTAggregateOptions struct { - Verbatim bool - LoadAll bool + WithCursorOptions *FTAggregateWithCursor + Params map[string]interface{} + Filter string Load []FTAggregateLoad - Timeout int GroupBy []FTAggregateGroupBy SortBy []FTAggregateSortBy - SortByMax int Apply []FTAggregateApply + Timeout int + SortByMax int LimitOffset int Limit int - Filter string - WithCursor bool - WithCursorOptions *FTAggregateWithCursor - Params map[string]interface{} DialectVersion int + Verbatim bool + LoadAll bool + WithCursor bool } type AggregateCmd struct { @@ -3575,22 +3575,22 @@ func newAggregateCmd(res rueidis.RedisResult) *AggregateCmd { } type FTCreateOptions struct { - OnHash bool - OnJSON bool - Prefix []any Filter string DefaultLanguage string LanguageField string - Score float64 ScoreField string PayloadField string + Prefix []any + StopWords []any + Score float64 MaxTextFields int - NoOffsets bool Temporary int + OnHash bool + OnJSON bool + NoOffsets bool NoHL bool NoFields bool NoFreqs bool - StopWords []any SkipInitialScan bool } @@ -3679,20 +3679,20 @@ func (t SearchFieldType) String() string { } type FieldSchema struct { + VectorArgs *FTVectorArgs FieldName string As string + PhoneticMatcher string + Separator string + GeoShapeFieldType string FieldType SearchFieldType + Weight float64 Sortable bool UNF bool NoStem bool NoIndex bool - PhoneticMatcher string - Weight float64 - Separator string CaseSensitive bool WithSuffixtrie bool - VectorArgs *FTVectorArgs - GeoShapeFieldType string IndexEmpty bool IndexMissing bool } @@ -3704,16 +3704,16 @@ type FTVectorArgs struct { type FTFlatOptions struct { Type string - Dim int DistanceMetric string + Dim int InitialCapacity int BlockSize int } type FTHNSWOptions struct { Type string - Dim int DistanceMetric string + Dim int InitialCapacity int MaxEdgesPerNode int MaxAllowedEdgesPerNode int @@ -3722,9 +3722,9 @@ type FTHNSWOptions struct { } type SpellCheckTerms struct { + Dictionary string Include bool Exclude bool - Dictionary string } type FTSearchFilter struct { @@ -3735,10 +3735,10 @@ type FTSearchFilter struct { type FTSearchGeoFilter struct { FieldName string + Unit string Longitude float64 Latitude float64 Radius float64 - Unit string } type FTSearchReturn struct { @@ -3761,21 +3761,21 @@ type FTExplainOptions struct { } type IndexErrors struct { - IndexingFailures int `redis:"indexing failures"` LastIndexingError string LastIndexingErrorKey string + IndexingFailures int `redis:"indexing failures"` } type FTAttribute struct { Identifier string Attribute string Type string + PhoneticMatcher string Weight float64 Sortable bool NoStem bool NoIndex bool UNF bool - PhoneticMatcher string CaseSensitive bool WithSuffixtrie bool } @@ -3794,10 +3794,10 @@ type FieldStatistic struct { } type GCStats struct { + AverageCycleTimeMs string `redis:"average_cycle_time_ms"` BytesCollected int `redis:"bytes_collected"` TotalMsRun int `redis:"total_ms_run"` TotalCycles int `redis:"total_cycles"` - AverageCycleTimeMs string `redis:"average_cycle_time_ms"` LastRunTimeMs int `redis:"last_run_time_ms"` GCNumericTreesMissed int `redis:"gc_numeric_trees_missed"` GCBlocksDenied int `redis:"gc_blocks_denied"` @@ -3810,20 +3810,23 @@ type IndexDefinition struct { } type FTInfoResult struct { + DialectStats map[string]int `redis:"dialect_stats"` IndexErrors IndexErrors `redis:"Index Errors"` - Attributes []FTAttribute `redis:"attributes"` BytesPerRecordAvg string `redis:"bytes_per_record_avg"` - Cleaning int `redis:"cleaning"` - CursorStats CursorStats `redis:"cursor_stats"` - DialectStats map[string]int `redis:"dialect_stats"` - DocTableSizeMB float64 `redis:"doc_table_size_mb"` + IndexName string `redis:"index_name"` + OffsetBitsPerRecordAvg string `redis:"offset_bits_per_record_avg"` + OffsetsPerTermAvg string `redis:"offsets_per_term_avg"` + RecordsPerDocAvg string `redis:"records_per_doc_avg"` + Attributes []FTAttribute `redis:"attributes"` FieldStatistics []FieldStatistic `redis:"field statistics"` + IndexOptions []string `redis:"index_options"` + IndexDefinition IndexDefinition `redis:"index_definition"` GCStats GCStats `redis:"gc_stats"` + CursorStats CursorStats `redis:"cursor_stats"` + Cleaning int `redis:"cleaning"` + DocTableSizeMB float64 `redis:"doc_table_size_mb"` GeoshapesSzMB float64 `redis:"geoshapes_sz_mb"` HashIndexingFailures int `redis:"hash_indexing_failures"` - IndexDefinition IndexDefinition `redis:"index_definition"` - IndexName string `redis:"index_name"` - IndexOptions []string `redis:"index_options"` Indexing int `redis:"indexing"` InvertedSzMB float64 `redis:"inverted_sz_mb"` KeyTableSizeMB float64 `redis:"key_table_size_mb"` @@ -3832,11 +3835,8 @@ type FTInfoResult struct { NumRecords int `redis:"num_records"` NumTerms int `redis:"num_terms"` NumberOfUses int `redis:"number_of_uses"` - OffsetBitsPerRecordAvg string `redis:"offset_bits_per_record_avg"` OffsetVectorsSzMB float64 `redis:"offset_vectors_sz_mb"` - OffsetsPerTermAvg string `redis:"offsets_per_term_avg"` PercentIndexed float64 `redis:"percent_indexed"` - RecordsPerDocAvg string `redis:"records_per_doc_avg"` SortableValuesSizeMB float64 `redis:"sortable_values_size_mb"` TagOverheadSzMB float64 `redis:"tag_overhead_sz_mb"` TextOverheadSzMB float64 `redis:"text_overhead_sz_mb"` @@ -4065,8 +4065,8 @@ func newFTInfoCmd(res rueidis.RedisResult) *FTInfoCmd { } type FTSpellCheckOptions struct { - Distance int Terms *FTSpellCheckTerms + Distance int Dialect int } @@ -4082,8 +4082,8 @@ type SpellCheckResult struct { } type SpellCheckSuggestion struct { - Score float64 Suggestion string + Score float64 } type FTSpellCheckCmd struct{ baseCmd[[]SpellCheckResult] } @@ -4249,44 +4249,44 @@ func parseFTSpellCheck(data []interface{}) ([]SpellCheckResult, error) { } type Document struct { - ID string Score *float64 Payload *string SortKey *string Fields map[string]string + ID string } type FTSearchResult struct { - Total int64 Docs []Document + Total int64 } type FTSearchOptions struct { - NoContent bool - Verbatim bool - NoStopWords bool - WithScores bool - WithPayloads bool - WithSortKeys bool + Params map[string]interface{} + Language string + Expander string + Scorer string + Payload string Filters []FTSearchFilter GeoFilter []FTSearchGeoFilter InKeys []interface{} InFields []interface{} Return []FTSearchReturn + SortBy []FTSearchSortBy Slop int Timeout int - InOrder bool - Language string - Expander string - Scorer string - ExplainScore bool - Payload string - SortBy []FTSearchSortBy - SortByWithCount bool LimitOffset int Limit int - Params map[string]interface{} DialectVersion int + NoContent bool + Verbatim bool + NoStopWords bool + WithScores bool + WithPayloads bool + WithSortKeys bool + InOrder bool + ExplainScore bool + SortByWithCount bool } type FTSearchCmd struct { @@ -4639,11 +4639,16 @@ const ( // ClientInfo is redis-server ClientInfo type ClientInfo struct { - ID int64 // redis version 2.8.12, a unique 64-bit client ID Addr string // address/port of the client LAddr string // address/port of local address client connected to (bind address) - FD int64 // file descriptor corresponding to the socket Name string // the name set by the client with CLIENT SETNAME + Events string // file descriptor events (see below) + LastCmd string // cmd, last command played + User string // the authenticated username of the client + LibName string // redis version 7.2, client library name + LibVer string // redis version 7.2, client library version + ID int64 // redis version 2.8.12, a unique 64-bit client ID + FD int64 // file descriptor corresponding to the socket Age time.Duration // total duration of the connection in seconds Idle time.Duration // idle time of the connection in seconds Flags ClientFlags // client flags (see below) @@ -4663,13 +4668,8 @@ type ClientInfo struct { OutputListLength int // oll, output list length (replies are queued in this list when the buffer is full) OutputMemory int // omem, output buffer memory usage TotalMemory int // tot-mem, total memory consumed by this client in its various buffers - Events string // file descriptor events (see below) - LastCmd string // cmd, last command played - User string // the authenticated username of the client Redir int64 // client id of current client tracking redirection Resp int // redis version 7.0, client RESP protocol version - LibName string // redis version 7.2, client library name - LibVer string // redis version 7.2, client library version } type ClientInfoCmd struct { diff --git a/rueidiscompat/pubsub.go b/rueidiscompat/pubsub.go index 80990a8e..a33c88ef 100644 --- a/rueidiscompat/pubsub.go +++ b/rueidiscompat/pubsub.go @@ -114,8 +114,6 @@ func newPubSub(client rueidis.Client) *pubsub { } type pubsub struct { - mu sync.Mutex - rc rueidis.Client mc rueidis.DedicatedClient mcancel func() @@ -126,6 +124,7 @@ type pubsub struct { allCh chan any msgCh chan *Message + mu sync.Mutex } func (p *pubsub) mconn() rueidis.DedicatedClient { diff --git a/rueidislimiter/limiter.go b/rueidislimiter/limiter.go index b8bd7259..7ff4f028 100644 --- a/rueidislimiter/limiter.go +++ b/rueidislimiter/limiter.go @@ -37,8 +37,8 @@ type rateLimiter struct { type RateLimiterOption struct { ClientBuilder func(option rueidis.ClientOption) (rueidis.Client, error) - ClientOption rueidis.ClientOption KeyPrefix string + ClientOption rueidis.ClientOption Limit int Window time.Duration } diff --git a/rueidisotel/metrics.go b/rueidisotel/metrics.go index 8e96fa44..9176162e 100644 --- a/rueidisotel/metrics.go +++ b/rueidisotel/metrics.go @@ -42,12 +42,12 @@ type HistogramOption struct { } type dialMetrics struct { - addOpts []metric.AddOption - recordOpts []metric.RecordOption attempt metric.Int64Counter success metric.Int64Counter counts metric.Int64UpDownCounter latency metric.Float64Histogram + addOpts []metric.AddOption + recordOpts []metric.RecordOption } // WithHistogramOption sets the HistogramOption. diff --git a/rueidisotel/trace.go b/rueidisotel/trace.go index ec046c6c..65b37128 100644 --- a/rueidisotel/trace.go +++ b/rueidisotel/trace.go @@ -69,11 +69,11 @@ type otelclient struct { meter metric.Meter cscMiss metric.Int64Counter cscHits metric.Int64Counter + tAttrs trace.SpanStartEventOption + dbStmtFunc StatementFunc addOpts []metric.AddOption recordOpts []metric.RecordOption - tAttrs trace.SpanStartEventOption histogramOption HistogramOption - dbStmtFunc StatementFunc } func (o *otelclient) B() rueidis.Builder { diff --git a/rueidisprob/bloomfilter.go b/rueidisprob/bloomfilter.go index 95f4ff2e..aaaf8b4d 100644 --- a/rueidisprob/bloomfilter.go +++ b/rueidisprob/bloomfilter.go @@ -159,6 +159,10 @@ type BloomFilter interface { type bloomFilter struct { client rueidis.Client + addMultiScript *rueidis.Lua + + existsMultiScript *rueidis.Lua + // name is the name of the Bloom filter. // It is used as a key in the Redis. name string @@ -166,18 +170,17 @@ type bloomFilter struct { // counter is the name of the counter. counter string - // hashIterations is the number of hash functions to use. - hashIterations uint hashIterationString string - // size is the number of bits to use. - size uint + addMultiKeys []string - addMultiScript *rueidis.Lua - addMultiKeys []string + existsMultiKeys []string - existsMultiScript *rueidis.Lua - existsMultiKeys []string + // hashIterations is the number of hash functions to use. + hashIterations uint + + // size is the number of bits to use. + size uint } // NewBloomFilter creates a new Bloom filter. diff --git a/rueidisprob/countingbloomfilter.go b/rueidisprob/countingbloomfilter.go index f85524ea..79307dfd 100644 --- a/rueidisprob/countingbloomfilter.go +++ b/rueidisprob/countingbloomfilter.go @@ -153,6 +153,10 @@ type CountingBloomFilter interface { type countingBloomFilter struct { client rueidis.Client + addMultiScript *rueidis.Lua + + removeMultiScript *rueidis.Lua + // name is the name of the Counting Bloom Filter. // It is used as a key in the Redis. name string @@ -160,18 +164,17 @@ type countingBloomFilter struct { // counter is the name of the counter. counter string - // hashIterations is the number of hash functions to use. - hashIterations uint hashIterationString string - // size is the number of bits to use. - size uint + addMultiKeys []string - addMultiScript *rueidis.Lua - addMultiKeys []string + removeMultiKeys []string - removeMultiScript *rueidis.Lua - removeMultiKeys []string + // hashIterations is the number of hash functions to use. + hashIterations uint + + // size is the number of bits to use. + size uint } // NewCountingBloomFilter creates a new Counting Bloom Filter. diff --git a/rueidisprob/slidingbloomfilter.go b/rueidisprob/slidingbloomfilter.go index e7d21de4..fa94bac0 100644 --- a/rueidisprob/slidingbloomfilter.go +++ b/rueidisprob/slidingbloomfilter.go @@ -187,8 +187,9 @@ func WithReadOnlyExists(enableReadOperations bool) SlidingBloomFilterOptionFunc type slidingBloomFilter struct { client rueidis.Client - // window is the duration of the sliding window. - window time.Duration + addMultiScript *rueidis.Lua + + existsMultiScript *rueidis.Lua // Pre-calculated window half in milliseconds windowHalfMs string @@ -200,18 +201,20 @@ type slidingBloomFilter struct { // counter is the name of the counter. counter string - // hashIterations is the number of hash functions to use. - hashIterations uint hashIterationString string - // size is the number of bits to use. - size uint + addMultiKeys []string - addMultiScript *rueidis.Lua - addMultiKeys []string + existsMultiKeys []string - existsMultiScript *rueidis.Lua - existsMultiKeys []string + // window is the duration of the sliding window. + window time.Duration + + // hashIterations is the number of hash functions to use. + hashIterations uint + + // size is the number of bits to use. + size uint } // NewSlidingBloomFilter creates a new sliding window Bloom filter. diff --git a/sentinel.go b/sentinel.go index 4518b187..327eadef 100644 --- a/sentinel.go +++ b/sentinel.go @@ -42,18 +42,18 @@ func newSentinelClient(opt *ClientOption, connFn connFn, retryer retryHandler) ( type sentinelClient struct { mConn atomic.Value - mAddr string - sAddr string + sConn conn + retryHandler retryHandler connFn connFn mOpt *ClientOption sOpt *ClientOption - sConn conn sentinels *list.List + mAddr string + sAddr string sc call - retryHandler retryHandler - cmd Builder mu sync.Mutex stop uint32 + cmd Builder retry bool replica bool }