Skip to content

tanvimoharir/multitier-rust

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Multitier Rust Prototype

This project is a minimal prototype exploring multitier programming in Rust, inspired by Scala Loci. It demonstrates how to:

  • Generate distributed RPC stubs at compile time using a procedural macro (placement!)
  • Build and run separate client and server binaries using Rust features
  • Communicate over HTTP/WebSockets (Axum + async channels)

The goal is to evaluate how Rust can support multitier code where remote calls look like normal function calls, and code placement (client vs server) is handled automatically at compile time.


✅ Key Concepts

Procedural Macro

The placement! macro expands at compile time and generates:

  • Server-side RPC handler code
  • Client-side stub functions that serialize and send RPC requests

The generated code is placed under:

target/generated

Features: server & client

This prototype uses Rust features to build client and server binaries separately:

  • --features server → Compiles server RPC handlers + starts Axum server
  • --features client → Compiles RPC stubs + WebSocket client

This ensures each binary only contains code relevant to its role.

❗ Features do not replace the procedural macro — they simply toggle build targets. The macro still does the RPC code generation.


📦 Project Structure

multitier-app/
├── src/
│   ├── api.rs        # RPC definitions + placement! macro usage
│   ├── client.rs     # Client runtime & WebSocket RPC transport
│   ├── server.rs     # Axum server, RPC execution
│   └── main.rs       # Entry point (conditionally includes client or server)
├── target/generated/ # Auto-generated RPC stubs & handlers
├── run_server.sh # Clean + build + run server
├── run_client.sh # Clean + build + run client
└── Cargo.toml
├── placement_macros/ # Procedural macro crate
│ ├── Cargo.lock
│ ├── Cargo.toml
│ └── src/
│ └── lib.rs # placement attribute macro implementation


▶️ How to Run

Start Server

./scripts/run_server.sh

Expected output:

Server running on localhost:3000

Start Client (new/different terminal)

./scripts/run_client.sh

Expected output:

Connected
<remote function call results>

🔍 What to Look For

  • Auto-generated code in target/generated/

🧠 Future Directions

Potential improvements toward a generic distributed runtime:

  • Multiple server/client nodes
  • Dynamic node discovery & failure handling
  • Typed ties / peer relations (like Scala Loci)
  • Verification strategy (protocol + macro correctness)

🎯 Purpose

This prototype is not a framework — it's a research scaffold to understand how Rust might support structured distributed programming with:

  • Compile‑time placement checking
  • Generated communication code
  • Clean RPC ergonomics

👩‍💻 References

  • https://scala-loci.github.io/
  • A Survey of Multitier Programming - PASCAL WEISENBURGER, JOHANNES WIRTH, and GUIDO SALVANESCHI, Technische Universität Darmstadt, Germany
  • Distributed System Development with ScalaLoci - PASCAL WEISENBURGER, MIRKO KÖHLER, GUIDO SALVANESCHI, Technische Universität Darmstadt, Germany

About

TBA

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages