Bootstrap Steps
AuthGuard can run certain steps before starting the server, those are called "bootstrap steps". There are no restrictions on what those steps can do. For example, they can just log a message, connect to an external service, or create database indices.
#
Creating a StepAll you need to do is to create a class which implements BootstrapStep
interface, and
your class will be discovered automatically.
Steps are initialized after configuration and all dynamic bindings are initialized, and just like other extensions, they can have access to their own configuration or inject some of the services. For example:
#
Implementation GuidelinesWhile there are no restrictions what steps can do, there are certain guidelines that you need to be aware of
#
IndependenceSteps are completely independent and cannot be dependent on other steps. In other words, a step cannot accept another step in the constructor and the order of execution is not guaranteed either.
#
IdempotencySteps with side effects should be idempotent since they'll run every time AuthGuard is restarted.
#
ConcurrencyUnless necessary, steps should not return before all of their tasks are done. They should not schedule something in the background.
#
FailureExceptions thrown by steps are logged and they will not prevent the server from starting. For fatal failures that should halt the server a step may just force the process to terminate. This will be replaced in the future with a halt signal that makes the application shut down gracefully.