amzn / smoke-framework

A light-weight server-side service framework written in the Swift programming language.
Apache License 2.0
1.44k stars 41 forks source link

Support async application initialisation and shutdown. #93

Closed tachyonics closed 2 years ago

tachyonics commented 2 years ago

Issue #, if available:

Description of changes: Add an option for an async server lifecycle.

  1. Add an untilShutdown() method on StandardSmokeHTTP1Server that will asynchronously wait until the server is shutdown. Internally this will store continuations from this method to be continued when the server shuts down.
  2. Add SmokeAsyncPerInvocationContextInitializer, SmokeAsyncStaticContextInitializer, SmokeAsyncServerPerInvocationContextInitializer, SmokeAsyncServerStaticContextInitializer protocols that change the shutdown() method to async. We are added new protocols to avoid breaking applications that are currently blocking in their shutdown method.
  3. Add StandardJSONSmokeAsyncServerPerInvocationContextInitializer and StandardJSONSmokeAsyncServerStaticContextInitializer protocols that extend the new more generic protocols.
  4. Add async variants of SmokeHTTP1Server+runAsOperationServer. These can also accept an initialisation method that is async.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.