New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

serviced

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

serviced - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

2

package.json
{
"name": "serviced",
"version": "2.0.0",
"version": "2.0.1",
"description": "Microservice dependency readiness probe",

@@ -5,0 +5,0 @@ "main": "serviced.js",

@@ -12,3 +12,2 @@ # Serviced

I use this to ensure I don't start certain processes (for example, our API server) before the backing services (db, message broker and kubernetes api) are up, running and reachable. Internally `serviced` uses `backoff` and `request` for http calls and retries.

@@ -24,25 +23,60 @@ ## Usage

const service1 = {
name: 'db',
url: 'http://db',
json: true,
maxDelay: 1000,
numberOfBackoffs: 10,
// Test that a single service returns status code 200.
new Serviced('http://exmample.com').then(() => {
// Your service is online and returns status code 200.
});
// Test that multiple services returns status code 200.
new Serviced('http://svc-a.com', 'http://svc-b.com').then(() => {
// Both services are online and return status codes 200.
});
// Test the response body from a service request with a test function.
new Serviced({
url: 'http://svc-a.com',
test(body) {
return body.foo === true;
},
};
}).then(() => {
// Service is online and response passes supplied test.
});
const service2 = {
name: 'kubernetes',
url: 'http://localhost:8080',
// Test the response body from multiple service requests with test functions.
new Serviced({
url: 'http://svc-a.com',
test(body) {
return body.foo === true;
},
}, {
url: 'http://svc-b.com',
test(body) {
return body.bar === true;
},
};
}).then(() => {
// Services are online and responses pass supplied tests.
});
const services = new Serviced(service1, service2);
// Pass additional options to underlying request and retry modules.
new Serviced({
url: 'http://svc-a.com',
request: { // pass options to request
auth: {
user: 'username',
pass: 'password',
}
},
retry: { // pass options to retry
retries: 2,
maxTimeout: 2000,
},
test(body) {
return body.foo === true;
},
}).then(() => {
// Service is online and response passes supplied test.
});
```
services.then(() => {
// Your services have responded and are ready.
});
## Change log
* 2.0.0 Breaking changes from 1.x. I switched to `retry` over `backoff` primarily because of how it handles errors but also for simplicity.

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc