You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I recently switched my web framework to using svcs to handle app-level services and request-level utilities.
In the patterns I'm using, the application can get addons that can add informations to existing services.
To illustrate, let's consider :
class MyStore(dict):
pass
app_registry = Registry()
app_registry.register_value(MyStore, MyStore())
Each addons, get the registry as an argument and adds to the store. Currently, I end up doing :
def my_plugin(app_registry):
store = app_registry.get_registered_service_for(MyStore).factory()
store["whatever"] = 1
It works, of course. But it looks a bit awkward. First, when we get the RegisteredService, we don't know what kind of registration it is : value, factory (or a lazy_factory, if it ever is adopted). In my add ons, I need to make sure it's an app-level singleton i'm getting. I found out that the RegisteredService contain no info about the type.
I'm guessing this is not an uncommon usecase. How do you guys deal with it ?
Could it be that i'm expecting a kind of behavior that would fall under the need of using "scopes" as dishka, aioinject or rodi do ?
Or should I just be content with my current implementation ?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello everyone.
I recently switched my web framework to using svcs to handle app-level services and request-level utilities.
In the patterns I'm using, the application can get addons that can add informations to existing services.
To illustrate, let's consider :
Each addons, get the registry as an argument and adds to the store. Currently, I end up doing :
It works, of course. But it looks a bit awkward. First, when we get the RegisteredService, we don't know what kind of registration it is : value, factory (or a lazy_factory, if it ever is adopted). In my add ons, I need to make sure it's an app-level singleton i'm getting. I found out that the RegisteredService contain no info about the type.
I'm guessing this is not an uncommon usecase. How do you guys deal with it ?
Could it be that i'm expecting a kind of behavior that would fall under the need of using "scopes" as dishka, aioinject or rodi do ?
Or should I just be content with my current implementation ?
thanks
Beta Was this translation helpful? Give feedback.
All reactions