-
Notifications
You must be signed in to change notification settings - Fork 567
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
Comments
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
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 theGlobalServiceRegistry
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:createContextValue
inio.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 withtest-
, to support test-scoped singletonscreate 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 approachThe text was updated successfully, but these errors were encountered: