{"id":50714930,"url":"https://github.com/snower/ruslock","last_synced_at":"2026-06-09T18:30:29.785Z","repository":{"id":358889352,"uuid":"1238603558","full_name":"snower/ruslock","owner":"snower","description":"slock rust client","archived":false,"fork":false,"pushed_at":"2026-05-19T12:42:15.000Z","size":125,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-19T15:41:41.476Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/snower.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-05-14T09:18:44.000Z","updated_at":"2026-05-19T12:42:21.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/snower/ruslock","commit_stats":null,"previous_names":["snower/ruslock"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/snower/ruslock","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snower%2Fruslock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snower%2Fruslock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snower%2Fruslock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snower%2Fruslock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/snower","download_url":"https://codeload.github.com/snower/ruslock/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snower%2Fruslock/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34121020,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-09T02:00:06.510Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-06-09T18:30:28.187Z","updated_at":"2026-06-09T18:30:29.776Z","avatar_url":"https://github.com/snower.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ruslock\n\nRust client for `slock`.\n\nThe crate exposes two independent APIs:\n\n- `ruslock::blocking` uses `std::net::TcpStream` and a reader thread.\n- `ruslock::aio` uses `tokio` and `async/await`.\n\nThe blocking API does not wrap a tokio runtime. Both APIs share the same protocol,\nLockData, error, and primitive logic.\n\n## Blocking Quickstart\n\n```rust,no_run\nuse ruslock::{LockData, Result};\n\nfn main() -\u003e Result\u003c()\u003e {\n    let client = ruslock::blocking::Client::connect(\"127.0.0.1:5658\")?;\n    let mut lock = client.lock(\"order:1001\", 5, 10);\n\n    lock.acquire_with_data(LockData::set(\"aaa\"))?;\n    lock.release()?;\n    client.close();\n    Ok(())\n}\n```\n\n## Async Quickstart\n\n```rust,no_run\nuse ruslock::{LockData, Result};\n\n#[tokio::main]\nasync fn main() -\u003e Result\u003c()\u003e {\n    let client = ruslock::aio::Client::connect(\"127.0.0.1:5658\").await?;\n    let mut lock = client.lock(\"order:1001\", 5, 10);\n\n    lock.acquire_with_data(LockData::set(\"aaa\")).await?;\n    lock.release().await?;\n    client.close().await;\n    Ok(())\n}\n```\n\n## Replset\n\n```rust,no_run\nuse ruslock::Result;\n\nfn main() -\u003e Result\u003c()\u003e {\n    let client = ruslock::blocking::ReplsetClient::connect(\n        \"127.0.0.1:5658,127.0.0.1:5659\",\n    )?;\n    let mut lock = client.lock(\"replset-key\", 5, 10);\n    lock.acquire()?;\n    lock.release()?;\n    client.close();\n    Ok(())\n}\n```\n\n## Runtime Client Selection\n\nUse `ClientHandle` when deployment is selected from configuration. A single\nnode creates a normal client backend, while multiple nodes create a replset\nbackend. The business code after construction is identical.\n\n```rust,no_run\nuse ruslock::Result;\n\nfn run(nodes: String) -\u003e Result\u003c()\u003e {\n    let client = ruslock::blocking::ClientHandle::connect(nodes)?;\n    let mut lock = client.lock(\"order:1001\", 5, 10);\n\n    lock.acquire()?;\n    lock.release()?;\n    client.close();\n    Ok(())\n}\n```\n\n```rust,no_run\nuse ruslock::Result;\n\nasync fn run(nodes: String) -\u003e Result\u003c()\u003e {\n    let client = ruslock::aio::ClientHandle::connect(nodes).await?;\n    let mut lock = client.lock(\"order:1001\", 5, 10);\n\n    lock.acquire().await?;\n    lock.release().await?;\n    client.close().await;\n    Ok(())\n}\n```\n\n## LockData\n\n```rust\nuse ruslock::LockData;\n\nlet data = LockData::pipeline(vec![\n    LockData::set(\"aaa\"),\n    LockData::append(\"bbb\"),\n]);\nlet encoded = data.encode().unwrap();\nassert_eq!(encoded[4], ruslock::protocol::constants::LOCK_DATA_COMMAND_TYPE_PIPELINE);\n```\n\n## Feature Flags\n\n- `blocking`: synchronous client facade.\n- `aio`: async tokio client facade.\n- `replset`: replset facade.\n- default: `[\"blocking\", \"aio\", \"replset\"]`.\n\n## Tests\n\nUnit and mock transport tests do not require a server:\n\n```powershell\ncargo test --all-features\n```\n\nJava parity and integration tests use a local `slock` endpoint. Defaults match\nthe Java client tests:\n\n```powershell\n$env:SLOCK_TEST_HOST = \"127.0.0.1\"\n$env:SLOCK_TEST_PORT = \"5658\"\ncargo test --all-features --test java_parity_blocking --test java_parity_async --test java_parity_replset --test java_parity_lock_data --test java_parity_flow_tree\n```\n\nThe benchmark parity test is ignored by default:\n\n```powershell\ncargo test --all-features --test java_parity_benchmark -- --ignored\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsnower%2Fruslock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsnower%2Fruslock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsnower%2Fruslock/lists"}