Coder Social home page Coder Social logo

dot-microservices / dot-rest Goto Github PK

View Code? Open in Web Editor NEW
45.0 5.0 2.0 1 MB

a minimalist toolkit for building scalable, fault tolerant and eventually-consistent microservices

License: MIT License

JavaScript 100.00%
microservices soa rest clerq fault-tolerance rpc microservice-framework microservice-toolkit

dot-rest's Introduction

dot-rest

a minimalist toolkit for building fast, scalable and fault tolerant microservices

Configuration

  • host : binds server instance to this value. it's 0.0.0.0 by default.
  • pino : options for pino logger. it's { "level": "error" } by default.
  • port : start point for port assignment. it's 8000 by default.

Examples

const Clerq = require('clerq');
const { Client, Server } = require('dot-rest');
const IORedis = require('ioredis');

class Service {
    static _configure() {
        return {
            echo: [ '*', '/:path' ]
        };
    }

    static _name() {
        return 'myService';
    }

    static async echo(req) { // ? , res
        return req.params;
    }
}

const registry = new Clerq(new IORedis(), { expire: 5, pino: { level: 'error' } });
const client = new Client(registry, { expire: 5, pino: { level: 'error' } });
const server = new Server(registry, { expire: 5, pino: { level: 'error' } });
server.start()
    .then(() => server.addService(Service))
    .catch(console.log);

setTimeout(async() => {
    const r = await client.get(Server._unCamelCase(Service._name()), 'test');
    console.log(r.data);
    server.stop();
    client.close();
}, 500);

dot-rest's People

Contributors

dependabot[bot] avatar umuplus 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  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

Forkers

kustomzone vdt

dot-rest's Issues

service registry is unstable

Service registry doesn't know when the service instance goes down.
Stopping clerq isn't enough for a clean shutdown.
We must call "down" method with correct service information.
Also we need to catch exit signal and provide graceful shutdown.

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.