| Crates.io | micro_traffic_sim |
| lib.rs | micro_traffic_sim |
| version | 0.1.0 |
| created_at | 2025-12-18 19:27:53.820071+00 |
| updated_at | 2025-12-19 13:55:32.767036+00 |
| description | gRPC interface for microscopic traffic simulation via cellular automata |
| homepage | https://github.com/LdDl/micro_traffic_sim_grpc |
| repository | https://github.com/LdDl/micro_traffic_sim_grpc |
| max_upload_size | |
| id | 1993247 |
| size | 348,909 |
This crate exposes the gRPC API for the micro traffic simulation via cellular automata. It can be used as a Rust library (crates.io), run as a server binary, and distributed via Docker. Go and Python client stubs can be generated from the same protos.
protoc available on PATHdocker for container buildsmake buildmake run-servermake build-releasetarget/release/micro_traffic_simNotes:
server. Commands above enable it when needed. Those are basically:cargo build --release --features server
0.0.0.0:50051.There are two supported paths: build locally with Dockerfile, or pull from registry.
make docker-build IMAGE=micro-traffic-sim/server TAG=latestmake docker-run IMAGE=micro-traffic-sim/server TAG=latestThe Docker image is built with a multi-stage process (Rust builder + slim runtime). It compiles with the server feature enabled.
The server image is available from both Docker Hub and GitHub Container Registry.
Docker Hub:
docker pull dimahkiin/micro-traffic-sim-server:latest
docker run --rm -it -p 50051:50051 dimahkiin/micro-traffic-sim-server:latest
GitHub Container Registry:
docker pull ghcr.io/lddl/micro-traffic-sim-server:latest
docker run --rm -it -p 50051:50051 ghcr.io/lddl/micro-traffic-sim-server:latest
Replace latest with a specific version tag (e.g., 0.1.0) for reproducible deployments.
Download pre-built binaries from the GitHub Releases page.
Available builds:
micro-traffic-sim-server-{version}-linux-amd64.tar.gzmicro-traffic-sim-server-{version}-windows-amd64.zipLinux example:
# Download and extract
wget https://github.com/LdDl/micro_traffic_sim_grpc/releases/download/v0.1.0/micro-traffic-sim-server-0.1.0-linux-amd64.tar.gz
tar -xzf micro-traffic-sim-server-0.1.0-linux-amd64.tar.gz
# Run the server
./micro_traffic_sim
Windows example:
# Extract the zip file, then run:
.\micro_traffic_sim.exe
The server listens on 0.0.0.0:50051 by default.
E.g. we can run the server in debug mode with:
cargo run --features server --bin micro_traffic_sim
Add the crate to your project: cargo add micro_traffic_sim
export MT_SIM_ADDR=127.0.1.0:50051
cargo run --example rust_client
Here more details: clients/go/README.md
export MT_SIM_ADDR=127.0.1.0:50051
# from repository root
cd ./clients/go
go run ./cmd/example/main.go
Here more details: clients/python/README.md
export MT_SIM_ADDR=127.0.1.0:50051
# from repository root
cd ./clients/python
source .venv/bin/activate
python examples/main.py
This section describes how I've used to generate client code for different languages from the proto files.
Client code generation for Golang is done via scripts/gen_go.sh. It requires protoc and protoc-gen-go to be installed and available on PATH.
chmod +x ./scripts/gen_go.sh
./scripts/gen_go.sh clients/go
cd ./clients/go
go mod init github.com/LdDl/micro_traffic_sim_grpc/clients/go
go mod tidy
cd -
Client code generation for Python is done via scripts/gen_python.sh. The script automatically creates a virtual environment and installs all dependencies.
chmod +x ./scripts/gen_python.sh
./scripts/gen_python.sh
The script:
.venv in clients/python/ (if not exists)requirements.txt*_pb2.py, *_pb2.pyi (type stubs), and *_pb2_grpc.pymicro-traffic-sim package in editable mode