-
Notifications
You must be signed in to change notification settings - Fork 49
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
Find async or non-async client #57
Comments
or the code could just try to discover whatever it prefers, catch the
exception if none found and try the other. i would not overdo it with
factories ;-)
|
Actually, I was thinking about the same 😄 But it would still be useful as a snippet somewhere. |
sure, mentioning it in the doc would make a lot of sense. maybe a
section in the client discovery doc?
|
Or we could add an argument to the find method where we allow emulated client
So if no async client is found and allowEmulation is set to true it use the SyncClient Discovery and encapsulate it with an emulated async client. WDYT ? |
The only time you use As a library author you usually do not care if the client is emulated or not, you just want the async client api. The only time you care is if you are an application author using a library that is using What I propose is that we, by default, are trying to find all real async clients and then fallback on emulated ones. |
I would rather keep it simple and let the developer handle the situation. We don't know the preference of a given code. Adding emulation related code to the discovery adds an extra dependency (client-common) and complexity. |
i agree that we should keep discovery simple. you can try to find async,
if not found find sync and wrap it, if that is what you need. finding a
sync client and hiding that by wrapping it in an emulator is doing a
disservice, and adding tons of configuration options is complicating
things too much imho.
if somebody really wants to use discovery and the emulated client (e.g.
using a library that only finds an async client and has no DI, but you
need to use it with a sync client), they can still explicitly set the
emulated client on the async discovery. so the current code does cover
all conceivable situations, but makes emulation a bit more effort for
the sake of transparency and simplicity
|
Okey. Big -1 for adding more dependency. The situation we have not covered is when I as a library developer what to emulate a async client. I believe I can write an extra strategy for that that we let the users opt-in to. |
I just added #65. I as a application author may write a strategy like that. What I want to push in is the support for a strategy to return a candidate with a closure. What do you think? That would make the discovery super flexible, but... could it be too flexible? |
do we still need to do something about this or is it good enough as is? |
We agreed to add a cookbook entry |
In some cases it doesn't matter if the installed client is sync or async (for example when known to be used in PluginClient). For that we could have a discovery which finds a sync or async client.
The text was updated successfully, but these errors were encountered: