Skip to content

Commit

Permalink
Add MaxIdleWorkerDuration to Server. (#1183)
Browse files Browse the repository at this point in the history
  • Loading branch information
kilosliu committed Dec 26, 2021
1 parent 4517204 commit 6b55811
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions server.go
Expand Up @@ -248,6 +248,10 @@ type Server struct {
// Deprecated: Use IdleTimeout instead.
MaxKeepaliveDuration time.Duration

// MaxIdleWorkerDuration is the maximum idle time of a single worker in the underlying
// worker pool of the Server. Idle workers beyond this time will be cleared.
MaxIdleWorkerDuration time.Duration

// Period between tcp keep-alive messages.
//
// TCP keep-alive period is determined by operation system by default.
Expand Down Expand Up @@ -1757,11 +1761,12 @@ func (s *Server) Serve(ln net.Listener) error {
s.mu.Unlock()

wp := &workerPool{
WorkerFunc: s.serveConn,
MaxWorkersCount: maxWorkersCount,
LogAllErrors: s.LogAllErrors,
Logger: s.logger(),
connState: s.setState,
WorkerFunc: s.serveConn,
MaxWorkersCount: maxWorkersCount,
LogAllErrors: s.LogAllErrors,
MaxIdleWorkerDuration: s.MaxIdleWorkerDuration,
Logger: s.logger(),
connState: s.setState,
}
wp.Start()

Expand Down

0 comments on commit 6b55811

Please sign in to comment.