/elevator-async

This is a simple study on how to build an actor-based async parallel elevator system in Rust with tokio

Primary LanguageRustGNU Affero General Public License v3.0AGPL-3.0

Elevator System

AGPL-v3

This is a simple study on how to build an actor-based async parallel elevator system in Rust.

It uses tokio for async IO with the tokio::sync::mpsc channel for message passing.

How to use

First run the server with:

cargo run

Please note that the elevator system will only print the state of the system to the console, if you run without --release flag. This enables the cfg(debug_assertions) macro in the code base.

This will bind the server to port 3000. Then open a new terminal and send commands to the socket:

# Linux
nc localhost 3000
# macOS
netcat localhost 3000

The commands are JSON objects. To simulate an:

  • Floor switch input: {"FloorSwitch":{"floor":3,"direction":"Up"}}
  • Elevator switch input: {"ElevatorSwitch":{"destination":10}}

Then watch your elevator spam your console with messages.

License

The source code is licensed under an AGPL v3 License

AGPL-v3