From f80c5f3ff81685d289ce2b8aabdfac36badf0c07 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 2 Aug 2024 02:08:33 +0000 Subject: [PATCH] Renovate: Update github.com/sapcc --- go.mod | 4 ++-- go.sum | 8 ++++---- .../github.com/sapcc/go-bits/httpext/server.go | 17 ++++++++++++++--- vendor/modules.txt | 4 ++-- 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/go.mod b/go.mod index 53378d9..c6c9d80 100644 --- a/go.mod +++ b/go.mod @@ -6,8 +6,8 @@ require ( github.com/alecthomas/kong v0.9.0 github.com/gorilla/mux v1.8.1 github.com/prometheus/client_golang v1.19.1 - github.com/sapcc/go-api-declarations v1.12.0 - github.com/sapcc/go-bits v0.0.0-20240725082021-261f0bf53c79 + github.com/sapcc/go-api-declarations v1.12.1 + github.com/sapcc/go-bits v0.0.0-20240801093859-8ef04d19f38d go.uber.org/automaxprocs v1.5.3 ) diff --git a/go.sum b/go.sum index d1d754e..801d4b0 100644 --- a/go.sum +++ b/go.sum @@ -34,10 +34,10 @@ github.com/prometheus/common v0.55.0 h1:KEi6DK7lXW/m7Ig5i47x0vRzuBsHuvJdi5ee6Y3G github.com/prometheus/common v0.55.0/go.mod h1:2SECS4xJG1kd8XF9IcM1gMX6510RAEL65zxzNImwdc8= github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc= github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk= -github.com/sapcc/go-api-declarations v1.12.0 h1:lFgLbufRQ+rZOaJctF0Tw+6KWYvtRhnpVimtaNzc2So= -github.com/sapcc/go-api-declarations v1.12.0/go.mod h1:83R3hTANhuRXt/pXDby37IJetw8l7DG41s33Tp9NXxI= -github.com/sapcc/go-bits v0.0.0-20240725082021-261f0bf53c79 h1:+UVZQpUPdlDoKyiAQ5SgvE/zxQ1AF/hlan+wD8V1Qqg= -github.com/sapcc/go-bits v0.0.0-20240725082021-261f0bf53c79/go.mod h1:AWYXw+xIyaouPyJj6s1M66t/Txw0r0ft6X5Pgljg/R0= +github.com/sapcc/go-api-declarations v1.12.1 h1:1/QfRD7D4OGfZv3F1HGFwwAJtiuYUvjqE/XhE4UnpCc= +github.com/sapcc/go-api-declarations v1.12.1/go.mod h1:83R3hTANhuRXt/pXDby37IJetw8l7DG41s33Tp9NXxI= +github.com/sapcc/go-bits v0.0.0-20240801093859-8ef04d19f38d h1:J6hg859uZMKn3aEQhEZBdUMXvbKIl3I7t7kNM4qeOps= +github.com/sapcc/go-bits v0.0.0-20240801093859-8ef04d19f38d/go.mod h1:GDqhmlHFdWGzbJlpNinE2f21GOvOKe5tt2N1rOix4I0= github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8= github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= diff --git a/vendor/github.com/sapcc/go-bits/httpext/server.go b/vendor/github.com/sapcc/go-bits/httpext/server.go index 379582a..c9e9903 100644 --- a/vendor/github.com/sapcc/go-bits/httpext/server.go +++ b/vendor/github.com/sapcc/go-bits/httpext/server.go @@ -72,7 +72,18 @@ func ContextWithSIGINT(ctx context.Context, delay time.Duration) context.Context func ListenAndServeContext(ctx context.Context, addr string, handler http.Handler) error { logg.Info("Listening on %s...", addr) server := &http.Server{Addr: addr, Handler: handler} + return listenAndServeContext(ctx, server, func() error { return server.ListenAndServe() }) +} + +// ListenAndServeTLSContext is a wrapper around http.ListenAndServeTLS() that additionally +// shuts down the HTTP server gracefully when the context expires, or if an error occurs. +func ListenAndServeTLSContext(ctx context.Context, addr, certFile, keyFile string, handler http.Handler) error { + logg.Info("Listening on %s...", addr) + server := &http.Server{Addr: addr, Handler: handler} + return listenAndServeContext(ctx, server, func() error { return server.ListenAndServeTLS(certFile, keyFile) }) +} +func listenAndServeContext(ctx context.Context, server *http.Server, listenAndServe func() error) error { // waitForServerShutdown channel serves two purposes: // 1. It is used to block until server.Shutdown() returns to prevent // program from exiting prematurely. This is because when Shutdown is @@ -95,13 +106,13 @@ func ListenAndServeContext(ctx context.Context, addr string, handler http.Handle waitForServerShutdown <- err }() - listenAndServeErr := server.ListenAndServe() - if listenAndServeErr != http.ErrServerClosed { + listenAndServeErr := listenAndServe() + if listenAndServeErr != http.ErrServerClosed { //nolint:errorlint // errorlint usually understands that this error is returned directly from ListenAndServe(), but the indirection confuses it shutdownServer <- struct{}{} } shutdownErr := <-waitForServerShutdown - if listenAndServeErr == http.ErrServerClosed { + if listenAndServeErr == http.ErrServerClosed { //nolint:errorlint // same as above return addPrefix(shutdownErr, "ListenAndServeContext: could not shutdown HTTP server") } diff --git a/vendor/modules.txt b/vendor/modules.txt index 05505b5..797cb97 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -30,10 +30,10 @@ github.com/prometheus/common/model github.com/prometheus/procfs github.com/prometheus/procfs/internal/fs github.com/prometheus/procfs/internal/util -# github.com/sapcc/go-api-declarations v1.12.0 +# github.com/sapcc/go-api-declarations v1.12.1 ## explicit; go 1.21 github.com/sapcc/go-api-declarations/bininfo -# github.com/sapcc/go-bits v0.0.0-20240725082021-261f0bf53c79 +# github.com/sapcc/go-bits v0.0.0-20240801093859-8ef04d19f38d ## explicit; go 1.22 github.com/sapcc/go-bits/assert github.com/sapcc/go-bits/httpapi