Skip to content

Commit

Permalink
Add logic to make sure to close all http connection once the server i…
Browse files Browse the repository at this point in the history
…s closed
  • Loading branch information
alinz committed May 2, 2024
1 parent bb56f70 commit d9809f3
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@ func (h *Handler) consumerHandler(w http.ResponseWriter, r *http.Request) {
if isAutoAck {
if lastEventId != "" {
select {
case <-h.closeSignal:
return
case <-ctx.Done():
return
case events, ok := <-batch:
Expand Down Expand Up @@ -271,6 +273,8 @@ func (h *Handler) consumerHandler(w http.ResponseWriter, r *http.Request) {
}
} else {
select {
case <-h.closeSignal:
return
case <-ctx.Done():
return
case events, ok := <-batch:
Expand All @@ -292,6 +296,8 @@ func (h *Handler) consumerHandler(w http.ResponseWriter, r *http.Request) {
}
} else {
select {
case <-h.closeSignal:
return
case <-ctx.Done():
return
case events, ok := <-batch:
Expand Down

0 comments on commit d9809f3

Please sign in to comment.