ZhHong / Nebula-cpp

An event driven asynchronous C++ framework based on a custom Pb protocol supports both HTTP and websocket protocols.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

English | 中文                 Bwar's blog.

Nebula : An event driven asynchronous C++ framework

Author Platform License

  1. Overview
  2. License
  3. Getting Start
  4. Documentation
  5. Depend on
  6. Related Project
  7. Todo list
  8. Change log

Overview

Nebula is an event-driven TCP protocol network framework developed in C++ language. It supports multiple application layer communication protocols including proto3, http, https, and websocket. The purpose of developing the Nebula framework is to provide a fast and high-performance distributed service cluster based on C++.

Nebula can be used as a single high-performance TCP server, but building a cluster based on Nebula will be truly reflect its value. In order to build distributed service clusters quickly, Nebula Bootstrap cluster solutions including various types of services have been developed. For details on NebulaBootstrap, please refer to NebulaBootstrap.

License

MIT License

Copyright (c) 2018 Bwar

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Getting Start

Nebula was developed with C++11/C++14 standard, and the compiler must fully support C++11(some C++14 features are replaced by C++11 standard when encountering a lower version of the compiler). Nebula was builded passing with gcc6.4 on centos6.5(upgrade binutils to 2.22 or later) and centos7.4.
We provides NebulaBootstrap, which allows developers to build and deploy Nebula quickly. Nebula will be a framework that be widely used. A distributed solution based on NebulaBootstrap will make it easy to develop micro-service applications in C++. You must ensure that your system is installed with a fully C++11 compiler before you build, and all dependencies will be automatically resolved in the following build steps.

build step:

  1. wget https://github.com/Bwar/NebulaBootstrap/archive/master.zip

  2. unzip master.zip; rm master.zip; mv NebulaBootstrap-master NebulaBootstrap

  3. cd NebulaBootstrap

  4. chmod u+x deploy.sh

  5. ./deploy.sh

    Run deploy.sh, the NebulaBootstrap distributed services were build completed. The reliance of Nebula was also automatically downloaded and compiled by deploy from the Internet before the construction of Nebula. The deploy path as follows:

  • NebulaBootstrap

    • bin         server bin location。
    • build        build path,created by deploy.sh, if you do not need to build again, just delete it.(optional)。
    • conf        configuration path.
    • data        application data path. e.g. Nebio which is a data collect and real-time analysis application, write it's data to this path (optional).
    • lib         library path.
    • log         program logs path.
    • plugins       plugins path.
      • logic       plugins for logic server(optional).
    • script       script path. deploy.sh, startup.sh and shutdown.sh were depend on this path.
    • temp        temp file path(optional).
    • configure.sh     run configure.sh for a simple configuration when deploy for the first time.
    • deploy.sh      auto build and deploy.
    • shutdown.sh      shutdown one or more server.
    • startup.sh      startup one or more server.
    • README_cn.md
    • README.md

    build completed, you can start the server:

./configure.sh
./startup.s

The server should have started successfully now, startup.sh will print the server that had been started, If not, check logs for reason. Notice that the default configuration file of Nebula limits the number of connections per IP in a period. If you have a large amount of testing, you should check the configuration limit. If the server has been successfully started, testing with postman or curl.

curl -H "Content-Type:application/json" -X POST -d '{"name": "Nebula", "address":"https://github.com/Bwar/Nebula"}' http://${your_ip}:16003/hello

A simple testing can be start with a NebulaInterface only, but you need to develop your own plugins. NebulaBootstrap provided the a cluster HelloWorld, the testing will launch NebulaBeacon, NebulaInterface and NebulaLogic. This is a diagram of the cluster architecture:

nebula_cluster

Documentation

The complete documentation for Nebula is available: Nebula documentation and Nebula wiki

Depend on

Related Project

Todo list

  • ipv6 support
  • coroutine support.

Change log

v0.4

  • distributed log service test passing.
  • add https support.
  • add keep alive settings to http channel.
  • replace repeated http headers with proto3 map.
  • provides a symmetric encryption key setup interface for channel.
  • bug fix.

v0.3

  • rewrite with C++14
  • create actors by reflection (using template)
  • add distributed trace log

v0.2

  • the first runable version

About

An event driven asynchronous C++ framework based on a custom Pb protocol supports both HTTP and websocket protocols.

License:MIT License


Languages

Language:C++ 78.2%Language:C 21.5%Language:Makefile 0.3%