Coder Social home page Coder Social logo

libpbrpc's Introduction

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.

libpbrpc's People

Contributors

madwyn avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.