Skip to main content

Crate forge_worker_sdk

Crate forge_worker_sdk 

Source
Expand description

Organizyio Forge — Rust-side building blocks for local worker processes.

This crate provides everything a product worker binary needs to participate in the Forge IPC protocol with a Go supervisor. It intentionally contains no Archivist / UFIS scan types — those live in organizy-worker.

§Quick-start

use forge_worker_sdk::{dispatcher::{WorkerHandler, ok_response, unknown_method}, framing::Encoding,
                job_registry::{EventSender, JobRegistry}, protocol::WireResponse, server};
use std::sync::Arc;

struct MyHandler;
impl WorkerHandler for MyHandler {
    fn worker_version(&self) -> &str { env!("CARGO_PKG_VERSION") }
    fn features(&self) -> Vec<String> { vec![] }
    fn handle_method(&self, req_id: &str, method: &str, params: Option<serde_json::Value>,
                     _event_tx: EventSender, _registry: Arc<JobRegistry>) -> WireResponse {
        unknown_method(req_id, method)
    }
}

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    server::run_worker("/tmp/my-worker.sock", MyHandler, Encoding::Msgpack).await
}

§Modules

  • framingFrameCodec (Tokio Decoder/Encoder) + Frame enum.
  • protocolWireRequest / WireResponse / WireEvent + control types.
  • job_registry — Thread-safe job tracking with cancel tokens and event routing.
  • dispatcherWorkerHandler trait + BaseDispatcher (control-plane handling).
  • serverrun_worker entry point; Unix socket + Windows named pipe.
  • preluderun_worker, WorkerHandler, Encoding, ErrorPayload for quick imports.

Re-exports§

pub use framing::Encoding;
pub use framing::Frame;
pub use framing::FrameCodec;
pub use framing::KIND_EVENT;
pub use framing::KIND_REQUEST;
pub use framing::KIND_RESPONSE;
pub use framing::MAX_FRAME_PAYLOAD;
pub use job_registry::cancel_pair;
pub use job_registry::CancelSignal;
pub use job_registry::CancelToken;
pub use job_registry::EventSender;
pub use job_registry::JobRegistry;
pub use job_registry::JobState;
pub use job_registry::JobStatus;
pub use dispatcher::err_response;
pub use dispatcher::ok_response;
pub use dispatcher::unknown_method;
pub use dispatcher::WorkerHandler;
pub use server::run_worker;

Modules§

dispatcher
Product-extension point and control-plane dispatcher.
framing
Length-prefixed framing: [u32 BE length][u8 kind][payload].
job_registry
Job tracking, cancel tokens, and per-connection event routing.
prelude
Narrow re-exports for small worker binaries: use forge_worker_sdk::prelude::*.
protocol
Wire protocol types shared with the Go Forge supervisor.
server
Async IPC server — accepts connections and drives the per-connection loop.