Use a single select so if the context is canceled while we're waiting for a new GCP pubsub message, the read errors rather than remaining blocked.
When Shutdown is called on a net/http Server, it causes the Serve function to return but may still have further cleanup to do. The previous implementation sent a signal that shutdown was complete once Serve returned, which would cancel a timeout context. If the server was still actually cleaning up, we might get an error from Shutdown because the context it was using was canceled.
Close the stopped channel once Shutdown returns to trigger cleanup.
Use a single select so if the context is canceled while we're waiting for a new GCP pubsub message, the read errors rather than remaining blocked.
When
Shutdown
is called on a net/httpServer
, it causes theServe
function to return but may still have further cleanup to do. The previous implementation sent a signal that shutdown was complete onceServe
returned, which would cancel a timeout context. If the server was still actually cleaning up, we might get an error fromShutdown
because the context it was using was canceled.Close the stopped channel once
Shutdown
returns to trigger cleanup.Fixes #711.