pub struct CommandServer { /* private fields */ }Expand description
Core command server implementation.
Uses CommandRegistry as source of truth for metadata. Uses KV for operational data (params, responses, indices, leases).
Implementations§
Source§impl CommandServer
impl CommandServer
Sourcepub fn new(
kv: Arc<dyn Kv>,
storage: Arc<dyn Storage>,
command_dispatcher: Arc<dyn CommandDispatcher>,
command_registry: Arc<dyn CommandRegistry>,
base_url: String,
response_signing_key: Vec<u8>,
) -> Self
pub fn new( kv: Arc<dyn Kv>, storage: Arc<dyn Storage>, command_dispatcher: Arc<dyn CommandDispatcher>, command_registry: Arc<dyn CommandRegistry>, base_url: String, response_signing_key: Vec<u8>, ) -> Self
Create a new command server instance
Sourcepub fn with_inline_limit(
kv: Arc<dyn Kv>,
storage: Arc<dyn Storage>,
command_dispatcher: Arc<dyn CommandDispatcher>,
command_registry: Arc<dyn CommandRegistry>,
base_url: String,
inline_max_bytes: usize,
response_signing_key: Vec<u8>,
) -> Self
pub fn with_inline_limit( kv: Arc<dyn Kv>, storage: Arc<dyn Storage>, command_dispatcher: Arc<dyn CommandDispatcher>, command_registry: Arc<dyn CommandRegistry>, base_url: String, inline_max_bytes: usize, response_signing_key: Vec<u8>, ) -> Self
Create a new command server with custom inline size limit
Sourcepub fn verify_response_token(
&self,
command_id: &str,
token: &str,
expires: i64,
) -> bool
pub fn verify_response_token( &self, command_id: &str, token: &str, expires: i64, ) -> bool
Verify a response token for a specific command.
Performs HMAC verification first (constant-time), then checks expiration, to avoid leaking timing information about token validity windows.
Sourcepub async fn create_command(
&self,
request: CreateCommandRequest,
) -> Result<CreateCommandResponse>
pub async fn create_command( &self, request: CreateCommandRequest, ) -> Result<CreateCommandResponse>
Create a new command.
Flow:
- Validate request
- Registry creates command metadata (source of truth)
- KV stores params blob
- KV creates pending index (for Pull) or dispatch (for Push)
Sourcepub async fn upload_complete(
&self,
command_id: &str,
upload_request: UploadCompleteRequest,
) -> Result<UploadCompleteResponse>
pub async fn upload_complete( &self, command_id: &str, upload_request: UploadCompleteRequest, ) -> Result<UploadCompleteResponse>
Mark upload as complete and dispatch command.
Sourcepub async fn get_command_status(
&self,
command_id: &str,
) -> Result<CommandStatusResponse>
pub async fn get_command_status( &self, command_id: &str, ) -> Result<CommandStatusResponse>
Get command status.
Queries registry for metadata (source of truth), KV for response blob.
Sourcepub async fn submit_command_response(
&self,
command_id: &str,
response: CommandResponse,
) -> Result<()>
pub async fn submit_command_response( &self, command_id: &str, response: CommandResponse, ) -> Result<()>
Submit response from deployment.
Stores response blob in KV, updates state in registry.
Sourcepub async fn acquire_lease(
&self,
deployment_id: &str,
lease_request: &LeaseRequest,
) -> Result<LeaseResponse>
pub async fn acquire_lease( &self, deployment_id: &str, lease_request: &LeaseRequest, ) -> Result<LeaseResponse>
Acquire leases for polling deployments.
Scans KV pending index, queries registry for metadata, creates leases in KV.
Sourcepub async fn release_lease(
&self,
command_id: &str,
lease_id: &str,
) -> Result<()>
pub async fn release_lease( &self, command_id: &str, lease_id: &str, ) -> Result<()>
Release a lease manually.
Increments attempt count in registry, returns command to Pending state.
Sourcepub async fn get_command_deployment_id(
&self,
command_id: &str,
) -> Result<Option<String>>
pub async fn get_command_deployment_id( &self, command_id: &str, ) -> Result<Option<String>>
Get the deployment_id that owns a command.
Used by the manager’s auth layer to check whether the caller has access to a specific command without fetching the full status.
Sourcepub async fn release_lease_by_id(&self, lease_id: &str) -> Result<()>
pub async fn release_lease_by_id(&self, lease_id: &str) -> Result<()>
Release a lease by lease_id only (for the API).
pub async fn store_params( &self, command_id: &str, params: &BodySpec, ) -> Result<()>
pub async fn get_params(&self, command_id: &str) -> Result<Option<BodySpec>>
pub async fn store_response( &self, command_id: &str, response: &CommandResponse, ) -> Result<()>
pub async fn get_response( &self, command_id: &str, ) -> Result<Option<CommandResponse>>
Auto Trait Implementations§
impl !RefUnwindSafe for CommandServer
impl !UnwindSafe for CommandServer
impl Freeze for CommandServer
impl Send for CommandServer
impl Sync for CommandServer
impl Unpin for CommandServer
impl UnsafeUnpin for CommandServer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more