31

A draft for a simple micro-service framework

 6 years ago
source link: https://www.tuicool.com/articles/hit/URZ7RrA
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

my-middleware

my-middleware offers an abstraction for distributed systems.

You can use my-middleware to:

  • easily setup a distributed and scalable system based on queues (e.g. bull, AMPQ, ZeroMQ, etc.)
  • easily switch from a queue system to another one - e.g. switch from ZeroMQ to bull etc.

Usage

Example of a job server

// server.js
//
//
const MyMiddleware = require('my-middleware')
const MyMiddlewareAmpq = require('my-middleware-ampq')

const onMessage = (job, done) => { console.log(job) }
const myMiddlewareAmpq = new MyMiddlewareAmq({ onMessage })

const distributedSystem = new MyMiddleware(myMiddlewareAmpq)

distributedSystem.startServer()

// client.js
//
//
const MyMiddleware = require('my-middleware')
const MyMiddlewareAmpq = require('my-middleware-ampq')

const myMiddlewareAmpqClient = new MyMiddlewareAmq({ /* options */})
const distributedSystem = new MyMiddleware(myMiddlewareAmpqClient)

distributedSystem.startClient()

const msg = { body:'a message...' }

distributedSystem.send(msg)

Supported middleware

TODO

How to add a middleware

TBD


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK