Hi,
I’m just migrating our Solution vom v5 to v20.06.
Should I register the new Eventstore Client as Singleton in my DI-Container?
Thanks for Help!
Best Regards, Thomas
Hi,
I’m just migrating our Solution vom v5 to v20.06.
Should I register the new Eventstore Client as Singleton in my DI-Container?
Thanks for Help!
Best Regards, Thomas
Yes. Please note that we already provide extension methods on ServiceCollection
- AddEventStoreClient
- which registers it as a singleton. The overload to configure the client via connection string is coming in the next version.
Hi Joao,
thanks for the fast reply.
That is good to hear. So the Client is Thread-Safe I assume.
I don’t want to use the Extention-Method.Used old Autofac Modules a lot and don’t want to refactor all of them.
BR. Thomas
I can imagine the question for the TCP client, is the GRPC client also thread-safe?
In the docs also says it can be registered as Singleton, so I assume it, just asking for safety.
under the hood we use grpc channels & clients , so it’s as thread safe as those
EventStoreClient manages the channels .
Since creating channels is expensive we prefer a singleton client (https://github.com/grpc/grpc/blob/master/src/csharp/Grpc.Core/Channel.cs#L29)
Thanks Yves, I thought so because of the nature of grpc just wanted to make sure because on the TCP docs it explicitly mentions the client is thread safe but not on th grpc one.
It will be good the document for grpc also says that