Skip to content

rerfactor: Add RPC server to handle RPC calls#102

Merged
davidebriani merged 1 commit intoastarte-platform:feature/erlang-rpcfrom
lusergit:ref/rpc_server
Apr 7, 2025
Merged

rerfactor: Add RPC server to handle RPC calls#102
davidebriani merged 1 commit intoastarte-platform:feature/erlang-rpcfrom
lusergit:ref/rpc_server

Conversation

@lusergit
Copy link
Copy Markdown
Contributor

@lusergit lusergit commented Apr 3, 2025

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)

@lusergit lusergit marked this pull request as draft April 3, 2025 09:58
@lusergit lusergit force-pushed the ref/rpc_server branch 4 times, most recently from 83b2622 to 3d0486a Compare April 4, 2025 13:16
@lusergit lusergit requested a review from Annopaolo April 4, 2025 13:30
@lusergit lusergit marked this pull request as ready for review April 4, 2025 13:30
@lusergit lusergit requested a review from davidebriani April 4, 2025 13:31
Supervisor of the RPC server.
"""

use Supervisor
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 👍

@lusergit lusergit changed the base branch from release-1.2 to feature/erlang-rpc April 7, 2025 08:55
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>
@lusergit lusergit requested a review from davidebriani April 7, 2025 13:38
lusergit added a commit to lusergit/astarte that referenced this pull request Apr 7, 2025
uses astarte-platform/astarte_vmq_plugin#102 as vernemq image

Signed-off-by: Luca Zaninotto <luca.zaninotto@secomind.com>
@davidebriani davidebriani merged commit e2f3772 into astarte-platform:feature/erlang-rpc Apr 7, 2025
4 checks passed
@lusergit lusergit deleted the ref/rpc_server branch April 8, 2025 08:34
lusergit added a commit to lusergit/astarte that referenced this pull request Apr 8, 2025
uses astarte-platform/astarte_vmq_plugin#102 as vernemq image

Signed-off-by: Luca Zaninotto <luca.zaninotto@secomind.com>
lusergit added a commit to lusergit/astarte that referenced this pull request Apr 8, 2025
uses astarte-platform/astarte_vmq_plugin#102 as vernemq image

Signed-off-by: Luca Zaninotto <luca.zaninotto@secomind.com>
lusergit added a commit to lusergit/astarte that referenced this pull request Apr 8, 2025
uses astarte-platform/astarte_vmq_plugin#102 as vernemq image

Signed-off-by: Luca Zaninotto <luca.zaninotto@secomind.com>
lusergit added a commit to lusergit/astarte that referenced this pull request Apr 9, 2025
uses astarte-platform/astarte_vmq_plugin#102 as vernemq image

Signed-off-by: Luca Zaninotto <luca.zaninotto@secomind.com>
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