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.
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.
The source code is licensed under an AGPL v3 License