Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to provide Actor TypeName during runtime at startup. #677

Closed
bjorkstromm opened this issue May 13, 2021 · 3 comments · Fixed by #721
Closed

Add support to provide Actor TypeName during runtime at startup. #677

bjorkstromm opened this issue May 13, 2021 · 3 comments · Fixed by #721
Assignees
Milestone

Comments

@bjorkstromm
Copy link
Member

Describe the proposal

Currently, since Actor Placement Service is global within the Kubernetes cluster, it makes it difficult to run multiple versions (e.g. DEV and TEST) of the application within the same cluster. This is due to the fact that Actor names are either automatically assigned from the name of the implementing class or by using the ActorAttribute and specifying the TypeName property. Bot of these approaches are compile-time constants which can't be adjusted during runtime.

Here's two proposals:

  1. Make it possible to resolve Actor TypeName from an environment variable when specified in the ActorAttribute. This is e.g. possible in Azure Functions with most of the attributes there. This would allow us to use the attribute as follows:

    [Actor(TypeName = "%MyActorName%")]
    public class MyActorName : Dapr.Actors.Runtime.Actor, IMyActor
    {
    }

    The %MyActorName% can then be resolved from an environment variable using e.g. Environment.ExpandEnvironmentVariables, or using a more sophisticated approach as Azure Functions SDK (see NameResolverExtensions.cs).

  2. Make it possible to provide ActorTypeName when calling RegisterActor<T>() on the ActorRegistrationCollection. This would currently be possible if ActorTypeName on ActorTypeInformation wasn't readonly. (I do it today using reflection :)). Propsal here is to add a overload to RegisterActor<T>() which takes a string parameter for the Actor TypeName.

@rynowak
Copy link
Contributor

rynowak commented May 13, 2021

I'd prefer approach 2 - the functions approach would be surprising, given that nothing else we do works that way.

Feel free to send a PR for option 2 :)

@bjorkstromm
Copy link
Member Author

@rynowak consider it done!

Regarding Approach 1, I actually wanted this also for the TopicAttribute. See #678. Don't really know what the best approach would be there (beside the Azure Function approach). But, but... Let's continue that discussion on that issue.

@devlead
Copy link

devlead commented May 14, 2021

Must say I really like option one, would make it really straightforward to have the same set of "artifacts" flow and be reused through environments.

bjorkstromm added a commit to bjorkstromm/dotnet-sdk that referenced this issue May 16, 2021
bjorkstromm added a commit to bjorkstromm/dotnet-sdk that referenced this issue Feb 9, 2022
- Fixes dapr#677

Signed-off-by: Martin Björkström <martin.bjorkstrom@gmail.com>
halspang pushed a commit that referenced this issue Feb 15, 2022
* Adds support for providing Actor type name during runtime.

- Fixes #677

Signed-off-by: Martin Björkström <martin.bjorkstrom@gmail.com>

* Make ActorTypeInformation.TryGet(Type) and ActorTypeInformation.Get(Type) obsolete.

- Fix relevant code after obsoleting.

Signed-off-by: Martin Björkström <martin.bjorkstrom@gmail.com>
@halspang halspang added this to the v1.7 milestone Feb 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants