gRPCaesar is a microservice built with gRPC. It has two components:
- gRPCaesar client: Written in Go, the client accepts input from command-line flags and makes a request to the Cipher service with that input.
- Cipher service: Written in Node.js, the service encodes or decodes the received text using the Caesar cipher encryption technique.
The Cipher service interface defined in the cipher.proto file includes one simple RPC service method: ProcessMessage.
This method accepts a request consisting of a string text, an integer shift, and a boolean denoting encryption or decryption. It returns a response consisting of a string message.
Flag | Description | Value | Default Value |
---|---|---|---|
-t |
text, a quote-enclosed string | "Et tu brute" |
"hello world" |
-s |
shift, an integer | 3 |
0 |
-m |
mode, a string character "e" or "d" (encode or decode) | e |
e |
For example:
./grpcaesar -t "Et tu brute" -s 3 -m e
Start server
cd service
npm install
node server.js
Start client
cd client
./grpcaesar -t "hi" -s 2 -m e #encode "hi" with a shift of 2
./grpcaesar -t "jk" -s 2 -m d #decode "jk" with a shift of 2
Rebuild the Go client executable
cd client
go build -o grpcaesar
Run the Go code without executable
cd client
go run main.go cipher.pb.go -t "hi" -s 2 -m e #encode "hi" with a shift of 2
Run Go unit tests
cd client
go test
For more information on gRPC with Node.js and Go, see the official gRPC documentation.