2 unstable releases
Uses new Rust 2024
| 0.3.0 | Dec 13, 2025 |
|---|---|
| 0.2.0 | Dec 11, 2025 |
#3 in #multi-service
58KB
884 lines
High-level plugin runtime for rapace
This crate provides boilerplate-free APIs for building rapace plugins that communicate via SHM transport. It handles all the common setup that every plugin needs:
- CLI argument parsing (--shm-path or positional args)
- Waiting for the host to create the SHM file
- SHM session setup with standard configuration
- RPC session creation with correct channel ID conventions
- Service dispatcher setup
Single-service plugins
For simple plugins that expose a single service:
use rapace_plugin::{run, ServiceDispatch};
use rapace::{Frame, RpcError};
use std::future::Future;
use std::pin::Pin;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let server = MyServiceServer::new(());
run(server).await?;
Ok(())
}
Multi-service plugins
For plugins that expose multiple services:
use rapace_plugin::{run_multi, DispatcherBuilder, ServiceDispatch};
use rapace::{Frame, RpcError};
use std::future::Future;
use std::pin::Pin;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
run_multi(|builder| {
builder
.add_service(MyServiceServer::new(()))
.add_service(AnotherServiceServer::new(()))
}).await?;
Ok(())
}
Configuration
By default, the plugin uses a standard SHM configuration that should match most hosts:
- ring_capacity: 256 descriptors
- slot_size: 64KB
- slot_count: 128 slots (8MB total)
The plugin always uses even channel IDs starting from 2 (following rapace convention where plugins use even IDs and hosts use odd IDs).
Dependencies
~28–46MB
~610K SLoC