Module worker

Source
Expand description

The Worker class is a convenience wrapper around the construction of the Runtime and execution of the users application.

In the future, the Worker should probably be moved to a procedural macro similar to the #[tokio::main] attribute, where we might annotate an async main function with #[dynamo::main] or similar.

The Worker::execute method is designed to be called once from main and will block the calling thread until the application completes or is canceled. The method initialized the signal handler used to trap SIGINT and SIGTERM signals and trigger a graceful shutdown.

On termination, the user application is given a graceful shutdown period of controlled by the DYN_WORKER_GRACEFUL_SHUTDOWN_TIMEOUT environment variable. If the application does not shutdown in time, the worker will terminate the application with an exit code of 911.

The default values of DYN_WORKER_GRACEFUL_SHUTDOWN_TIMEOUT differ between the development and release builds. In development, the default is DEFAULT_GRACEFUL_SHUTDOWN_TIMEOUT_DEBUG and in release, the default is DEFAULT_GRACEFUL_SHUTDOWN_TIMEOUT_RELEASE.

Structs§

Worker

Constants§

DEFAULT_GRACEFUL_SHUTDOWN_TIMEOUT_DEBUG
Default graceful shutdown timeout in seconds in debug mode
DEFAULT_GRACEFUL_SHUTDOWN_TIMEOUT_RELEASE
Default graceful shutdown timeout in seconds in release mode
DYN_WORKER_GRACEFUL_SHUTDOWN_TIMEOUT
Environment variable to control the graceful shutdown timeout