Skip to content

Simple Lightweight Failure Detection protocol for rust based on SWIM

License

Notifications You must be signed in to change notification settings

pathivu/nilai-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nilai-rs

Nilai is a simple, lightweight embedded failure detection protocol based on SWIM. Nilai detects the failure state by pinging every node in a cluster by round-robin fashion.

It spreads the node state by infection style. Nilai is lightweight because it's built on top of tokio runtime.

Nilai derived from thamizh word (நிலை), which means state.

Example

use failure::Error;
use nilai::builder;
use nilai::types;
use std::thread;
use std::time::Duration;

fn do_main() -> Result<(), Error> {
    let nilai_builder = builder::NilaiBuilder::new("127.0.0.1:5001".parse()?);
    let closer = nilai_builder
        .alive_delegate(Box::new(|_: types::Node| println!("new node joined")))
        .execute()?;
    // nilai is running so block the current thread.
    thread::sleep(Duration::from_secs(5));
    closer.stop();
    Ok(())
}

fn main() {
    match do_main() {
        Err(err) => {
            println!("not able to run nilai handler {:?}", err);
        }
        _ => {}
    }
}

About

Simple Lightweight Failure Detection protocol for rust based on SWIM

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages