ColonyOS Rust SDK
Rust SDK for ColonyOS - build distributed applications with executors that can run anywhere.
Features
- Pure Rust implementation (no C dependencies)
- Async/await support with Tokio
- secp256k1 ECDSA cryptography with SHA3-256 hashing
- Full ColonyOS API support
- WebAssembly (WASM) support for browser-based executors
Installation
Add this to your Cargo.toml:
[]
= "1.0"
= { = "1", = ["full"] }
WASM Support
For WebAssembly targets, use the wasm feature:
[]
= { = "1.0", = false, = ["wasm"] }
= "0.2.88"
= "0.4.38"
Quick Start
Building an Executor
An executor is a worker that pulls and executes processes from a ColonyOS server:
use ;
async
Submitting a Process
use FunctionSpec;
async
API Overview
See docs/API.md for the complete API reference.
Colony Management
add_colony,remove_colony,get_colony,get_colonies
Executor Management
add_executor,approve_executor,reject_executor,remove_executorget_executor,get_executors
Process Lifecycle
submit- Submit a new processassign- Wait for and assign a process to executeclose- Mark process as successfulfail- Mark process as failedget_process,get_processes,remove_process,remove_all_processesset_output- Set process output
Workflows
submit_workflow,get_processgraph,get_processgraphsremove_processgraph,remove_all_processgraphs
Logging
add_log,get_logs
Channels
channel_append,channel_read
Subscriptions (WebSocket)
subscribe_process- Wait for process state changessubscribe_channel- Real-time channel message streaming
Statistics
get_statistics
Function Registry
add_function,get_functions,get_functions_by_executor,remove_function
Blueprints
add_blueprint_definition,get_blueprint_definition,get_blueprint_definitions,remove_blueprint_definitionadd_blueprint,get_blueprint,get_blueprints,update_blueprint,remove_blueprintupdate_blueprint_status,reconcile_blueprint
Cryptography
The SDK uses pure Rust cryptography:
use crypto;
// Generate a new private key
let prvkey = gen_prvkey;
// Derive the public ID from a private key
let id = gen_id;
// Sign a message
let signature = gen_signature;
// Verify signature and recover ID
let recovered_id = recid;
assert_eq!;
// Hash a message with SHA3-256
let hash = gen_hash;
Running Tests
Start a Colonies server
Run tests
# Run all tests
# Run only unit tests
# Run integration tests (requires running server)
Examples
See the examples directory:
examples/simple_executor.rs- Basic executor implementationexamples/submit_process.rs- Submit and monitor a processexamples/workflow.rs- Submit a workflow with dependenciesexamples/wasm/- WASM executor that runs in the browser
Tutorials
- Getting Started - Step-by-step guide to building your first executor
- WASM Executor - Building a browser-based executor with WebAssembly
License
MIT