Crates.io | fort |
lib.rs | fort |
version | 0.4.0 |
source | src |
created_at | 2019-10-05 22:03:06.466427 |
updated_at | 2020-12-21 11:00:52.762688 |
description | Proc macro attributes for Bastion runtime |
homepage | https://github.com/bastion-rs/fort |
repository | https://github.com/bastion-rs/fort |
max_upload_size | |
id | 170237 |
size | 42,286 |
Fort is proc macro attribute crate for Bastion.
[dependencies]
fort = "0.4"
bastion = "0.4"
You can directly use fort to load work onto the root supervisor with:
#[fort::root]
async fn main(_: BastionContext) -> Result<(), ()> {
println!("Running in Bastion runtime!");
Ok(())
}
Make your program fault-tolerant with fort
:
#[fort::root]
async fn main(_: BastionContext) -> Result<(), ()> {
loop {
println!("Undying main!");
panic!("Error")
}
}
You want to spawn multiple process
#[fort::root(redundancy = 10)]
async fn main(_: BastionContext) -> Result<(), ()> {
loop {
println!("Undying main!");
panic!("Error")
}
}
use std::io::Write;
use std::net::TcpListener;
#[fort::root]
async fn main(_: BastionContext) -> Result<(), ()> {
let listener = TcpListener::bind("127.0.0.1:2278").unwrap();
println!("TCP server started at 127.0.0.1:2278");
for stream in listener.incoming() {
thread::spawn(|| {
let mut stream = stream.unwrap();
stream.write_all(b"Hello World\r\n").unwrap();
panic!("Fail in thread!");
});
panic!("Fail in event loop");
}
Ok(())
}