-
Notifications
You must be signed in to change notification settings - Fork 23
Adds ExActor.Common.server_pid/1 #28
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
base: master
Are you sure you want to change the base?
Conversation
sasa1977
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good so far. I would advise to create a basic test first, which will make it easier to refactor later. Once the code is settled, we'll need to extend docs, both in readme, as well as ExActor.Operations module.
| But by providing a custom implementation of `server_pid/1`, you can map an identifier | ||
| to a PID by some other means. | ||
| """ | ||
| def server_pid(server_reference) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should make this public. By doing it, we're by default adding extra function to the module's interface, and I'm not sure I like that. Preferably, this would be a defp, though I'm not sure if defoverridable would work then. If it doesn't, then we could make it @doc false so it's not included in the generated docs, and marked as an internal detail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, I think we shouldn't inject this function for the cases where a global :export option is provided.
| @@ -0,0 +1,22 @@ | |||
| defmodule ExActor.Common do | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you're introducing this module, then moving the code of ExActor.Helper.init_generation_state to the __using__ might be nice. That way, we get to keep the common boilerplate in the same place.
| quote do | ||
| GenServer.unquote(server_fun)(unquote_splicing(interface_gen_server_args)) | ||
| end | ||
| GenServer.unquote(server_fun)(unquote_splicing(interface_gen_server_args)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line and the next one need to be indented once more.
This implements #27 , custom dispatch logic by using an overridable
server_pid/1function.I 'think' it works, but I have not yet had time to write tests for it (hopefully tomorrow or the day after that), so that is definitely something that should still happen before this pull request is merged, but I wanted to share this in its current state already at least.
Feel free to give feedback. 😄