dotnet-sdk
dotnet-sdk copied to clipboard
Add wait() method to block until Sidecar is up
App might depend on sidecar right away. Implement wait() method to enable app to wait for sidecar to be up before invoking the first call.
This issue happens when we run samples (and potentially applications) that needs to invoke the sidecar right away but the sidecar is not available. So, this utility method (which can be implemented by the app) is handy to make the app wait for the sidecar when that is needed.
This issue partially solves the problem but does not have a built in loop to actually wait for the sidecar to be up: https://github.com/dapr/dotnet-sdk/issues/640
Adding this to the SDKs is fine but there needs to be an alternative that does not require an SDK to know Dapr is ready to receive requests from the app.
As an app, I could define an "init" or "ready" route that gets called by Dapr when it is ready. The onus will be on the app writer to use that callback to do any initialization after the call.
My only concern of this being in the SDK only is it will apply pressure to have SDKs for all languages. Giving a generic route or alternative method makes this available to all languages regardless of there is an SDK or not.
We will need to provide examples of both methods in the documentation.
I tried calling the http://127.0.0.1:3500/v1.0/healthz sidecar endpoint from the app and get a 500. The sidecar is waiting on the app which is waiting on the sidecar ... seems like a potential race condition
I tried calling the http://127.0.0.1:3500/v1.0/healthz sidecar endpoint from the app and get a 500. The sidecar is waiting on the app which is waiting on the sidecar ... seems like a potential race condition
Correct. This is a known race condition. This is why the user must know when it is safe to wait for the sidecar. The HTTP endpoint for the app must be up before waiting for the sidecar. BTW, you will likely get a 500 when calling the sidecar to begin with, this call must be retried until the sidecar is up and number of retries is exceeded.
We did this: https://github.com/dapr/dotnet-sdk/blob/master/src/Dapr.Client/DaprClientGrpc.cs#L1353