Skip to content
This repository has been archived by the owner on Sep 22, 2020. It is now read-only.

#[derive(Actor)] #1

Open
callym opened this issue Nov 16, 2017 · 5 comments
Open

#[derive(Actor)] #1

callym opened this issue Nov 16, 2017 · 5 comments

Comments

@callym
Copy link
Contributor

callym commented Nov 16, 2017

Should we add a custom derive for the Actor trait?

#[derive(Actor)]
struct SumActor;

Which expands to:

impl Actor for SumActor {
    type Context = Context<Self>;
}
@fafhrd91
Copy link
Member

fafhrd91 commented Nov 16, 2017

main problem is we can have many different contexts. we can use something like #[actor] for default context or #[actor(HttpContext)] in case of custom context. it requires nightly but i think that's fine

@fafhrd91
Copy link
Member

@callym are you planing to work on any of the issues?

@callym
Copy link
Contributor Author

callym commented Nov 22, 2017

I think we can do

#[derive(Actor)]
#[derive(Actor)]
#[ActorContext(HttpContext)]

This wouldn't require Nightly as it can be done in custom derive (the same way #[Message(result, error)] is done)

@fafhrd91
Copy link
Member

What is the point? Even without macro actor definition takes only 3 lines. I don’t think it worse introducing macro

@najamelan
Copy link

@fafhrd91 I would really appreciate if we could implement this. "To answer What's the point?" -> The same as for #[ derive( Message )]. It only saves 3 lines per Actor, so in serious project it saves like 300 lines.

As for the context. It seems the same situation as Message with Result, and I would stick to consistent implementation with message, in the lines of: #[ctype=HttpContext]. It doesn't cost anything, but it might shave a few hundred lines of a project. And to be honest, I have alot of actors, but never used another context than default.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants