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

4.x: Global values update #9186

Open
tomas-langer opened this issue Aug 21, 2024 · 0 comments · May be fixed by #9193
Open

4.x: Global values update #9186

tomas-langer opened this issue Aug 21, 2024 · 0 comments · May be fixed by #9193
Assignees
Labels
4.x Version 4.x testing
Milestone

Comments

@tomas-langer
Copy link
Member

tomas-langer commented Aug 21, 2024

We have a few types that use static singletons to store "global" instances - configuration, service registry, metrics.

Introduce a new common type io.helidon.common.GlobalInstances to handle such singletons, that has a capability to be cleared.
This is a temporary solution - we want to move all instances to ServiceRegisty, and use the GlobalServiceRegistry to obtain them instead, as service registry can manage lifecycle and provides basic inversion of control, to obtain config etc.

Context approach was not working nicely, as you may access the global from a custom context (such as a server request), and then it would not be a global.
For testing purposes, it would be really great to have these instances bound to Helidon Context, instead of as singletons.
Proposal:
create ContextValue in io.helidon.common.context that would take care of this
~~register the values in either the global config (keeping current behavior of global singleton at runtime), or with a current context (or its parent hierarchy) that has an ID starting with test-, to support test-scoped singletons
create an extension for testing that runs everything (before all, after all, each test method, constructor) in Helidon and create a new context for each test class being executed (i.e. all methods within a class share the same context)
modify existing "globals" to use the new approach

@tomas-langer tomas-langer added testing 4.x Version 4.x labels Aug 21, 2024
@tomas-langer tomas-langer added this to the 4.2.0 milestone Aug 21, 2024
@tomas-langer tomas-langer self-assigned this Aug 21, 2024
@github-project-automation github-project-automation bot moved this to Triage in Backlog Aug 21, 2024
@tomas-langer tomas-langer moved this from Triage to Sprint Scope in Backlog Aug 22, 2024
@tomas-langer tomas-langer changed the title 4.x: Global values using Context 4.x: Global values update Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4.x Version 4.x testing
Projects
Status: Sprint Scope
Development

Successfully merging a pull request may close this issue.

1 participant