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 get_command_access_context(
&self,
command_id: &str,
) -> Result<Option<CommandAccessContext>>
pub async fn get_command_access_context( &self, command_id: &str, ) -> Result<Option<CommandAccessContext>>
Get the command’s canonical ownership fields for route authorization.
Sourcepub async fn get_lease_owner(
&self,
lease_id: &str,
) -> Result<Option<(String, String)>>
pub async fn get_lease_owner( &self, lease_id: &str, ) -> Result<Option<(String, String)>>
Resolve a lease_id to (command_id, owner_deployment_id) via the
lease:{lease_id} reverse index, re-verifying against the live lease
record (the reverse entry can outlive a released lease briefly, and a
command can have been re-leased under a new lease_id since).
Used by the manager’s auth layer to check that the caller may act on the deployment that holds the lease.
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>>
Sourcepub async fn reap_expired_commands(&self) -> Result<u32>
pub async fn reap_expired_commands(&self) -> Result<u32>
Expire every overdue non-terminal command recorded in the deadline index. Intended to run periodically from the hosting process.
Deadlines are otherwise only enforced lazily (status polls and lease
scans), which never reaches a command nobody polls — most notably a
PendingUpload whose params upload never completed, which has no
pending-index entry and would otherwise live forever.
Uses the conditional terminal transition, so racing a concurrent submit is safe: whoever wins, the record stays consistent. Returns the number of commands expired.
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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