Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions http/codegen/templates/server_end.go.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
log.Printf(ctx, "shutting down HTTP server at %q", u.Host)

{{ comment "Shutdown gracefully with a 30s timeout." }}
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
shutdownCtx, cancel := context.WithTimeout(context.WithoutCancel(ctx), 30*time.Second)
defer cancel()

err := srv.Shutdown(ctx)
err := srv.Shutdown(shutdownCtx)
if err != nil {
log.Printf(ctx, "failed to shutdown: %v", err)
log.Printf(shutdownCtx, "failed to shutdown: %v", err)
}
}()
}
6 changes: 3 additions & 3 deletions http/codegen/testdata/golden/server-no-server.golden
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ func handleHTTPServer(ctx context.Context, u *url.URL, serviceEndpoints *service
log.Printf(ctx, "shutting down HTTP server at %q", u.Host)

// Shutdown gracefully with a 30s timeout.
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
shutdownCtx, cancel := context.WithTimeout(context.WithoutCancel(ctx), 30*time.Second)
defer cancel()

err := srv.Shutdown(ctx)
err := srv.Shutdown(shutdownCtx)
if err != nil {
log.Printf(ctx, "failed to shutdown: %v", err)
log.Printf(shutdownCtx, "failed to shutdown: %v", err)
}
}()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ func handleHTTPServer(ctx context.Context, u *url.URL, serviceEndpoints *service
log.Printf(ctx, "shutting down HTTP server at %q", u.Host)

// Shutdown gracefully with a 30s timeout.
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
shutdownCtx, cancel := context.WithTimeout(context.WithoutCancel(ctx), 30*time.Second)
defer cancel()

err := srv.Shutdown(ctx)
err := srv.Shutdown(shutdownCtx)
if err != nil {
log.Printf(ctx, "failed to shutdown: %v", err)
log.Printf(shutdownCtx, "failed to shutdown: %v", err)
}
}()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ func handleHTTPServer(ctx context.Context, u *url.URL, serviceEndpoints *service
log.Printf(ctx, "shutting down HTTP server at %q", u.Host)

// Shutdown gracefully with a 30s timeout.
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
shutdownCtx, cancel := context.WithTimeout(context.WithoutCancel(ctx), 30*time.Second)
defer cancel()

err := srv.Shutdown(ctx)
err := srv.Shutdown(shutdownCtx)
if err != nil {
log.Printf(ctx, "failed to shutdown: %v", err)
log.Printf(shutdownCtx, "failed to shutdown: %v", err)
}
}()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ func handleHTTPServer(ctx context.Context, u *url.URL, wg *sync.WaitGroup, errc
log.Printf(ctx, "shutting down HTTP server at %q", u.Host)

// Shutdown gracefully with a 30s timeout.
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
shutdownCtx, cancel := context.WithTimeout(context.WithoutCancel(ctx), 30*time.Second)
defer cancel()

err := srv.Shutdown(ctx)
err := srv.Shutdown(shutdownCtx)
if err != nil {
log.Printf(ctx, "failed to shutdown: %v", err)
log.Printf(shutdownCtx, "failed to shutdown: %v", err)
}
}()
}
Expand Down
6 changes: 3 additions & 3 deletions http/codegen/testdata/golden/server-streaming.golden
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ func handleHTTPServer(ctx context.Context, u *url.URL, streamingServiceAEndpoint
log.Printf(ctx, "shutting down HTTP server at %q", u.Host)

// Shutdown gracefully with a 30s timeout.
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
shutdownCtx, cancel := context.WithTimeout(context.WithoutCancel(ctx), 30*time.Second)
defer cancel()

err := srv.Shutdown(ctx)
err := srv.Shutdown(shutdownCtx)
if err != nil {
log.Printf(ctx, "failed to shutdown: %v", err)
log.Printf(shutdownCtx, "failed to shutdown: %v", err)
}
}()
}
Expand Down
Loading