Skip to main content

palladium_runtime/control_plane/
mod.rs

1/// Control Plane Server (REQ-086, REQ-087, REQ-088)
2///
3/// `ControlPlaneActor` is a system actor spawned at `/system/control-plane`
4/// when `EngineConfig::control_plane_socket` is set. On `on_start` it binds a
5/// Unix domain socket and spawns an accept loop that handles connections
6/// concurrently. Each connection speaks newline-delimited JSON-RPC 2.0.
7///
8/// Supported methods:
9/// - `engine.status`
10/// - `cluster.status`
11/// - `cluster.members`
12/// - `cluster.join`
13/// - `cluster.leave`
14/// - `cluster.gossip.status`
15/// - `cluster.member.set-meta`
16/// - `actor.list`
17/// - `actor.info`
18/// - `actor.stop`
19/// - `actor.spawn`
20/// - `msg.call`
21/// - `federation.policy.get`, `federation.policy.set`
22/// - `federation.registry.list`, `federation.registry.get`
23/// - `consensus.group.create`, `consensus.group.attach`, `consensus.group.list`
24/// - `consensus.group.members`, `consensus.group.status`
25/// - `consensus.group.delete`, `consensus.group.detach`
26/// - `consensus.propose`, `consensus.read`
27/// - `consensus.engine.status`, `consensus.engine.config`
28/// - `plugin.list`, `plugin.load`, `plugin.unload`, `plugin.reload`
29///   (delegated to `PluginRpcHandler` when one is provided)
30mod actor;
31mod listeners;
32mod rpc;
33mod utils;
34
35pub(crate) use actor::ControlPlaneActor;
36pub(crate) use utils::parse_socket_addr;
37
38use crate::reactor::Reactor;
39
40/// Extension point for plugin management RPCs.
41///
42/// Implement this trait in the application layer (e.g., wrapping a
43/// `PluginRegistry` from `pd-plugin`) and inject it into `EngineConfig` to
44/// enable `plugin.*` control-plane methods. When `None`, those methods
45/// return a "not implemented" error.
46pub trait PluginRpcHandler<R: Reactor = crate::reactor::TokioReactor>:
47    Send + Sync + 'static
48{
49    /// List all currently loaded plugins.
50    fn list_plugins(&self) -> Vec<serde_json::Value>;
51    /// Load a plugin from the given file path. Returns plugin info on success.
52    fn load_plugin(&self, path: &str) -> Result<serde_json::Value, String>;
53    /// Unload a plugin by name.
54    fn unload_plugin(&self, name: &str) -> Result<(), String>;
55    /// Reload a plugin by name (unload + load from the same path).
56    fn reload_plugin(&self, name: &str) -> Result<serde_json::Value, String>;
57    /// Spawn an actor instance for a registered type.
58    fn spawn_actor(
59        &self,
60        type_name: &str,
61        config: &[u8],
62    ) -> Result<Box<dyn palladium_actor::Actor<R>>, String>;
63}