Skip to content

Rust crates for distributed algorithms using actor model

Notifications You must be signed in to change notification settings

veminovici/aabel-nexus-rs

Repository files navigation

Simplee > Aabel > Nexus

CI GitHub top language License:MIT GitHub code size in bytes GitHub last commit GitHub watchers

A set of crates for distributed algorithms. They use an actor model and the actix actor framework.

Crates

  • The nexus-ids crate implements the actor and session identifiers.
  • The nexus-hashmap crate implements several extensions for the HashMap.
  • The nexus-list crate implements an extension to list, by implementing Add, AddAssign, Sub, and SubAssign traits.
  • The nexus-lattice crate defines Join and Meet traits, basic operations in the lattice theory.
  • The nexus-counters crate implements a distributed counter. In our case it will be used to increment different values.
  • The nexus-session-store crate implements a store for session. Each session can store values for each node.
  • The nexus-message crate defines the MessageExt trait, an extention for the actix::Message trait. The crate also defines the kernel and node control messages.
  • The nexus-observer crate implements the Observer actor. The actor counts the number of successful and failed operations during the execution of the run.
  • The nexus-kernel crate implements the Kernel actor. The actor receives and delivers messages to other actors.
  • The nexus-node crate defines the ActorExt trait, an extention for the actix::Actor trait.

Examples

You can find an example of how to use the Observer actor at in the test_observer file.

let observer = Observer::start();

// Increment success for key1
let msg = OpSucceededMsg::new("key1");
let _ = observer.send(msg).await.unwrap();

let msg = OpSucceededMsg::new("key1");
let _ = observer.send(msg).await.unwrap();

// Increment fail for key2
let msg = OpFailedMsg::new("key2");
let _ = observer.send(msg).await.unwrap();

eprintln!("Sending keys message");

let msg = KeysMsg;
let res = observer.send(msg).await.unwrap();

eprintln!("keys: {:?}", res.keys());

A second example show how to use the kernel actor, which you can find it in the test_kernel file.

let kernel = Kernel::new().start();
let actor = MyActor::new().start();

// Register the actor (it will be the destination of a message)
let aid = 2.into();
let msg = Register::new(aid, actor.downgrade().recipient());
let _ = kernel.send(msg).await.unwrap();

// Dispatch a message to the actor we just created
let fid = Aid::from(1);
let tid = aid; // this is the aid of the actor we just created
let sid = Sid::from(fid);
let msg = Dispatch::new(fid, tid, sid);
let _ = kernel.send(msg).await.unwrap();

// Validate that the actor received and processed the message
let valid = actor.send(Validate).await.unwrap();
assert!(valid);

// Unregister the actor
let msg = Unregister::new(aid);
let _ = kernel.send(msg).await.unwrap();

About

Code designed and written on the beautiful island of Saaremaa, Estonia.

About

Rust crates for distributed algorithms using actor model

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages