feat: align OpenRPC server with simplified client API
- Updated RegisterRunnerParams to only require name (queue = name) - Added AddRunnerParams with RunnerConfig for add_runner method - Updated RunnerManagementParams and StopRunnerParams with secrets - Added add_runner method to OpenRPC trait and implementation - Removed duplicate AddRunnerParams definition - Updated client register_runner to send params as JSON object - Added TODO comments for moving secrets to HTTP headers
This commit is contained in:
		@@ -69,14 +69,50 @@ fn invalid_params_error(msg: &str) -> ErrorObject<'static> {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// Request parameters for registering a new runner
 | 
			
		||||
/// TODO: Move secret to HTTP Authorization header for better security
 | 
			
		||||
#[derive(Debug, Deserialize, Serialize)]
 | 
			
		||||
pub struct RegisterRunnerParams {
 | 
			
		||||
    pub secret: String,
 | 
			
		||||
    pub name: String,
 | 
			
		||||
    pub queue: String,
 | 
			
		||||
    // Note: queue is derived from name (name = queue)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// Request parameters for runner management operations
 | 
			
		||||
/// TODO: Move secret to HTTP Authorization header for better security
 | 
			
		||||
#[derive(Debug, Deserialize, Serialize)]
 | 
			
		||||
pub struct RunnerManagementParams {
 | 
			
		||||
    pub secret: String,
 | 
			
		||||
    pub actor_id: String,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// Request parameters for stopping a runner
 | 
			
		||||
/// TODO: Move secret to HTTP Authorization header for better security
 | 
			
		||||
#[derive(Debug, Deserialize, Serialize)]
 | 
			
		||||
pub struct StopRunnerParams {
 | 
			
		||||
    pub secret: String,
 | 
			
		||||
    pub actor_id: String,
 | 
			
		||||
    pub force: bool,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// Request parameters for adding a runner with configuration
 | 
			
		||||
/// TODO: Move secret to HTTP Authorization header for better security
 | 
			
		||||
#[derive(Debug, Deserialize, Serialize)]
 | 
			
		||||
pub struct AddRunnerParams {
 | 
			
		||||
    pub secret: String,
 | 
			
		||||
    pub config: RunnerConfig,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// Runner configuration
 | 
			
		||||
#[derive(Debug, Clone, Deserialize, Serialize)]
 | 
			
		||||
pub struct RunnerConfig {
 | 
			
		||||
    pub name: String,
 | 
			
		||||
    pub command: String,
 | 
			
		||||
    #[serde(skip_serializing_if = "Option::is_none")]
 | 
			
		||||
    pub env: Option<std::collections::HashMap<String, String>>,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// Request parameters for running a job
 | 
			
		||||
/// TODO: Move secret to HTTP Authorization header for better security
 | 
			
		||||
#[derive(Debug, Deserialize, Serialize)]
 | 
			
		||||
pub struct RunJobParams {
 | 
			
		||||
    pub secret: String,
 | 
			
		||||
@@ -108,17 +144,6 @@ pub struct JobStatusResponse {
 | 
			
		||||
    pub completed_at: Option<String>,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// Request parameters for adding a new runner
 | 
			
		||||
#[derive(Debug, Deserialize, Serialize)]
 | 
			
		||||
pub struct AddRunnerParams {
 | 
			
		||||
    pub actor_id: String,
 | 
			
		||||
    pub binary_path: String,
 | 
			
		||||
    pub db_path: String,
 | 
			
		||||
    pub redis_url: String,
 | 
			
		||||
    pub process_manager_type: String, // "simple" or "tmux"
 | 
			
		||||
    pub tmux_session_name: Option<String>, // required if process_manager_type is "tmux"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// Request parameters for queuing a job
 | 
			
		||||
#[derive(Debug, Deserialize, Serialize)]
 | 
			
		||||
pub struct QueueJobParams {
 | 
			
		||||
@@ -308,11 +333,15 @@ pub trait SupervisorRpc {
 | 
			
		||||
 | 
			
		||||
    /// Start a specific runner
 | 
			
		||||
    #[method(name = "start_runner")]
 | 
			
		||||
    async fn start_runner(&self, actor_id: String) -> RpcResult<()>;
 | 
			
		||||
    async fn start_runner(&self, params: RunnerManagementParams) -> RpcResult<()>;
 | 
			
		||||
 | 
			
		||||
    /// Stop a specific runner
 | 
			
		||||
    #[method(name = "stop_runner")]
 | 
			
		||||
    async fn stop_runner(&self, actor_id: String, force: bool) -> RpcResult<()>;
 | 
			
		||||
    async fn stop_runner(&self, params: StopRunnerParams) -> RpcResult<()>;
 | 
			
		||||
    
 | 
			
		||||
    /// Add a runner with configuration
 | 
			
		||||
    #[method(name = "add_runner")]
 | 
			
		||||
    async fn add_runner(&self, params: AddRunnerParams) -> RpcResult<()>;
 | 
			
		||||
 | 
			
		||||
    /// Get a specific runner by ID
 | 
			
		||||
    #[method(name = "get_runner")]
 | 
			
		||||
@@ -422,8 +451,9 @@ impl SupervisorRpcServer for Arc<Mutex<Supervisor>> {
 | 
			
		||||
        debug!("OpenRPC request: register_runner with params: {:?}", params);
 | 
			
		||||
        
 | 
			
		||||
        let mut supervisor = self.lock().await;
 | 
			
		||||
        // Queue name is the same as runner name
 | 
			
		||||
        supervisor
 | 
			
		||||
            .register_runner(¶ms.secret, ¶ms.name, ¶ms.queue)
 | 
			
		||||
            .register_runner(¶ms.secret, ¶ms.name, ¶ms.name)
 | 
			
		||||
            .await
 | 
			
		||||
            .map_err(runner_error_to_rpc_error)?;
 | 
			
		||||
        
 | 
			
		||||
@@ -541,23 +571,38 @@ impl SupervisorRpcServer for Arc<Mutex<Supervisor>> {
 | 
			
		||||
        Ok(supervisor.list_runners().into_iter().map(|s| s.to_string()).collect())
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    async fn start_runner(&self, actor_id: String) -> RpcResult<()> {
 | 
			
		||||
        debug!("OpenRPC request: start_runner with actor_id: {}", actor_id);
 | 
			
		||||
    async fn start_runner(&self, params: RunnerManagementParams) -> RpcResult<()> {
 | 
			
		||||
        debug!("OpenRPC request: start_runner with params: {:?}", params);
 | 
			
		||||
        // TODO: Verify secret authorization
 | 
			
		||||
        let mut supervisor = self.lock().await;
 | 
			
		||||
        supervisor
 | 
			
		||||
            .start_runner(&actor_id)
 | 
			
		||||
            .start_runner(¶ms.actor_id)
 | 
			
		||||
            .await
 | 
			
		||||
            .map_err(runner_error_to_rpc_error)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    async fn stop_runner(&self, actor_id: String, force: bool) -> RpcResult<()> {
 | 
			
		||||
        debug!("OpenRPC request: stop_runner with actor_id: {}, force: {}", actor_id, force);
 | 
			
		||||
    async fn stop_runner(&self, params: StopRunnerParams) -> RpcResult<()> {
 | 
			
		||||
        debug!("OpenRPC request: stop_runner with params: {:?}", params);
 | 
			
		||||
        // TODO: Verify secret authorization
 | 
			
		||||
        let mut supervisor = self.lock().await;
 | 
			
		||||
        supervisor
 | 
			
		||||
            .stop_runner(&actor_id, force)
 | 
			
		||||
            .stop_runner(¶ms.actor_id, params.force)
 | 
			
		||||
            .await
 | 
			
		||||
            .map_err(runner_error_to_rpc_error)
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    async fn add_runner(&self, params: AddRunnerParams) -> RpcResult<()> {
 | 
			
		||||
        debug!("OpenRPC request: add_runner with params: {:?}", params);
 | 
			
		||||
        // TODO: Verify secret authorization
 | 
			
		||||
        // TODO: Implement actual runner addition logic with config
 | 
			
		||||
        // For now, just register the runner by name
 | 
			
		||||
        let mut supervisor = self.lock().await;
 | 
			
		||||
        supervisor
 | 
			
		||||
            .register_runner(¶ms.secret, ¶ms.config.name, ¶ms.config.name)
 | 
			
		||||
            .await
 | 
			
		||||
            .map_err(runner_error_to_rpc_error)?;
 | 
			
		||||
        Ok(())
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    async fn get_runner(&self, actor_id: String) -> RpcResult<RunnerWrapper> {
 | 
			
		||||
        debug!("OpenRPC request: get_runner with actor_id: {}", actor_id);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user