Skip to content

Commit

Permalink
feat: check for too big option.PipelineMultiplex value (#436)
Browse files Browse the repository at this point in the history
  • Loading branch information
atercattus committed Dec 28, 2023
1 parent a85dd76 commit 07e32e7
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions rueidis.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ const (
DefaultReadBuffer = 1 << 19
// DefaultWriteBuffer is the default value of bufio.NewWriterSize for each connection, which is 0.5MiB
DefaultWriteBuffer = 1 << 19
// MaxPipelineMultiplex is the maximum meaningful value for ClientOption.PipelineMultiplex
MaxPipelineMultiplex = 8
)

var (
Expand All @@ -46,6 +48,8 @@ var (
// ErrReplicaOnlyNotSupported means ReplicaOnly flag is not supported by
// current client
ErrReplicaOnlyNotSupported = errors.New("ReplicaOnly is not supported for single client")
// ErrWrongPipelineMultiplex means wrong value for ClientOption.PipelineMultiplex
ErrWrongPipelineMultiplex = errors.New("ClientOption.PipelineMultiplex must not be bigger than MaxPipelineMultiplex")
)

// ClientOption should be passed to NewClient to construct a Client
Expand Down Expand Up @@ -314,6 +318,9 @@ func NewClient(option ClientOption) (client Client, err error) {
option.InitAddress[i], option.InitAddress[j] = option.InitAddress[j], option.InitAddress[i]
})
}
if option.PipelineMultiplex > MaxPipelineMultiplex {
return nil, ErrWrongPipelineMultiplex
}
if option.Sentinel.MasterSet != "" {
option.PipelineMultiplex = singleClientMultiplex(option.PipelineMultiplex)
return newSentinelClient(&option, makeConn)
Expand Down

0 comments on commit 07e32e7

Please sign in to comment.