Which way to use DaprClient is recommended?
See original GitHub issueHi, there are 2 ways to use DaprClient
in current demos.
first one is to create a new DaprClient
instance whenever you need to talk to dapr runtime:
try (DaprClient client = (new DaprClientBuilder()).build()) {
// ...
}
second one is to create a DaprClient
bean before usage, then inject it into code:
@Autowired
private DaprClient client;
since our project is Spring-based, the second way seems attractive, however, is it thread-safe to use DaprClient
in the second way, since Spring’ bean is singleton by default.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
DaprClient usage - Dapr Docs
For best performance, create a single long-lived instance of DaprClient and provide access to that shared instance throughout your application.
Read more >Get started with Dapr | Microsoft Learn
You use the DaprClient.InvokeMethodAsync method to invoke the weatherforecast method of the MyBackEnd service. You'll configure the web API to ...
Read more >Improvements to dapr client · Issue #197 · dapr/dotnet-sdk
I did the initial draft of Dapr.Client and defined state as its own ... we were leaning this way to reduce maintenance pain...
Read more >Using Service Invocation from Dapr .NET SDK - Laurent Kempé
Using the DaprClient we only had to specify the HTTP method, the Dapr app-id and the method-name of our service. Conclusion. We have...
Read more >patterns Archives - klichx.dev
This means you may use http calls or Dapr client. Best part is that no matter what is on the other end, be...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The second way is preferred because you reuse the client. The client is thread-safe and designed to be reused.
that’s what confusing me too. i guess the only way to find it out is to read the source codes.