Azure service fabric actor dependency injection

前端 未结 6 948
予麋鹿
予麋鹿 2021-01-01 14:17

Is there any way to inject dependencies in to the Azure Service Fabric Actor\'s constructor?

6条回答
  •  天命终不由人
    2021-01-01 15:04

    Having had a bit of a dig-around in this area with dotPeek a while back (trying to resolve actors from an Autofac lifetime scope per-invocation), I think the trick is to create your own implementation of StatelessActorServiceFactory, and your own extension method to register the actor with it. Although the factory class is marked as internal, its interface (IStatelessServiceFactory) and the service type it creates (StatelessActorServiceInstance) are both public. Unfortunately, it doesn't look like StatelessActorServiceInstance was designed to be extensible (I'm hoping this is just an oversight).

    Unfortunately, it looks like WcfActorCommunicationProvider is also marked as internal so you'll pretty much have to create your own pipeline from scratch:

    1. Implement your own IStatelessServiceFactory
    2. Implement your own IStatelessServiceInstance, IActorService
    3. Implement your own IActorCommunicationProvider
    4. Implement your own IActorHost

    Doesn't really seem worth the effort anymore, does it? :-/

    That's where I gave up for now. I don't think it's worth trying to roll-your-own for now given the relative immaturity of the public API, since if this sort of functionality will show up at all, they'll probably do so in a way that'll break anything your implement yourself.

提交回复
热议问题