Giter Club home page Giter Club logo

maes's Introduction


maes
MAES

Why MicroserviceSystem OverviewHow To UseInstallContact me

MAES = Microservice Architecture on Embedded System.

MAES gives your system the abilities of :

  1. Build your service fast in C/C++;
  2. Multi-service or multi-process communication; (PUB/SUB and REQ/RESP)
  3. Write and save logs;
  4. Load configuration file and use configurations;

Why Microservice

Why use this backend architecture in embedded system?

  1. Breaking your monolithic application into services, which are then loosely connected via APIs. This allows for improved scalability, better fault isolation, and faster time to market;
  2. Easy for two-pizza development teams;
  3. For embedded system or embedded devices, the communication is easily between your services in your device or amoung your devices;
  4. Hope you will love MAES;

System Overview

image

How To Use

Create a Service

#include <iostream>
#include <memory>

// maes include
#include "MaesService.h"

// Create a derived class from maes::ServiceHandler
class MqttService : public maes::ServiceHandler {
public:
    MqttService() {}
    virtual ~MqttService() {}

public:

    // path of storing all the log files
    std::string getLogPath() override {
        return "/tmp";
    }

    // path of configuration file
    std::string getConfigFile() override {
        return "/home/config.json";
    }

    // set your service name
    std::string getServiceName() override {
        return "mqtt-service";
    }

    // set your service version
    std::string getVersion() {
      	return "1.2.3";
    }

    // startup sequence 1 inside maes
    void onInit() override {
      	// logs
        maeslog.debug("%s\n", __FUNCTION__);
    }

    // startup sequence 2 inside maes
    int initHal() override {
	maeslog.debug("%s\n", __FUNCTION__);
      	// init your hardware
      	// beep_init();
        // uart_init();
        // nfc_init();
        return 0;
    }

    // startup sequence 3 inside maes
    int initFml() override {
	maeslog.debug("%s\n", __FUNCTION__);
        // init your functions
      	// db_init();
      	// algorithm_init();
      	// encrypt_init();
        return 0;
    }

    // startup sequence 4 inside maes
    int initAppl() override {
      	// get configurations
        const int val = framework().getConfig()["mqtt-service"]["val"].asInt();

      	// do something
      	// ...

      	// main loop
      	while(1) {
          // ...
        }

        return 0;
    }

    // on maes exit
    void onExit() override {
        maeslog.debug("%s\n", __FUNCTION__);
    }
};

int main(int argc, char const *argv[]) {
    // put your service into the maes
    maes::Framework f(std::make_shared<MqttService>());
    // let's go
    return f.run();
}

Communication Between Microservices

PUB-SUB

// TODO

REQ-RESP

// TODO

Install

# Clone this repository
git clone https://github.com/jtttl/maes

# Go into the repository
cd maes

# Create build directory for cmake
mkdir my_build

# Go into my_build
cd my_build

# Set zmq lib and inc directories
cmake .. -DZMQ_LIB="..." -DZMQ_INC="..."

# Make
make

Contact me

maes's People

Contributors

jtttl 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.