Skip to content

A simple RPC demo implemented in Go (server) and Rust (client).

License

Notifications You must be signed in to change notification settings

LingkKang/rpc_demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A simple RPC demo

A simple RPC demo implemented in Go and Rust.

The server is already hosted on test.lingkang.dev:8333 for testing.

The rustdoc of client side is hosted on lingkang.dev/rpc_demo/.

See this blog post for more details: Implement RPC demo from scratch - Lingkang's Blog.

Table of Contents

1. Server

The server side is implemented in Go, under the ./server directory.

1.1. Run

To run it locally:

cd server
go run cmd/main.go

Or build and run the binary:

cd server
go build -o target/rpc_demo cmd/main.go
./target/rpc_demo

Or use nohup to run it in the background.

nohup ./target/rpc_demo > ./target/output.txt 2>&1 & # keep the output
# or
nohup ./target/rpc_demo > /dev/null 2>&1 & # discard the output

1.2. Output

Golang built-in module log is used to provide basic running information.

The running output of the server side.


2. Client

The client side is implemented in Rust, under the ./client directory.

2.1. Run

It can be run locally:

cd client
cargo run

2.2. Output

A naive implementation of logger based on log crate is used in this demo:

The running output of the client side


3. CLOC

Count lines of code:

-------------------------------------------------------------------------------
Language                     files          blank        comment           code
-------------------------------------------------------------------------------
Go                               5             60             50            347
Rust                             8             84            120            320
Markdown                         2             51              0            119
YAML                             2             13              2             45
PowerShell                       1              7              0              8
TOML                             1              2              1              7
-------------------------------------------------------------------------------
SUM:                            19            217            173            846
-------------------------------------------------------------------------------

About

A simple RPC demo implemented in Go (server) and Rust (client).

Topics

Resources

License

Stars

Watchers

Forks