auto_discovery
v0.0.2
Published
Sample and Lib for service auto discovery
Downloads
6
Readme
autoDiscoverySample
In microservice world, enable new services without changing configs on the existing services. No configuration, and auto discovery new services.
Requirement:
- A Redis Server
- Node.js (express)
How To:
AutoDiscovery_sample.js is a sample
- npm install -save auto_discovery
- In code:
const AutoDiscovery = require('auto_discovery');
- Create an express server:
express = require('express');
app = express();
PORT= 3000;
- Create an object contains the service info:
myConfig = {name: NAME, content: {url: "http://localhost:3000", endpoints: {a: "/endpoint_a", b: "/endpoint_b", ...}}};
- Create redis info:
redisUrl = "localhost";
redisPort = "6379";
- Create autoDiscovery Instance:
AutoConfigs = new AutoDiscovery(myConfig, {url: redisUrl, port: redisPort}, {server: app, port: PORT}, null);
Any services using the same Redis Server will be enable with auto-discovery feature. Save time for configuration management, extra deployments.