-
Notifications
You must be signed in to change notification settings - Fork 296
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
Question: What's the deal with ConfigureAwait(false) in examples? #1601
Comments
See the explanation here: https://devblogs.microsoft.com/dotnet/configureawait-faq/#what-does-configureawait(false)-do |
And the decision on sync vs. async really has to do with your goals around performance. Sync is easier, async is more performant in large-scale applications. For a simple client, I would just stick with sync methods. |
could you also paste the ssl error, i don't think async would have some negative effects on it |
I think you missed the mark linking that article, it is well known what ConfigureAwait(false) does in a context of a library - so I wouldn't be surprised or asking about it if I saw being used inside the Kubernetes client implementation but here the question is specifically about the examples, so we are talking about our use of the client itself (not the internals of it) and in that context ConfigureAwait(false) is not something we should see in the examples.
Difficulty of use sync vs async here, when this is library usage we're dealing with? very little difference here using sync version vs doing
Well, the examples author decided not to. Instead, in the example I linked the Namespace listing uses both sync and async versions of the client - it uses sync version for ListNamespaces but then goes on to use ReadNamespaceAsync and to me that is just an odd thing to do in a single snippet of code - and it repeats across all the examples. So I'll ask is there a reasoning to this kind of use in the examples or is it just an oversight? It'd help if one of the client authors and/or example authors chimed in. |
Examples are written (and re-written) by various people at various times, you can look at the git blame if you want to see who wrote each line. I wouldn't take them as "best practices" but rather "here's how to get started" So in the specific question of mixing sync and async, it's probably random, I don't honestly remember, that code was written > 4 years ago. If you want to send PRs to clean up or clarify them, we'd welcome the contribution. |
This question is about proper client usage, method calls and guidance provided through samples.
Most examples use ConfigureAwait(false) with awaited calls to Kubernetes, why is that?
Some samples use both ways, calls to List method without await and calls to Read (namespace, for instance) with await..ConfigureAwait. Why is the public API written in this way?
https://github.com/kubernetes-client/csharp/blob/master/examples/namespace/NamespaceExample.cs
This
versus this
await client.CoreV1.ReadNamespaceAsync(name).ConfigureAwait(false);
We've had few issues with ConfigureAwait and SSL handshake with Kubernetes failing and I am unsure if it is due to ConfigureAwait.
Would just plain await without .ConfigureAwait() work fine too? bc there are examples on the Internet which use this option exclusively.
Also, it's somewhat weird public API of the C# client if it's done in this way
The text was updated successfully, but these errors were encountered: