diff --git a/proxmox-rest-server/src/api_config.rs b/proxmox-rest-server/src/api_config.rs index 712c591b..39178543 100644 --- a/proxmox-rest-server/src/api_config.rs +++ b/proxmox-rest-server/src/api_config.rs @@ -14,7 +14,7 @@ use serde::Serialize; use proxmox::api::{ApiMethod, Router, RpcEnvironmentType}; use proxmox::tools::fs::{create_path, CreateOptions}; -use crate::{ApiAuth, FileLogger, FileLogOptions, CommandoSocket}; +use crate::{ApiAuth, FileLogger, FileLogOptions, CommandSocket}; pub type GetIndexFn = fn(Option, Option, &ApiConfig, Parts) -> Response; @@ -182,13 +182,13 @@ impl ApiConfig { /// /// When enabled, all requests are logged to the specified file. /// This function also registers a `api-access-log-reopen` - /// command one the [CommandoSocket]. + /// command one the [CommandSocket]. pub fn enable_access_log

( &mut self, path: P, dir_opts: Option, file_opts: Option, - commando_sock: &mut CommandoSocket, + commando_sock: &mut CommandSocket, ) -> Result<(), Error> where P: Into @@ -221,13 +221,13 @@ impl ApiConfig { /// /// When enabled, all authentification requests are logged to the /// specified file. This function also registers a - /// `api-auth-log-reopen` command one the [CommandoSocket]. + /// `api-auth-log-reopen` command one the [CommandSocket]. pub fn enable_auth_log

( &mut self, path: P, dir_opts: Option, file_opts: Option, - commando_sock: &mut CommandoSocket, + commando_sock: &mut CommandSocket, ) -> Result<(), Error> where P: Into diff --git a/proxmox-rest-server/src/command_socket.rs b/proxmox-rest-server/src/command_socket.rs index 511ad561..46814c4f 100644 --- a/proxmox-rest-server/src/command_socket.rs +++ b/proxmox-rest-server/src/command_socket.rs @@ -148,23 +148,25 @@ where } // A callback for a specific commando socket. -type CommandoSocketFn = Box<(dyn Fn(Option<&Value>) -> Result + Send + Sync + 'static)>; +type CommandSocketFn = Box<(dyn Fn(Option<&Value>) -> Result + Send + Sync + 'static)>; /// Tooling to get a single control command socket where one can /// register multiple commands dynamically. /// -/// You need to call `spawn()` to make the socket active. -pub struct CommandoSocket { +/// The socket is activated by calling [spawn](CommandSocket::spawn), +/// which spawns an async tokio task to process the commands. +pub struct CommandSocket { socket: PathBuf, gid: Gid, - commands: HashMap, + commands: HashMap, } -impl CommandoSocket { +impl CommandSocket { + /// Creates a new instance. pub fn new

(path: P, gid: Gid) -> Self where P: Into, { - CommandoSocket { + CommandSocket { socket: path.into(), gid, commands: HashMap::new(), diff --git a/proxmox-rest-server/src/worker_task.rs b/proxmox-rest-server/src/worker_task.rs index dea78b5a..0ac3f431 100644 --- a/proxmox-rest-server/src/worker_task.rs +++ b/proxmox-rest-server/src/worker_task.rs @@ -23,7 +23,7 @@ use proxmox::api::upid::UPID; use pbs_tools::task::WorkerTaskContext; use pbs_tools::logrotate::{LogRotate, LogRotateFiles}; -use crate::{CommandoSocket, FileLogger, FileLogOptions}; +use crate::{CommandSocket, FileLogger, FileLogOptions}; struct TaskListLockGuard(File); @@ -324,7 +324,7 @@ pub fn worker_is_active_local(upid: &UPID) -> bool { } } -/// Register task control command on a [CommandoSocket]. +/// Register task control command on a [CommandSocket]. /// /// This create two commands: /// @@ -333,7 +333,7 @@ pub fn worker_is_active_local(upid: &UPID) -> bool { /// * ``worker-task-status ``: return true of false, depending on /// whether the worker is running or stopped. pub fn register_task_control_commands( - commando_sock: &mut CommandoSocket, + commando_sock: &mut CommandSocket, ) -> Result<(), Error> { fn get_upid(args: Option<&Value>) -> Result { let args = if let Some(args) = args { args } else { bail!("missing args") };