Comments (5)
Discovery process and requests are indepent workflows across requests. This should not be possible. It's true that discovery request can happen multiple times if the first discovery process was not satisfied. This is something that can be changed using a synchronization mechanism.
from resilient.js.
If you provide more details, such as the type of error you're getting, and some code to reproduce it, I might be able to assist you better.
from resilient.js.
This is my example
const resilientMiddlewareEureka = require('./resilient-middleware-eureka');
const Resilient = require('resilient');
let http = require('http');
// Resilient initialisations
const options = {
balancer: {
random: true,
roundRobin: false
},
discovery: {
servers: ['http://localhost:7777/eureka/v1/apps']
},
service: {}
};
let client = new Resilient(options);
client.use(resilientMiddlewareEureka('PROJECTS-API'));
// Run requests
const ITERATIONS_COUNT = 10;
let success = 0;
let promise = Promise.resolve(0);
// send 10 portions of requests
for (let i = 0; i <= ITERATIONS_COUNT; i++) {
promise = promise
.then((successCount) => {
console.log(`success ${i}`);
success += successCount;
// send one portion (100 requests parallel)
return makePackRequests(10);
});
}
promise
.then((successCount) => {
success += successCount;
console.log(`SUCCESS COUNT: ${success}`);
})
.catch((e) => {
console.log(`error:`, e);
});
function makePackRequests(count) {
let promises = [];
let successCount = 0;
for (let i = 0; i < count; i++) {
let promise = client.get('/projects')
.then(() => {
successCount++;
})
.catch((e) => {
console.log(`ERROR`);
console.log(e.message);
});
promises.push(promise);
}
return Promise
.all(promises)
.then(() => {
return successCount;
});
}
This is my result
success 0
OIUT
ERROR
Discovery server response is invalid or empty
ERROR
Discovery server response is invalid or empty
ERROR
Discovery server response is invalid or empty
ERROR
Discovery server response is invalid or empty
ERROR
Discovery server response is invalid or empty
ERROR
Discovery server response is invalid or empty
ERROR
Discovery server response is invalid or empty
ERROR
Discovery server response is invalid or empty
ERROR
Discovery server response is invalid or empty
success 1
success 2
success 3
success 4
success 5
success 6
success 7
success 8
success 9
success 10
SUCCESS COUNT: 101
And, how can I use a synchronization mechanism?
Need I set other http client?
from resilient.js.
You can implement the synchronization inside your Eureka middleware by keeping a global state of the discovery requests. E.g: during the first discovery request call within your middleware logic, you create a promise that would be resolved only when you get the response from Eureka. Subsequent concurrent discovery calls would check if that promise exists and would subscribe to it instead of performing the discovery process again.
That being said, I'm not fully sure where the problem origin actually is, but I suspect it's related to the custom middleware. As far as I know resilient.js
behavior is consistent.
from resilient.js.
I wanted to use your solution but it makes overhead for requests. And I think that several equal requests is bad approach. I made small fix for my team and I hope it will make the lib better.
#144
from resilient.js.
Related Issues (20)
- How to handle rate limiting? HOT 15
- How to integrate resilient module with express framework HOT 2
- Use standard code style
- Support observer hooks
- Allow to override retries option on resilient#send and rest of methods. HOT 3
- Not balancing HOT 2
- Support Promises HOT 1
- Use ES6 syntax
- failed self-refresh call for discovery middleware servers breaks eeverything
- Global binary is throwing error
- Decoding Gzipped Content HOT 4
- How to use querystring with GET?
- Typescript definitions? HOT 2
- Maximum simultaneous connections to a server. HOT 2
- Do you need a registry to use Discovery? HOT 2
- Fix failing build
- How to request binary files? HOT 1
- add the number of retries to the final response in case of custom faileure function
- Abandoned project HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from resilient.js.