Support for dependency injection?
hirrolot opened this issue · 2 comments
How DI is usually done in submillisecond
? For example, I may want to pass a configuration file, a database connection, and some other stuff of my own to some of my handlers. How can I do that?
Hi @Hirrolot,
lunatic's processes don't share any memory and each handler is running in a separate process. This means that the only way to share some data between two processes is to introduce a third one that holds the data. The best way to do this at the moment is to introduce a named process and then look it up inside each handler.
We do something similar in the logger, if you are looking for an example. The lunatic_log::init
method will spawn a process under a well defined name, and each call to info!
, debug!
and others will look up this logging process and send it a message to log something.