dotnet-sdk icon indicating copy to clipboard operation
dotnet-sdk copied to clipboard

Add wait() method to block until Sidecar is up

Open artursouza opened this issue 4 years ago • 5 comments

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.

artursouza avatar Oct 27 '20 23:10 artursouza

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.

artursouza avatar Jan 08 '21 23:01 artursouza

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

artursouza avatar Aug 20 '21 20:08 artursouza

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.

DarqueWarrior avatar Aug 20 '21 20:08 DarqueWarrior

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

bartr avatar Aug 20 '21 21:08 bartr

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.

artursouza avatar Aug 20 '21 22:08 artursouza

We did this: https://github.com/dapr/dotnet-sdk/blob/master/src/Dapr.Client/DaprClientGrpc.cs#L1353

halspang avatar Aug 29 '22 20:08 halspang