{"id":15787490,"url":"https://github.com/dunnock/orchestrator","last_synced_at":"2025-03-31T17:49:28.889Z","repository":{"id":62441064,"uuid":"234342409","full_name":"dunnock/orchestrator","owner":"dunnock","description":"Orchestion of command line processes for local dev usage via IPC channels","archived":false,"fork":false,"pushed_at":"2020-01-20T10:52:53.000Z","size":63,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-27T08:59:56.368Z","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/dunnock.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}},"created_at":"2020-01-16T14:49:28.000Z","updated_at":"2020-01-20T10:52:55.000Z","dependencies_parsed_at":"2022-11-01T22:01:55.703Z","dependency_job_id":null,"html_url":"https://github.com/dunnock/orchestrator","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dunnock%2Forchestrator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dunnock%2Forchestrator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dunnock%2Forchestrator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dunnock%2Forchestrator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dunnock","download_url":"https://codeload.github.com/dunnock/orchestrator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246513168,"owners_count":20789848,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":"2024-10-04T21:20:37.269Z","updated_at":"2025-03-31T17:49:28.851Z","avatar_url":"https://github.com/dunnock.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"Execute and orchestrate command line utils.\n\nBased on io streams and optionally ipc-channel orchestrator is intended for starting and orchestrating programs.\n\nThis repo cannot be used for running production critical tasks, rather it is for local dev or non critical orchestration.\n\nWorking on linux and Mac OS X, Windows is not supported due to dependency on ipc_channels.\n\n\n# Basic example\n\n```rust\nuse tokio::process::{Command};\nuse ipc_orchestrator::orchestrator;\n\n#[tokio::main]\nasync fn main() -\u003e anyhow::Result\u003c()\u003e {\n    let mut orchestrator = orchestrator().ipc(false);\n    orchestrator.start(\"start\", \u0026mut Command::new(\"echo\"));\n    orchestrator.connect().await\n}\n```\n\n# IPC routing example\n\n```shell\ncargo run --example=orchestrate\n```\n\n```rust\n#[tokio::main]\nasync fn main() -\u003e anyhow::Result\u003c()\u003e {\n    let mut orchestrator = orchestrator().ipc(true);\n\n    // Start pipeline: generate random f64 [0;1) -\u003e sum -\u003e write to stdout every 10_000 times\n    let mut cmd = Command::new(\"cargo\");\n    orchestrator.start(\"generate\", cmd.arg(\"run\").arg(\"--example=generate\"))\n        .expect(\"failed to start generate\");\n    let mut cmd = Command::new(\"cargo\");\n    orchestrator.start(\"sum\", cmd.arg(\"run\").arg(\"--example=sum\"))\n        .expect(\"failed to start sum\");\n    let mut cmd = Command::new(\"cargo\");\n    orchestrator.start(\"mul\", cmd.arg(\"run\").arg(\"--example=write\"))\n        .expect(\"failed to start mul\");\n\n    // Connect log handlers and IPC handlers\n    let mut orchestra = match orchestrator.connect().await {\n        Err(_) =\u003e std::process::exit(1),\n        Ok(o) =\u003e o,\n    };\n\n    // Route IPC messages\n    orchestra.pipe_bridges(\"generate\", \"sum\")?;\n    orchestra.pipe_bridges(\"sum\", \"write\")?;\n\n    // Killing it hard since some spawned futures might still run\n    match orchestra.run().await {\n        Err(_) =\u003e std::process::exit(1),\n        _ =\u003e Ok(()),\n    }\n}\n```\n\n\n# Custom logger\n\n```rust\nuse tokio::process::{Command, ChildStdout};\nuse ipc_orchestrator::Orchestrator;\nuse std::sync::atomic::{AtomicBool, Ordering};\nstatic CALLED: AtomicBool = AtomicBool::new(false);\nuse tokio::io::{AsyncBufReadExt, BufReader};\n\n// custom logs processor\nasync fn mock_log_handler(reader: ChildStdout, name: String) -\u003e anyhow::Result\u003c()\u003e {\n   let mut reader = BufReader::new(reader).lines();\n   assert_eq!(reader.next_line().await?.unwrap(), \"testbed\");\n   CALLED.store(true, Ordering::Relaxed);\n   Ok(())\n}\n\n#[tokio::main]\nasync fn main() {\n    let mut orchestrator = Orchestrator::from_handlers(mock_log_handler).ipc(false);\n    let mut cmd = Command::new(\"echo\");\n    cmd.arg(\"testbed\");\n    orchestrator.start(\"start\", \u0026mut cmd);\n    let orchestra = orchestrator.connect().await.unwrap();\n    // it supposes never existing processes\n    // hence it will give error on when any process exit or stdout was closed\n    orchestra.run().await.unwrap_err();\n    assert!(CALLED.load(Ordering::Relaxed));\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdunnock%2Forchestrator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdunnock%2Forchestrator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdunnock%2Forchestrator/lists"}