From d9809f39632e43a59b200e754a7cf3c06213bfa0 Mon Sep 17 00:00:00 2001 From: Ali Najafizadeh Date: Thu, 2 May 2024 10:52:38 -0400 Subject: [PATCH] Add logic to make sure to close all http connection once the server is closed --- server/server.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/server/server.go b/server/server.go index 74baef0..3933a94 100644 --- a/server/server.go +++ b/server/server.go @@ -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: @@ -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: @@ -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: