Background
Table of contents
Here is a brief outline of what has already been implemented for you, and what you will be implementing yourself.
Code
.
├── Cargo.lock
├── Cargo.toml
├── build.rs
├── proto
│ └── kv_store.proto
├── rust-toolchain.toml
└── src
├── bin
│ ├── client.rs
│ └── server.rs
├── client.rs
├── lib.rs
├── log.rs
├── rpc
│ ├── kv_store.rs
│ └── mod.rs
├── server.rs
└── test.rs
proto/kv_store.proto
Protocol buffers for the RPC server. You will need to modify this file to support additional RPCs.
src/bin/
Code for the binaries that are generated by
cargo build. You may not modify the code in this folder, but feel free to take a look at the client if you are curious how it is implemented.
src/client.rs
Helper functions for the client. You will need to modify the functions to issue the RPCs you define.
src/lib.rs
Helper functions, types, and constants. You may not modify this file.
src/log.rs
Logging utilities to help you debug your code.
src/rpc/kv_store.rs
Autogenerated stubs generated by the protocol buffer compiler. You can look here to see what methods and structs are created from the definitions you write in
proto/kv_store.proto.
src/server.rs
RPC server implementation. You will need to implement server-side stubs for the RPCs you define.
src/test.rs
RPC server tests. You may not modify this file, as these are the tests that the autograder will be checking.
Usage
To compile the code, run cargo b. This will regenerate the stubs in src/rpc/kv_store.rs and create the server and client binaries in the target/debug/ directory. To test the binaries, follow the steps below:
- Start the
serverbinary with no arguments by running./target/debug/server. - In another terminal, run the client with the appropriate subcommand:
lab_grpc 1.0.0 USAGE: client <SUBCOMMAND> OPTIONS: -h, --help Print help information -V, --version Print version information SUBCOMMANDS: echo example get help Print this message or the help of the given subcommand(s) putCurrently, only the EXAMPLE RPC is implemented (it simply adds 1 to the provided input):
client example <INPUT> client echo <MSG> client put <KEY> <VALUE> client get <KEY>For now, you can try running
target/debug/client example 1. You should see an output of2.
We strongly recommend using
tmuxto multiplex a single terminal instead of opening separate terminals for the client and server.