1 个不稳定版本
0.1.0 | 2021年8月1日 |
---|
#10 在 #析构函数
5KB
与您的可执行文件一起运行服务。例如,使用cargo test
自动运行和停止数据库和消息代理非常有用。
服务的自动启动和关闭依赖于ctor
包。服务注册使用linkme
包和SERVICES
静态。每个服务由一个实现了Service
特质的对象定义
use linkme::distributed_slice;
use companion_service::{Service, SERVICES};
struct Dummy;
impl Service for Dummy {
fn name(&self) -> &str {
"dummy"
}
fn start(&self) {
print!("start!");
}
fn stop(&self) {
print!("stop!");
}
}
#[distributed_slice(SERVICES)]
static DUMMY: &(dyn Service + Sync) = &Dummy;
依赖项
~1.5MB
~35K SLoC