Skip to content

Conversation

@Qqwy
Copy link

@Qqwy Qqwy commented Jun 10, 2017

This implements #27 , custom dispatch logic by using an overridable server_pid/1 function.

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. 😄

Copy link
Owner

@sasa1977 sasa1977 left a 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
Copy link
Owner

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.

Copy link
Owner

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
Copy link
Owner

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))
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants