rerfactor: Add RPC server to handle RPC calls#102
rerfactor: Add RPC server to handle RPC calls#102davidebriani merged 1 commit intoastarte-platform:feature/erlang-rpcfrom
Conversation
83b2622 to
3d0486a
Compare
| Supervisor of the RPC server. | ||
| """ | ||
|
|
||
| use Supervisor |
There was a problem hiding this comment.
The default Supervisor from Elixir is used instead of Horde.Supervisor.
Just to confirm that this was the intended behavior.
So I reckon that each VerneMQ replica tries to start a Astarte.VMQ.Plugin.RPC.Server instance, but only one replica will be able to start it.
However, what if that replica dies, either because of a crash or because it is scaled down? Will another replica automatically start a new Server? I suspect not.
There was a problem hiding this comment.
Horde does not have simple Supervisors, only DynamicSupervisors. My guess in this situation is that if the RPC server goes down all replicas supervisors try to start a new one and only one will succeed, so a new RPC server goes up.
But this is only a guess, so I agree that this should be moved to a Horde.DynamicSupervisor that handles this kinds of situations automagically 👍
RPC requests are currently handled both by an `astarte_rpc` client and a dedicated `GenServer`. This allows external services to also use the default erlang clustering strategy to perform RPC calls instead of relying on the custom library `artarte_rpc` Signed-off-by: Luca Zaninotto <luca.zaninotto@secomind.com>
uses astarte-platform/astarte_vmq_plugin#102 as vernemq image Signed-off-by: Luca Zaninotto <luca.zaninotto@secomind.com>
e2f3772
into
astarte-platform:feature/erlang-rpc
uses astarte-platform/astarte_vmq_plugin#102 as vernemq image Signed-off-by: Luca Zaninotto <luca.zaninotto@secomind.com>
uses astarte-platform/astarte_vmq_plugin#102 as vernemq image Signed-off-by: Luca Zaninotto <luca.zaninotto@secomind.com>
uses astarte-platform/astarte_vmq_plugin#102 as vernemq image Signed-off-by: Luca Zaninotto <luca.zaninotto@secomind.com>
uses astarte-platform/astarte_vmq_plugin#102 as vernemq image Signed-off-by: Luca Zaninotto <luca.zaninotto@secomind.com>
Depends on #103
Astarte services relied on https://github.com/astarte-platform/astarte_rpc to make RPC calls to other services (this one included) This is pretty cumbersome, can break in various points and includes features that we generally do not use for RPC calls.
This PR follows the line of astarte-platform/astarte#1186 adding an RPC server in the plugin that will answer RPC requests. This server is shared among all Plugin replicas and will shutdown when other replicas are up (this is handled by
Horde). The prerequisite for this to work is that verne itself and its instances are clustered. This should be handled by VerneMQ itself (source: the docs)