Reputation: 4482
I have an ASP.net Core application which needs to call a service using service remoting.
Is it a good idea to do something like this in my Startup
?:
services.AddSingleton<IHelloWorldService>(ServiceProxy.Create<IHelloWorldService>(new Uri("fabric:/Demo/HelloWorldService")));
As far as I'm aware, all ServiceProxy.Create()
is pretty "simple" and just proxies the calls -- so this sounds safe enough to do?
Upvotes: 0
Views: 383
Reputation: 9050
That's safe to do in the sense that the proxy object will always work. The nice thing about this is that you have a very familiar pattern where you inject a service interface like you do in a domain-driven application.
If fabric:/Demo/HelloWorldService is partitioned though, then this won't work out too well, because you need a new proxy for each partition. In that case, you should inject an IServiceProxyFactory, which can be used to create proxies for different partition and can still be mocked out for unit testing.
Upvotes: 2