Code Monkey home page Code Monkey logo

benchmarks's Introduction

rpclib MIT Build Status Build status Coverage Status Coverity Gitter

Status

rpclib is looking for maintainers

If you're looking for a similar library with support for JSON-RPC and async operations, check out packio.

Overview

rpclib is a RPC library for C++, providing both a client and server implementation. It is built using modern C++14, and as such, requires a recent compiler. Main highlights:

  • Expose functions of your program to be called via RPC (from any language implementing msgpack-rpc)
  • Call functions through RPC (of programs written in any language)
  • No IDL to learn
  • No code generation step to integrate in your build, just C++

Look&feel

Server

#include <iostream>
#include "rpc/server.h"

void foo() {
    std::cout << "foo was called!" << std::endl;
}

int main(int argc, char *argv[]) {
    // Creating a server that listens on port 8080
    rpc::server srv(8080);

    // Binding the name "foo" to free function foo.
    // note: the signature is automatically captured
    srv.bind("foo", &foo);

    // Binding a lambda function to the name "add".
    srv.bind("add", [](int a, int b) {
        return a + b;
    });

    // Run the server loop.
    srv.run();

    return 0;
}

When srv.run() is called, rpclib starts the server loop which listens to incoming connections and tries to dispatch calls to the bound functions. The functions are called from the thread where run was called from. There is also async_run that spawns worker threads and returns immediately.

Client

#include <iostream>
#include "rpc/client.h"

int main() {
    // Creating a client that connects to the localhost on port 8080
    rpc::client client("127.0.0.1", 8080);

    // Calling a function with paramters and converting the result to int
    auto result = client.call("add", 2, 3).as<int>();
    std::cout << "The result is: " << result << std::endl;
    return 0;
}

Status

All planned 1.0.0 features are done and tested; the current state is production-ready.

Who uses rpclib?

This list is updated as I learn about more people using the library; let me know if you don't want your project listed here.

Thanks

rpclib builds on the efforts of fantastic C++ projects. In no particular order:

Shoutouts to

benchmarks's People

Contributors

kentonv avatar sztomi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

benchmarks's Issues

Doesn't build on Ubuntu 16.04

Hi,

Thank you for creating this benchmark.

I tried building it on Ubuntu 16.04 64bit with the following config:

  • gcc 5.4
  • clang 5.0.1, from http://apt.llvm.org
  • cmake 3.5.1
  • conan 0.29.1, installed via sudo pip3 install conan

However, I got the following error:

$ git clone [email protected]:rpclib/benchmarks.git rpclib-benchmark
$ cd rpclib-benchmark
$ mkdir build && cd build
$ conan install .. --build missing
libevent/2.0.22@theirix/stable requirement OpenSSL/[>1.0.2a,<1.0.3]@lasote/stable overriden by thrift/0.9.3@sztomi/testing to OpenSSL/1.0.2g@lasote/stable
Version range '>1.0.2a,<1.0.3' required by 'libevent/2.0.22@theirix/stable' valid for downstream requirement 'OpenSSL/1.0.2g@lasote/stable'
WARN: Conflict in grpc/1.1.0@sztomi/testing
    Requirement OpenSSL/1.0.2i@lasote/stable conflicts with already defined OpenSSL/1.0.2g@lasote/stable
    Keeping OpenSSL/1.0.2g@lasote/stable
    To change it, override it in your base requirements
PROJECT: Installing /media/data/code/github/rpclib-benchmark
Requirements
    Boost/1.60.0@lasote/stable from conan-transit
    OpenSSL/1.0.2g@lasote/stable from conan-transit
    autoconf/2.69@sztomi/testing from conan-transit
    automake/1.15@sztomi/testing from conan-transit
    bison/3.0.4@sztomi/testing from conan-transit
    bzip2/1.0.6@lasote/stable from conan-transit
    capnproto/0.5.3@lasote/stable from conan-transit
    flex/2.6.3@sztomi/testing from conan-transit
    google-benchmark/1.1.0@cpace6/stable from conan-transit
    grpc/1.1.0@sztomi/testing from conan-transit
    libevent/2.0.22@theirix/stable from conan-transit
    libtool/2.4.6@sztomi/testing from conan-transit
    m4/latest@sztomi/testing from conan-transit
    pkg-config/0.29.1@sztomi/testing from conan-transit
    rpclib/1.0.0@sztomi/testing from conan-transit
    thrift/0.9.3@sztomi/testing from conan-transit
    zlib/1.2.8@lasote/stable from conan-transit
Packages
    Boost/1.60.0@lasote/stable:ca4920553084963bd998d7690b348e9806f8f446
    OpenSSL/1.0.2g@lasote/stable:c5d4f5a0443cee7ecb3c66e5b6736ad9745ead7c
    autoconf/2.69@sztomi/testing:fe389e50c4bb925b7cb51de74be9ac223b79e6df
    automake/1.15@sztomi/testing:873714f9ff21f6af4d44aafc6d007613a7e4cc3a
    bison/3.0.4@sztomi/testing:fe389e50c4bb925b7cb51de74be9ac223b79e6df
    bzip2/1.0.6@lasote/stable:0bb6f9a537a76b4aa6af7fb4dbef0aa6dddcabf4
    capnproto/0.5.3@lasote/stable:0af8d75efe38bba3cbf8f16eed4218fe0d5f9605
    flex/2.6.3@sztomi/testing:9aeda9e19058c99b9a22043c3a3f60bee7cfbeab
    google-benchmark/1.1.0@cpace6/stable:a2069270db732b89d402b71d74949d09f29d3535
    grpc/1.1.0@sztomi/testing:544e7cf9ec5368cfff8c992429499f206c66d06e
    libevent/2.0.22@theirix/stable:c63329b52ce2d11e4190404aef6b363b6c78b0a9
    libtool/2.4.6@sztomi/testing:fe389e50c4bb925b7cb51de74be9ac223b79e6df
    m4/latest@sztomi/testing:a2069270db732b89d402b71d74949d09f29d3535
    pkg-config/0.29.1@sztomi/testing:a2069270db732b89d402b71d74949d09f29d3535
    rpclib/1.0.0@sztomi/testing:a2069270db732b89d402b71d74949d09f29d3535
    thrift/0.9.3@sztomi/testing:d62b80f979e42c0f117c743b133c559bd39defa4
    zlib/1.2.8@lasote/stable:8094f5147bc9378351237bfd795472578065861f

bzip2/1.0.6@lasote/stable: Building your package in /path/to/my/home/dir/.conan/data/bzip2/1.0.6/lasote/stable/build/0bb6f9a537a76b4aa6af7fb4dbef0aa6dddcabf4
bzip2/1.0.6@lasote/stable: Copying sources to build folder
bzip2/1.0.6@lasote/stable: Generator cmake created conanbuildinfo.cmake
bzip2/1.0.6@lasote/stable: Calling build()
bzip2/1.0.6@lasote/stable:
bzip2/1.0.6@lasote/stable: ERROR: Package '0bb6f9a537a76b4aa6af7fb4dbef0aa6dddcabf4' build failed
bzip2/1.0.6@lasote/stable: WARN: Build folder /path/to/my/home/dir/.conan/data/bzip2/1.0.6/lasote/stable/build/0bb6f9a537a76b4aa6af7fb4dbef0aa6dddcabf4
ERROR: bzip2/1.0.6@lasote/stable: Error in build() method, line 36
	cmake = CMake(self.settings)
	ConanException: First argument of CMake() has to be ConanFile. Use CMake(self)

I'm not sure what I did wrong.

Could you please have a look at this problem?

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.