| Crates.io | shirly-client |
| lib.rs | shirly-client |
| version | 0.1.1 |
| created_at | 2025-11-13 20:21:44.39174+00 |
| updated_at | 2025-11-13 21:26:54.585071+00 |
| description | Rust client for the Shirly job scheduler API |
| homepage | https://example.com/shirly |
| repository | https://example.com/shirly/rust-client |
| max_upload_size | |
| id | 1931824 |
| size | 68,011 |
This guide walks through connecting the Rust SDK (clients/rust) to a running Shirly deployment. It assumes the scheduler binaries are online as described in ../binaries_setup.md.
Add the client crate to your workspace by referencing the shipped path or published package:
# Cargo.toml
[dependencies]
shirly-client = { path = "../../clients/rust" }
Then fetch dependencies:
cargo fetch
The client needs the API gateway URL and (optionally) a bearer token:
export SHIRLY_API_URL="http://localhost:8080/api/v1"
export SHIRLY_API_KEY="optional-token" # omit if not required
use shirly_client::{Client, SubmitJobRequest};
use serde_json::json;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let base = std::env::var("SHIRLY_API_URL").unwrap_or_else(|_| "http://localhost:8080/api/v1".into());
let api_key = std::env::var("SHIRLY_API_KEY").ok();
let client = Client::new(&base, api_key.as_deref())?;
let req = SubmitJobRequest {
priority: Some("critical".into()), // optional: "normal" by default
payload: json!({ "kind": "email", "to": "ops@example.com" }),
max_retries: Some(3),
..Default::default()
};
let job = client.submit_job(req).await?;
println!("submitted job {}", job.job_id);
// Poll until completion
loop {
let status = client.get_job_status(&job.job_id).await?;
println!("job state {}", status.state);
if matches!(status.state.as_str(), "completed" | "failed") {
break;
}
tokio::time::sleep(std::time::Duration::from_secs(1)).await;
}
Ok(())
}
If priority is omitted it defaults to "normal". Use "critical" to target the high-priority stream queue.
The client exposes helpers for advanced scenarios:
create_scheduled_job to register cron/interval jobs.create_workflow to submit DAG-based workflows.submit_job_batch to push many jobs in one request.Refer to the crate documentation (cargo doc --open -p shirly-client) for payload structures such as CreateScheduledJobRequest and WorkflowConfigRequest.
Administrative endpoints map to hosted methods:
list_workers, get_system_overviewpause_queue, resume_queuelist_dlq, replay_dlqpause_scheduler, resume_schedulerThese calls require the API to be started with appropriate access controls (e.g., API key or reverse proxy).
The client ships with integration tests that assume a local stack:
cargo test -p shirly-client --features integration -- --test-threads=1
Use this guide when packaging or documenting the Rust SDK for downstream users.