const mixinafIoc::RegistryShutdownHub
afIoc::RegistryShutdownHub
(Service) - Contribute functions to be executed on Registry shut down. All functions need to be immutable, which essentially means it can only reference const
classes.
Common usage is add listeners in your service ctor:
const class MyService { new make(RegistryShutdownHub shutdownHub) { shutdownHub.addRegistryShutdownListener |->| { doStuff() } } }
- addRegistryShutdownListener
abstract Void addRegistryShutdownListener(Str id, Str[] constraints, |->Void listener)
Adds a listener that will be notified when the registry shuts down. Note when shutdown listeners are called, the state of other dependent services is unassured. If your listener depends on other services use
addRegistryWillShutdownListener()
Errs thrown by the listener will be logged and ignored.
Each listener has a unique id (case insensitive) that is used by the constraints for ordering. Each constraint must start with the prefix
BEFORE:
orAFTER:
.config.addOrdered("Breakfast", eggs) config.addOrdered("Lunch", ["AFTER: breakfast", "BEFORE: dinner"], ham) config.addOrdered("Dinner", pie)
- addRegistryWillShutdownListener
abstract Void addRegistryWillShutdownListener(Str id, Str[] constraints, |->Void listener)
Adds a listener that will be notified when the registry shuts down. RegistryWillShutdown listeners are notified before shutdown listeners.
Errs thrown by the listener will be logged and ignored.
Each listener has a unique id (case insensitive) that is used by the constraints for ordering. Each constraint must start with the prefix
BEFORE:
orAFTER:
.config.addOrdered("Breakfast", eggs) config.addOrdered("Lunch", ["AFTER: breakfast", "BEFORE: dinner"], ham) config.addOrdered("Dinner", pie)