microsoft / service-fabric-services-and-actors-dotnet

Reliable Services and Reliable Actors are Service Fabric application frameworks for building highly-scalable distributed cloud applications.
Other
269 stars 113 forks source link

Unable to implement reminders for my own StateProvider implementation #345

Open ssteinau opened 2 years ago

ssteinau commented 2 years ago

Describe the bug ActorService allows implementing custom actor state providers. The Interface IActorStateProvider requires implementing the method

    Task<ReminderPagedResult<KeyValuePair<ActorId, List<ActorReminderState>>>> GetRemindersAsync(
        int numItemsToReturn, ...); // parameters omitted for brevity

The problem is in the return type "List\<ActorReminderState>". ActorReminderState is public non-sealed class and as such can be subclassed, yet its constructor is internal - One cannot create instances of the subclass.

Related issues cascade through the code as well:.ActorStateReminder constructor parameters are internal classes as well, To Reproduce

Create new project, import the actors NuGet package, create a subclass of ActorReminder state with a 3-param constructor that calls the base class. Compiler error because the base class constructor is internal. Example:

public class SubActorReminderState : ActorReminderState, IActorReminderState
{

  /*Properties
  */
  //Constructor
    public SubActorReminderState(ActorReminderData reminder, TimeSpan currentLogicalTime, ReminderCompletedData reminderCompletedData) : base(reminder,currentLogicalTime,reminderCompletedData) //calling base gives compiler error

Expected behavior

Be able to implement reminders for the state provider. Possible solutions:

Additional context

and a user can then implement the IActorReminderState interface, ActorReminderState can stay as-is.

Caveat: the interface would have to include additional properties and methods, non-interface properties and methods of ActorReminderState are used throughout the project.