Giter Club home page Giter Club logo

rustnet's Introduction

rust_net

A Reactive Distributed Systems ToolBox, it provides an easy modular approach to architect your Distributed application.

Warning: this project is for learning purposes only, it should not be used in production, instead check libp2p and its rust implementation

charachteristics

  • Has minimum dependancies to third party libraries
  • Loosely coupled components
  • Extensible

install

Add this to your cargo.toml file

rust_net = "1.0.0"

Components

Components are threads that communicate by sending messages to each other via flume channels(very similar to mpsc channels), and by also publishing and subscribing to certain messages(like broadcasting messages to whomever is interetsed).

every component must implement the NetComponent trait so it could be easily hooked with other components.

Node

An intermediary among components, providing a swift and straightforward approach to initiate rust_net components. Integrate your own components seamlessly, free from concerns about the underlying intricacies of inter-component communication. The Node serves as an intermediary, receiving external calls and effectively relaying them to the designated components. It's also possible to register custom user callbacks upon the receipt of external messages.

Note: The sequence of adding components must be upheld for the Node to function accurately. ensuring the correct order is vital, for instance each Reliable Delivery Component is dependent on a Failure Detector. Disrupting this order might lead to the Node panicking even before execution begins.

Faillure Detector

  • assumes synchrony which means timing Bounds of network and processes are fixed with the timeout variable

Delivery

  • BestEffor Delivery

    • Gurantees reliability only if sender is correct
  • Reliable Delivery

    • gurantees reliability independent of whether the sender is correct or not
    • it ensures all or none of the correct nodes gets the message
    • even if the sender crashes without delivering the message to everyone, every correct node that already received the message will play the role of the sender
    • Requires a Faillure detector

Example: need to guarantee that a message is reached to all correct nodes even if if the sender crashes after sending to one correct node.

  • Uniform Reliable Delivery

    • gurantees reliability and also considers the behaviour of failed nodes,
    • reliable Delivery is faster but it doesnt gurantee if all nodes delivered the message including Failled nodes

Example

  • create a Node that has a Faillure detector,Commits Messages only if all nodes Commit, has 5 maximum peers and triggers a user defined callback whenever a Uniform Reliable Delivery message is received
let peers = vec![

        String::from("172.17.0.2:8888"),
        String::from("172.17.0.3:8888"),
        String::from("172.17.0.4:8888"),
        String::from("172.17.0.5:8888"),
    ]
let mut node = Node::new("MyNode".to_string(), 8888, 5);

node.has_faillure_detector(Duration::from_millis(5000), Duration::from_millis(5000))
    .on_receive_message(
            MessageType::UniformReliableDelivery,
            Box::new(|msg| println!("FROM USER: Triggering my callback")),
        )
    .has_uniform_reliable_delivery();

node.start().join().expect("Failled Joining node handle");
  • if the Faillure Detector detects a crash it will Publish an event and the concerned components would React to this event accordignly, in the case of Uniform Reliable Broadcast it will redistributed all previous crashed node messages to gurantee Reliability

To Run the example open a terminal and type the following:

./Build.sh
./Run.sh

this will create a mesh network with 4 nodes, each node runing in a seperate docker container:

testingFDandURB.mp4

TODO

  • Add Lamport Logical Clock component
  • Add Vector clocks component
  • Add causal delivery component

Contact

email : [email protected]

linkedin : https://www.linkedin.com/in/houadef-salih

rustnet's People

Contributors

revoltez avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.