Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closeable: Cellar "closeability" handling improvements #1

Open
eledhwen opened this issue Apr 17, 2021 · 0 comments
Open

Closeable: Cellar "closeability" handling improvements #1

eledhwen opened this issue Apr 17, 2021 · 0 comments

Comments

@eledhwen
Copy link
Contributor

The Cellar container class was designed with the ability to close services explicitly declared as closeable, to that end it was made to implement the AutoCloseable interface in order to be used in constructs such as:

try (Cellar cellar = factory.populate(new Cellar(), "path/to/conf.yml"))
{
    //do stuff with cellar instance
}

..and automatically release any resource that may need it upon reaching the end of the try-with.

However, in lumio-vault the Cellar is currently "dissolved" into the Vault provider mapping system, so we typically can't close the Cellar itself, or at least not in a straightforward way. As a result, the closeable feature was implemented in such a way that each instance provided by a Cellar and marked as closeable is indexed in the Vault container, and the Vault class itself was made an AutoCloseable that iterates on the indexed instances and attempts to close them.

As a result we can already do something like this:

try (Vault vault = Vault.with("path/to/conf.yml"))
{
    //do stuff with vault instance
}

As it stands, the indexing process retains all instances that were once registered into the Vault container, even if they were overwritten by another Cellar afterwards. This makes for a rather unpredictable behaviour that later versions should probably try to address.

One possibility could be to "directly" register the Cellar instances themselves (rather than dissolve their contents into the Vault), either for the sole purpose of tracking autocloseable behaviours down the line, or possibly even as a alternate strategy have a more fine-grained management of registered cellars (dynamically resolve service availability at injection time?).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant