I'm not sure how or where to inject dependencies into a Grain. Where's the best place to do this?
If it's not possible, should I set up a container in the WorkerRole.Run method and get instances as I need them?
I'm not sure how or where to inject dependencies into a Grain. Where's the best place to do this?
If it's not possible, should I set up a container in the WorkerRole.Run method and get instances as I need them?
There is a limited support for DI in the grains. This feature is being promised to be delivered soon , but as in 1.0.9 - there is no traditional constructor injection.
So far you can use (anti-pattern) ServiceLocator using frameworks of your choice (e.g we are using Autofac and CommonServiceLocator for that) for resolving services you want to call inside your grain instance.
For the unit testing - there is a Grain constructor which can be used to construct grain instance with mocks (see more details here )
I'd invite you to the Orleans gitter chat (as via link above) where you can see answers and discussions around some other burning questions.
Since orleans 1.1.0 release, orleans team added "ASP.NET vNext style Dependency Injection for grains", you can see an example of this in here
Also to see how "ASP.NET vNext Dependency Injection" works see here
There is a limited support for DI in the grains. This feature is being promised to be delivered soon , but as in 1.0.9 - there is no traditional constructor injection.
So far you can use (anti-pattern) ServiceLocator using frameworks of your choice (e.g we are using Autofac and CommonServiceLocator for that) for resolving services you want to call inside your grain instance.
For the unit testing - there is a Grain constructor which can be used to construct grain instance with mocks (see more details here )
I'd invite you to the Orleans gitter chat (as via link above) where you can see answers and discussions around some other burning questions.
© 2022 - 2024 — McMap. All rights reserved.