| Crates.io | volli-commands |
| lib.rs | volli-commands |
| version | 0.1.12 |
| created_at | 2026-01-19 02:18:50.022501+00 |
| updated_at | 2026-01-19 02:18:50.022501+00 |
| description | Command implementations for the Volli CLI |
| homepage | |
| repository | https://github.com/wouterken/volli |
| max_upload_size | |
| id | 2053555 |
| size | 307,355 |
A distributed fleet command execution system for network diagnostics and monitoring.
The volli-commands crate provides a comprehensive framework for executing network diagnostic commands across a fleet of machines. It supports streaming results, fleet-wide distribution, permission management, and multiple output formats.
The system is built around several core components:
use volli_commands::{Command, CommandResultSender, CommandTarget, CommandOptions};
// Create a command
let ping_command = Command::Ping;
// Set up result handling
let (sender, mut receiver) = CommandResultSender::new("req_123".to_string());
// Execute the command
let args = vec!["example.com".to_string(), "4".to_string()];
ping_command.execute(&args, sender).await?;
// Handle streaming results
while let Some(header) = receiver.header_receiver.recv().await {
println!("Command started: {:?}", header);
}
while let Some(stream) = receiver.stream_receiver.recv().await {
println!("Stream data: {:?}", stream);
}
while let Some(footer) = receiver.footer_receiver.recv().await {
println!("Command completed: {:?}", footer);
}
use volli_commands::{CommandDistributor, CommandTarget, CommandOptions};
// Create distributor
let distributor = CommandDistributor::new("manager1".to_string());
// Execute across fleet
let mut updates = distributor.execute_command(
"ping".to_string(),
vec!["example.com".to_string()],
CommandTarget::AllWorkers,
CommandOptions {
timeout_secs: 30,
max_concurrent: None,
tags: HashMap::new(),
wire_version: Some(volli_commands::wire::COMMAND_WIRE_VERSION),
},
"admin".to_string(),
).await?;
// Handle fleet updates
while let Some(update) = updates.recv().await {
match update {
FleetCommandUpdate::Started { target_count, .. } => {
println!("Started on {} targets", target_count);
}
FleetCommandUpdate::WorkerCompleted { worker_id, result, .. } => {
println!("Worker {} completed: {:?}", worker_id, result.status);
}
FleetCommandUpdate::Completed { results, .. } => {
println!("Fleet execution completed: {}/{} successful",
results.successful, results.total_targets);
break;
}
_ => {}
}
}
use volli_commands::{PermissionManager, PrivilegeLevel};
let mut pm = PermissionManager::new();
// Check if ping can be executed (requires network capabilities)
if pm.has_privilege_level(PrivilegeLevel::NetworkCapabilities) {
println!("Can execute ping with raw sockets");
} else {
println!("Will fall back to system ping");
}
// Check specific capabilities
let capabilities = pm.check_capabilities(&[
Capability::RawSockets,
Capability::NetworkAdmin,
]).await?;
println!("Available capabilities: {:?}", capabilities);
use volli_commands::{FleetPingResults, OutputFormat, create_formatter};
// Create results (normally from fleet execution)
let results = FleetPingResults {
target: "example.com".to_string(),
total_nodes: 10,
responding_nodes: 9,
// ... other fields
};
// Format as table
let formatter = create_formatter(OutputFormat::Table);
let output = formatter.format_ping_aggregated(&results)?;
println!("{}", output);
// Format as JSON
let formatter = create_formatter(OutputFormat::Json);
let json_output = formatter.format_ping_aggregated(&results)?;
println!("{}", json_output);
Run the test suite:
cargo test -p volli-commands
All tests include:
This crate integrates with the broader Volli ecosystem:
Licensed under the BUSL-1.1 license. See the LICENSE file for details.