mirror of https://github.com/bastion-rs/fort
45ae8e642a | ||
---|---|---|
.github | ||
examples | ||
src | ||
.gitignore | ||
Cargo.toml | ||
LICENSE-APACHE | ||
LICENSE-MIT | ||
README.md |
README.md
Fort
Fort is proc macro attribute crate for Bastion.
Usage
[dependencies]
fort = "0.1"
bastion = "0.2.*"
You can directly use fort to load work onto the root supervisor with:
#[fort::root]
fn main() {
println!("Running in Bastion runtime!");
}
Make your program fault-tolerant with fort
:
#[fort::root]
fn main() {
loop {
println!("Undying main!");
panic!("Error")
}
}
Example TCP Server
use std::io::Write;
use std::net::TcpListener;
#[fort::root]
fn main() {
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() {
let mut stream = stream.unwrap();
stream.write(b"Hello World\r\n").unwrap();
panic!("Fail here!");
}
}