Skip to content

@ActorMethod to override method's name for client and service #444

Description

@artursouza

Today, we have Actor for Dapr implemented in 3 languages: C#, Java and Python. Each language has their own convention in how a method should be named. Then, actor method invocation does not work cross language without the caller breaking the language's convention when defining the Actor's interface.

Example of Actor interface in the service side in C#:

    public interface IMyActor : IActor
    {      
        Task<int> IncrementAndGetAsync(int delta);
    }

Now, the same interface could be represented at the caller's side in Java:

@ActorType(name = "MyActor")
public interface MyActor {
  @ActorMethod(name = "IncrementAndGetAsync")
  int incrementAndGet(int delta);
}

Instead of:

@ActorType(name = "MyActor")
public interface MyActor {
  int IncrementAndGetAsync(int delta);
}

This feature should also work the other way around, where the Java service would accept "IncrementAndGetAsync" instead of the native method name.

Note: The SDK already contains the @ActorMethod annotation but it does not have the name attribute.

Relates to: dapr/dapr#1165

Activity

  1. artursouza commented on Jan 17, 2021

    @artursouza
    ContributorAuthor

    This issue does not affect .Net SDK because it does not use native method invocation for cross language invocation (without remoting), it uses the following API instead:

          var proxy = ActorProxy.Create(new ActorId(actorId), actorType);
          return await proxy.InvokeAsync<int, int>("incrementAndGet", 1);
  2. artursouza commented on Jan 17, 2021

    @artursouza
    ContributorAuthor
  3. self-assigned this
    on Jan 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions