I'm building an application, where I have multiple different actor types that have the same kind of behavior (CRUD) in respect to some different data objects. In order to more easily create code that handles this I've tried to create an interface, that these actors can implement.
This means that i have an actor interface that looks something like this:
public interface IMyActor1 :
IActor,
IDataActor<DataItem1>,
IDataActor<DataItem2>
Where the IDataActor<T>
looks like this:
public interface IDataActor<T> where T : IDataItem
{
Task Create(T item);
Task<T> Read(string itemId);
Task Update(T item);
Task Delete(string itemId);
}
And the actor it self looks like this
class MyActor1: Actor, IMyActor1
{
...
}
Originally i tried having IDataActor<T>
derive from IActor
, but understandably this isn't allowed, and i get an "Generic interfaces cannot be remoted." error when i try to deploy, so i tried this.
When I build the project now I get the following error log:
System.ArgumentException: The actor type 'MyProject.ActorProject.MyActor1' does not implement any actor interfaces. An actor interface is the one that derives from 'Microsoft.ServiceFabric.Actors.IActor' type.
Parameter name: actorType
at Microsoft.ServiceFabric.Actors.Runtime.ActorTypeInformation.Get(Type actorType)
at FabActUtil.Tool.LoadActors(Assembly inputAssembly, IList`1 actorFilters, IList`1 actorTypes)
at FabActUtil.Tool.LoadActors(ToolContext context)
at FabActUtil.Tool.ProcessInput(ToolContext context)
at FabActUtil.Tool.Run(ToolArguments arguments)
at FabActUtil.Program.Main(String[] args)
The error claims that MyActor1 does not implement any actor interfaces, however it clearly does. Does anyone know is this is a bug, or if there's a practical workaround? Getting this working could save me a lot of duplicated code.
Thanks!