Skip to content

InfiniteVerma/rrpc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rrpc

A rust library that implements Remote Procedure Calls. RPC is used in distributed computing to execute a function in a different address space but written as if it's a normal function call.

Just a project to help me learn rust.

Untitled-2024-02-03-1338

Usage

  1. Clone the repo

  2. Build it to create rrpc binary

cargo build
  1. Create your project
cargo new <proj>
  1. Add rrpc as a build-dependency

  2. Design your IDL and write it input.txt (syntax below)

  3. Write build.rs using which call rrpc to generate client_gen.rs and server_gen.rs

  4. Use it in your source code

Refer to example/ for a working solution.

Syntax

rrpc currently supports enum, struct and functions. Functions support just int and string as params (for now).

Example .txt file:

FUNCTION my_func
IN INT var1
IN INT var2
ENDFUNCTION

ENUM test_enum
val1 u32 1
val2 u32 2
ENDENUM

STRUCT structName
INT intvar 
STRING str
ENDSTRUCT

Plan

V1

  • Base bones (lib + test)
  • Get it running
  • String parsing

V2

  • Pass port as a variable
  • JSON serialization
  • User can choose btw string/json at init time

V3

  • Multiple clients. To speed up, server listens and spawns a short lived thread to execute each request from a pool?
  • If sync, server main thread executes and returns. If async, dispatches a worker thread to do the job

V4

  • Read from a .txt file and write to a .rs file
  • Add test infra to test multiple scenarios
  • Support enum
  • Support struct with basic data types (int and string)

V5

  • Support functions
  • Use json to pack and unpack
  • Test with dummy mains

V6

  • Crate logic cleanup. Have a single crate?
  • Import it and try using it to generate .rs files
  • Fix client packing

V7

  • Build shared libraries and link them
  • Using above .txt cons, signatures of txt functions will be available to client and definition in server
  • How would a user pass this?

V8

  • Example project using the rpc crate

V9

  • Pass enum, structs created in .txt file in the functions
  • Support synchronous functions
  • Server should use worker threads for async functions and main thread for sync functions

V10

  • Proper error handling
  • Refactor. Try to understand more about designing code in rust.

V11

  • Horizontal and vertical scaling?
  • Parse a language instead of simply structs and enums?
  • Do computation in parts and then aggregate?

End Goal

  • user imports this crate as a dependency
  • make a .txt file with the specified IDL
  • make a small 'build.rs' to generate code
    • generates all the files
  • user codes their client + server implementation around it

References

About

A rust library that implements RPC

Topics

Resources

Stars

Watchers

Forks

Languages