Skip to content
forked from madwyn/libpbrpc

libpbrpc is one of the smallest C++ Protobuf RPC library

License

Notifications You must be signed in to change notification settings

connLAN/libpbrpc

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

libpbrpc

The aim is to build a minimal protobuf RPC lib using Google's Protocol Buffers.

libpbrpc is flexible as it is not bound to the http server, it's a lightweight middleware.

Dependencies

The only dependency is Protocol Buffers.

How to use

To use this lib is really simple. First define ServiceManager some where in your code.

ServiceManager srvMan;

Then the ServiceManager only provides two functions:

  1. Register a service:

    void regService(Service *service);
  2. Handle the RPC message:

    void handleRPC(const char *data, const size_t len, string &ret);
    • data is the raw Protobuf binary,
    • len is the length of the data,
    • ret is the result generated, you can send it back directly. (Note: use ret.length() to get the correct length.)

How it's made

The over all design is really simple:

  • Protocol. The RPC protocol is defined in the "pbrpc.proto" file. The protocol took the JSON RPC 2.0 as a reference.
  • Services. The RPC server provides several Services, and each Service has some Methods.
  • Methods. Each Method should have input(params) and output(results).

Examples

Please take a look of my other repository pbrpc as a demo which implements a simple RPC server.

Limitations

One major limitation of this library is it's synchronous. It is possible to adapt task queue for asynchronous message handling.

About

libpbrpc is one of the smallest C++ Protobuf RPC library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 61.5%
  • Protocol Buffer 20.3%
  • CMake 17.5%
  • C 0.7%