Replies: 2 comments 1 reply
-
|
Since @Tinche bemoaned your first point too and the rounded number of svcs users is currently "one Hynek", I think I'll change the default here. As for your second point: originally svcs was agnostic about these things, the problem is that internally it needs to be cognizant of async/or not for cleanups and pings. This might be frustrating if you don't use those features, but I'm afraid being less strict about this would lead to hard-to-debug problems. :-/ |
Beta Was this translation helpful? Give feedback.
-
|
Now that the default has changed I'm gonna close this now – thanks for your thoughts! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
First of all, thanks for this library! I really like simplicity of the API. I found it to be very intuitive. I was trying to incorporate it into one of my projects and it was super easy to start using it. I am also hoping to create a plugin for Litestar to integrate
svcs(great name, btw!).I faced some friction for setting up asynchronous singletons like a connection pool, and I think it would be nice to make the following change based on my experience:
EnterasFalseby default when usingregister_valuesince those are supposed to act as singletons, we only want the cleanup to be happen when the registry closes and not when the container is closed. A connection pool would be a prime example.Another point was regarding the raising of the
TypeErrorwhen using awaitable singletons if we use theContainer.getAPI to get the singleton instance. When I'm setting connection pools or other await singletons, and I've already awaited it to ensure its initialization etc. then having to callagetwhere it calls the__await__method again and again seems a bit wasteful to me. I feel like it's fine to not check for whether the service is awaitable withinContainer.get, or maybe just raise a warning instead of an error. Personally, I would prefer it to not check for whether something is awaitable or not. I think it's the user's responsibility to make sure they're calling the right API (i.e.getoraget).Just to give some context on the above, I was not able to use
agetnorgetwhen using the connection pool provided byasyncpg. This is not an issue withsvcsbutasyncpgsince it was not returning the pool from its__await__method if the pool was already initialized as you can see here.Beta Was this translation helpful? Give feedback.
All reactions