resilient-http / resilient.js Goto Github PK
View Code? Open in Web Editor NEWFault tolerant and reactive HTTP client for node.js and browsers
Fault tolerant and reactive HTTP client for node.js and browsers
resilient().setDiscoveryServers([ ... ])
Configured by weight in percentage
{
latency: 30,
request: 30,
error: 40
}
options.http = {
timeout: 15 * 1000,
cache: false
}
resilient.updateServer(cb)
Support servers discovering and processing jobs in a non-blocking thread
As possible feature a a future 0.2.0
version
{
latency: 30,
success: 30,
error: 40
}
[
{
url: 'http://1.server.com',
timeout: 3000,
priority: 1,
allowMethods: ['GET'],
weight: {
latency: 50,
response: 35,
error: 15
}
}
]
Use cucumber.js browser runner and handle tests status via mocha
Aditional option:
algorithm: 'roundrobin',
size: 3
It could use superagent or request
Just some wishful thinking for future version.
Useful to create coupling between clients as nested nodes which depends of the state of its parent
var client1 = Resilient({
discovery: { servers: ['http://server.me'] }
})
var client2 = Resilient({
parent: client1
})
Client 2 should not perform a request until the client 1 is available, for example, cannot update servers until Client1 has an up-to-date servers list
It could be also useful to dynamically update discovery servers from it's parent
resilient.balancer({
weight: {
request: 30,
error: 50,
latency: 20
}
})
It should support take read it from Server()
Ping
Add options to support parallel requests
parallel: true
301 - Moved permanently
307 - Temporary redirect
Exposed as config options and transported by header to discovery servers
Support a custom XHR client, useful to integrate with Angular and others frameworks
function wrapHttp(options, cb) {
$http(options)
.then(function (res) { cb(null, res) }, function (err) { cb(err) })
}
resilient.setHttpClient(wrapHttp)
Just a reminder!
Like $http
Allow more configurable options for the balancer algorithm
Resilient({
balancer: {
policy: 'latency' // 'errors'
}
})
Use lil-events
Add retry support for fallbacks:
retry: 3, // default to 0
retryDefer: 1000
updateServer(function (err) {
if (err) cb(new ResilientError(err))
})
Required properties:
Inspired in Angular
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.