Reputation: 6685
Having played around with the preview SDK, I noticed a few astonishing things when trying to provide common implementations for a set of related Actor types to be used by a framework I'm developing.
Creating code like the following doesn't seem to work as expected:
Library:
public abstract class CommonActor : Actor, ICommonActor
{
public abstract void DoStuff();
}
Console Application:
public class MyActor : CommonActor
{
public void override DoStuff()
{
//Stuff
}
}
When creating my Actor, my call to register the actor fails.
fabricRuntime.RegisterActor(typeof(MyActor));
I receive an error that the type does not derive from Actor, which is clearly bogus.
Also I noticed that this seems to break the tool to generate the service manifest. (I had to work around this by disabling the tool.)
This basically prevents me from writing the API for my users the way that I want to. I don't like that at all. Similarly as other have reported, there is little-to-no support for dependency-injection scenarios here, undermining the utility of the Actors model pretty dramatically for me.
Am I missing something? Is there a better way to implement actor abstractions here?
Upvotes: 2
Views: 441
Reputation: 331
This can now be done as long as the child actor is explicitly named using the ActorService
decorator. In your example this would translate to updating the MyActor
class like this...
[ActorService(Name = "MyActor")] // Child actors need this decorator
public class MyActor : CommonActor
{
public void override DoStuff()
{
//Stuff
}
}
More information is also available in the Service Fabric documentation.
Upvotes: 5
Reputation: 476
Thanks for reporting the issue. This is a known limitation that will get fixed in the future release. While not pretty you can workaround by using containment.
Upvotes: 1