Skip to content

An example of using the RPCz library

Notifications You must be signed in to change notification settings

golocron/rpcz_example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rpcz_example

RPCz Example is a small project that demonstrates a way of using the rpcz library for serving and talking to an RPC service.

The code in this repository is intended to be self-explanatory, and shows a few basic concepts:

  • ./proto contains the Protobuf definitions of the request and response types used by the Echo service
  • ./service/echo is an example of an RPC service which makes use of the type definitions above
  • ./cmd/echo-server creates and runs an RPCz server with an instance of the Echo service
  • ./cmd/echo-client shows an RPCz client that makes requests to the Echo service that is run by the RPCz server.

Server

To build and run the server app, use the following commands:

make echo-server

./bin/echo-server

Client

The client app can be built and run as simple as:

make echo-client

./bin/echo-client

More Options

There are a few more options for running both client and server apps:

$ ./bin/echo-client -help

Usage of ./bin/echo-client:
  -addr string
    	listen on address: ip:port or path to socket (default "localhost:10217")
  -async
    	client: run in async mode
  -cert string
    	tls: path to ssl certificate
  -key string
    	tls: path to ssl key
  -net string
    	network type: tcp or unix (default "tcp")
  -nreq int
    	client: number of requests to be made (default 100)
  -ssl-server-name string
    	tls client: name of the server (should match the one specified in the cert (default "localhost")
  -tls
    	tls: use tls or not. Requeries cert and key