Skip to content

Commit

Permalink
[release-1.12] Add timeouts on receive adapter (#447)
Browse files Browse the repository at this point in the history
* Update adapter.go

* Update adapter.go

* Update adapter.go

* Update adapter.go

---------

Co-authored-by: David Hadas <david.hadas@gmail.com>
  • Loading branch information
knative-prow-robot and davidhadas authored Nov 24, 2023
1 parent 4bd6283 commit 1abd82a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions pkg/adapter/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"context"
"fmt"
"net/http"
"time"

cloudevents "github.com/cloudevents/sdk-go/v2"
"go.uber.org/zap"
Expand Down Expand Up @@ -79,8 +80,10 @@ func (a *gitHubAdapter) Start(ctx context.Context) error {
done := make(chan bool, 1)

server := &http.Server{
Addr: ":" + a.port,
Handler: a.newRouter(),
ReadTimeout: 10 * time.Second,
ReadHeaderTimeout: 2 * time.Second,
Addr: ":" + a.port,
Handler: a.newRouter(),
}

go common.GracefulShutdown(server, a.logger, ctx.Done(), done)
Expand Down
7 changes: 5 additions & 2 deletions pkg/mtadapter/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"context"
"fmt"
"net/http"
"time"

cloudevents "github.com/cloudevents/sdk-go/v2"
"go.uber.org/zap"
Expand Down Expand Up @@ -87,8 +88,10 @@ func NewAdapter(ctx context.Context, processed adapter.EnvConfigAccessor, ceClie
func (a *gitHubAdapter) Start(ctx context.Context) error {
// Start our multi-tenant server receiving GitHub events
server := &http.Server{
Addr: fmt.Sprintf(":%d", a.port),
Handler: a.router,
ReadTimeout: 10 * time.Second,
ReadHeaderTimeout: 2 * time.Second,
Addr: fmt.Sprintf(":%d", a.port),
Handler: a.router,
}

done := make(chan bool, 1)
Expand Down

0 comments on commit 1abd82a

Please sign in to comment.