withPausedRequestHandling<T> method

Future<T> withPausedRequestHandling<T>(
  1. Future<T> action()
)

Stops accepting new requests on the user-facing servers (the API server and, if enabled, the web server), waits for in-flight requests to settle, runs action, then resumes request handling.

Used during runtime operations that require the pod to be quiescent - e.g. applying migrations through InsightsEndpoint.applyMigrations - to provide the same safety guarantees as a pod restart.

The operator-facing Insights server is not paused, so the call that invoked action can complete and return its result.

Implementation

Future<T> withPausedRequestHandling<T>(
  Future<T> Function() action,
) async {
  await server.shutdown();
  await _webServer?.stop();
  try {
    return await action();
  } finally {
    await _startUserFacingServers();
  }
}