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
Alright, I have a classic client-server application (websockets-driven let's say). The idea is, the server is a coordinator, the client is an executor. You can imagine Celery as a good example of similar software. I'm trying to improve the current IoC implementation on the server side by replacing it with this library. Hence, we have the following dependencies on the server:
DB. Should be a singleton in the application
SessionCoordinator. Created on-demand each time the new connection appears
SessionServiceA. SessionCoordinator dependency.
SessionServiceB. SessionCoordinator dependency.
SessionProtocol. SessionCoordinator dependency.
The problem is, ServiceA, B, and Protocol should be singletons as well, but only within one SessionCoordinator. Each time we create a new SessionCoordinator, a new set of dependencies should be created.
A similar problem is covered, we can make everything a singleton, and reset it each time we want to create a new SessionCoordinator, right? But here comes a problem: DB should remain as a singleton.
I believe I can do some tricks with this library and figure it out, but chances are you have some thoughts on that right now. So my question is, how would I scope some dependencies to be a singleton per session, but keep DB as a global singleton?
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
-
Alright, I have a classic client-server application (websockets-driven let's say). The idea is, the server is a coordinator, the client is an executor. You can imagine Celery as a good example of similar software. I'm trying to improve the current IoC implementation on the server side by replacing it with this library. Hence, we have the following dependencies on the server:
The problem is, ServiceA, B, and Protocol should be singletons as well, but only within one SessionCoordinator. Each time we create a new SessionCoordinator, a new set of dependencies should be created.
A similar problem is covered, we can make everything a singleton, and reset it each time we want to create a new SessionCoordinator, right? But here comes a problem: DB should remain as a singleton.
I believe I can do some tricks with this library and figure it out, but chances are you have some thoughts on that right now. So my question is, how would I scope some dependencies to be a singleton per session, but keep DB as a global singleton?
Beta Was this translation helpful? Give feedback.
All reactions