dapr / dapr/dotnet-sdk

Allow to define which interfaces are important for the dapr actor host

Open
#1,341 4 comments 0 reactions 1 assignee Claimed by @siri-varma View on GitHub
help wanted
Dominant language
C#
Stars
1.2k
Forks
378
Avg merge
1d 22h
Merged PRs (30d)
5

Description

## Describe the proposal

Currently, if you do something like:

```csharp
builder.Services.AddActors(options =>
{
options.Actors.RegisterActor(nameof(MyActor));
});
```

The complete interface hierarchy needs to be compatible with actors. So if you have something like:

```csharp
public interface IInternalMyActor : IMyActor
{
void SomeInternalMethod()
}

public interface IMyActor: IActor
{
Task SomeMethod()
}

public class MyActor: Actor, IInternalMyActor{
// TODO: implementation
}
```

If you try to start this actor host you will get the following error message:

```
: 'Method 'SomeInternalMethod' of actor interface 'MySample.IInternalMyActor ' does not return Task or Task<>. The actor interface methods must be async and must return either Task or Task<>. (Parameter 'actorInterfaceType')'
```

Error happens at `InterfaceDescription:224`.

It would be nice if we would be able to provide at the actor registration another generic parameter which interface should be used to access the actor. So like:

```csharp
builder.Services.AddActors(options =>
{
options.Actors.RegisterActor(nameof(MyActor));
});
```

That would make it possible to have a quite complicated structure of interface on an actor. Also it would make it alot easier to use `default interface methods`, because you can have an more advanced `IActor` interface in your project that just map members from the class `Actor`, so you can use it in your `default interface methods`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.