hfour / h4bff

H4's backend & frontend framework :cupid::wrench: https://hfour.github.io/h4bff/
MIT License
7 stars 2 forks source link

Add support for sub-apps that share singleton context #2

Closed gphfour closed 5 years ago

gphfour commented 5 years ago

Introduces support for application nesting and singleton context sharing. Basically, it means that we can have a tree-like hierarchy of locators which enables us to inherit singleton contexts and share singleton components. But, in the same time, it allows us to define separate "child" singleton contexts. It will help us with solving issues like separate RPC registries and multiple connection pools.

Maybe the most critical thing here is the lazy instantiation of the singletons. The approach taken here makes sure that the already created singletons in the parent contexts are available for usage in the child contexts, but if a singleton is not present in any parent context then it gets created on the child context that asked for it. Like this, we hide the singleton for any parent context or other contexts that are not ancestors to the context the singleton is created in.