Repository: quic-go/quic-go
Pull request #4701 (2024-10-15 02:55:59)

http3: rename Server.CloseGracefully to Shutdown
This is more consistent with standard library naming for graceful shutdown methods for HTTP/1 and HTTP/2.

codecov[bot]: ## [Codecov](https://app.codecov.io/gh/quic-go/quic-go/pull/4701?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=quic-go) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 84.47%. Comparing base [(`588b93c`)](https://app.codecov.io/gh/quic-go/quic-go/commit/588b93c817d35948a87bc29ac906151047458c25?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=quic-go) to head [(`4c3a6d6`)](https://app.codecov.io/gh/quic-go/quic-go/commit/4c3a6d68a4a91ca57c004fa27de3c7e32a0f1a02?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=quic-go).

<details><summary>Additional details and impacted files</summary>


```diff
@@            Coverage Diff             @@
##           master    #4701      +/-   ##
==========================================
- Coverage   84.52%   84.47%   -0.05%     
==========================================
  Files         151      148       -3     
  Lines       15060    14782     -278     
==========================================
- Hits        12729    12486     -243     
+ Misses       1799     1782      -17     
+ Partials      532      514      -18     
```

</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/quic-go/quic-go/pull/4701?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=quic-go).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=quic-go).


Patch:
diff --git a/http3/server.go b/http3/server.go
index 61fd125c..ac0f7177 100644
--- a/http3/server.go
+++ b/http3/server.go
@@ -684,7 +684,7 @@ func (s *Server) handleRequest(conn *connection, str quic.Stream, datagrams *dat
 				if logger == nil {
 					logger = slog.Default()
 				}
-				logger.Error("http: panic serving", "arg", p, "trace", buf)
+				logger.Error("http: panic serving", "arg", p, "trace", string(buf))
 			}
 		}()
 		handler.ServeHTTP(r, req)
@@ -747,10 +747,10 @@ func (s *Server) Close() error {
 	return err
 }
 
-// CloseGracefully shuts down the server gracefully.
+// Shutdown shuts down the server gracefully.
 // The server sends a GOAWAY frame first, then or for all running requests to complete.
-// CloseGracefully in combination with ListenAndServe() (instead of Serve()) may race if it is called before a UDP socket is established.
-func (s *Server) CloseGracefully(ctx context.Context) error {
+// Shutdown in combination with ListenAndServe() (instead of Serve()) may race if it is called before a UDP socket is established.
+func (s *Server) Shutdown(ctx context.Context) error {
 	s.mutex.Lock()
 	s.closed = true
 	// server is never used


Test patch:
diff --git a/http3/server_test.go b/http3/server_test.go
index 49206d15..c3b8c1c7 100644
--- a/http3/server_test.go
+++ b/http3/server_test.go
@@ -1200,7 +1200,7 @@ var _ = Describe("Server", func() {
 	})
 
 	It("closes gracefully", func() {
-		Expect(s.CloseGracefully(context.Background())).To(Succeed())
+		Expect(s.Shutdown(context.Background())).To(Succeed())
 	})
 
 	It("errors when listening fails", func() {
diff --git a/integrationtests/self/http_test.go b/integrationtests/self/http_test.go
index 20c41610..58f75c77 100644
--- a/integrationtests/self/http_test.go
+++ b/integrationtests/self/http_test.go
@@ -1092,7 +1092,7 @@ var _ = Describe("HTTP tests", func() {
 			go func() {
 				defer GinkgoRecover()
 				defer close(done)
-				Expect(server.CloseGracefully(context.Background())).To(Succeed())
+				Expect(server.Shutdown(context.Background())).To(Succeed())
 				fmt.Println("close gracefully done")
 			}()
 			time.Sleep(delay)
@@ -1112,7 +1112,7 @@ var _ = Describe("HTTP tests", func() {
 		// manually close the client, since we don't support
 		client.Transport.(*http3.Transport).Close()
 
-		// make sure that CloseGracefully returned
+		// make sure that Shutdown returned
 		Eventually(done).Should(BeClosed())
 	})
 
@@ -1130,7 +1130,7 @@ var _ = Describe("HTTP tests", func() {
 				ctx, cancel := context.WithTimeout(context.Background(), delay)
 				defer cancel()
 				defer close(shutdownDone)
-				Expect(server.CloseGracefully(ctx)).To(MatchError(context.DeadlineExceeded))
+				Expect(server.Shutdown(ctx)).To(MatchError(context.DeadlineExceeded))
 			}()
 			for t := range time.NewTicker(delay / 10).C {
 				if _, err := w.Write([]byte(t.String())); err != nil {
@@ -1155,7 +1155,7 @@ var _ = Describe("HTTP tests", func() {
 		Eventually(requestChan).Should(Receive(&requestDuration))
 		Expect(requestDuration).To(BeNumerically("~", delay, delay/2))
 
-		// make sure that CloseGracefully returned
+		// make sure that Shutdown returned
 		Eventually(shutdownDone).Should(BeClosed())
 	})
 })