maelstrom_rs 0.1.0

A Rust crate to write toy distributed systems with Maelstrom as Actors
Documentation
  • Coverage
  • 100%
    39 out of 39 items documented1 out of 12 items with examples
  • Size
  • Source code size: 29.63 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 565.49 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 26s Average build duration of successful builds.
  • all releases: 26s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • PierreZ/maelstrom-rs
    12 4 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • PierreZ

maelstrom-rs

A crate that is providing an Actor model to develop toy distributed systems using Maelstrom.

What is Maelstrom?

Maelstrom is a workbench for learning distributed systems by writing your own. It uses the Jepsen testing library to test toy implementations of distributed systems.

Getting started

Examples following the official documentations can be found in the examples folder.

The crate exposes:

  • an Actor trait that you can implement:
  • a Runtime, that will run it.

Examples

use maelstrom_rs::actor::Actor;
use maelstrom_rs::message::{Request, Response};
use maelstrom_rs::error::Error;
use maelstrom_rs::runtime::Runtime;

fn main() {
   let node = EchoActor { node_id: None };
   let mut runtime = Runtime::new(Box::new(node));
   // runtime.start();
}

struct EchoActor {
    node_id: Option<String>,
}

impl Actor for EchoActor {
  fn init(&mut self, node_id: &str, _node_ids: Vec<String>) -> Result<(), Error> {
       self.node_id = Some(String::from(node_id));
       eprintln!("node {} initiated", node_id);
       Ok(())
   }

   fn receive(&mut self, message: &Request) -> Result<Vec<Response>, Error> {
       match message.message_type.as_str() {
           "echo" => unimplemented!(),
           _ => unimplemented!(),
        }
   }
}