Skip to content

Commit

Permalink
resolve issues, add timeout
Browse files Browse the repository at this point in the history
Signed-off-by: Noah Kreiger <[email protected]>
  • Loading branch information
nkreiger committed Apr 24, 2024
1 parent f0281a0 commit bfce173
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
6 changes: 4 additions & 2 deletions v2/protocol/http/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ func WithShutdownTimeout(timeout time.Duration) Option {
}
}

// WithReadTimeout sets the read timeout for the http server.
// WithReadTimeout sets the read timeout for the http server. If not set, it will default to the
// DefaultTimeout (600s). There is no maximum limit on the timeout for long-running processes.
func WithReadTimeout(timeout time.Duration) Option {
return func(p *Protocol) error {
if p == nil {
Expand All @@ -94,7 +95,8 @@ func WithReadTimeout(timeout time.Duration) Option {
}
}

// WithWriteTimeout sets the write timeout for the http server.
// WithWriteTimeout sets the write timeout for the http server. If not set, it will default to the
// DefaultTimeout (600s). There is no maximum limit on the timeout for long-running processes.
func WithWriteTimeout(timeout time.Duration) Option {
return func(p *Protocol) error {
if p == nil {
Expand Down
2 changes: 1 addition & 1 deletion v2/protocol/http/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func New(opts ...Option) (*Protocol, error) {
p.readTimeout = DefaultTimeout
}

if p.writeTimeout <= 0 {
if p.writeTimeout == 0 {
p.writeTimeout = DefaultTimeout
}

Expand Down
6 changes: 4 additions & 2 deletions v2/protocol/http/protocol_lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ func (p *Protocol) OpenInbound(ctx context.Context) error {
}

p.server = &http.Server{
Addr: listener.Addr().String(),
Handler: attachMiddleware(p.Handler, p.middleware),
Addr: listener.Addr().String(),
Handler: attachMiddleware(p.Handler, p.middleware),
ReadTimeout: p.readTimeout,
WriteTimeout: p.writeTimeout,
}

// Shutdown
Expand Down

0 comments on commit bfce173

Please sign in to comment.