Skip to content

Commit

Permalink
What: configurable of pipeline feature
Browse files Browse the repository at this point in the history
Why:

  * can disable pipeline support by config

How:

  * nop
  • Loading branch information
mcspring committed Jul 27, 2019
1 parent d2c80c9 commit 43c4595
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
13 changes: 7 additions & 6 deletions redistest/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,13 @@ func FakeTimeoutServer(handler redis.Handler, timeout time.Duration) (srv *redis
}

srv = &redis.Server{
Handler: handler,
ReadTimeout: 3 * time.Second,
WriteTimeout: 5 * time.Second,
IdleTimeout: timeout,
EnableRetry: true,
ErrorLog: log.New(os.Stdout, "[Server Timeout] ", os.O_CREATE|os.O_WRONLY|os.O_APPEND),
Handler: handler,
ReadTimeout: 3 * time.Second,
WriteTimeout: 5 * time.Second,
IdleTimeout: timeout,
EnableRetry: true,
EnablePipeline: true,
ErrorLog: log.New(os.Stdout, "[Server Timeout] ", os.O_CREATE|os.O_WRONLY|os.O_APPEND),
}

go func() {
Expand Down
6 changes: 4 additions & 2 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ type Server struct {
// Handler invoked to handle Redis requests, must not be nil.
Handler Handler

EnableRetry bool
// features of command retry and pipeline
EnableRetry bool
EnablePipeline bool

// ReadTimeout is the maximum duration for reading the entire request,
// including the reading the argument list.
Expand Down Expand Up @@ -370,7 +372,7 @@ func (s *Server) serveCommands(c *Conn, addr string, cmds []Command, config serv

// is this a pipeline?
reqErr := req.Close()
if err == nil && reqErr == nil {
if s.EnablePipeline && err == nil && reqErr == nil {
pipeErr := s.servePipeline(c, addr, cmds, config)
if pipeErr != ErrNotPipeline {
err = pipeErr
Expand Down

0 comments on commit 43c4595

Please sign in to comment.