Skip to content

Commit 230973f

Browse files
kiranmandaawolden
authored andcommitted
The modifyInstance() function is returning back to the caller when the the instance is not in UP status. So the cache is never updated to the OUT_OF_SERVICE status. This should fix that problem. (#148)
1 parent 0d4c142 commit 230973f

File tree

4 files changed

+25
-2
lines changed

4 files changed

+25
-2
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,6 @@ node_modules
2929
lib/
3030

3131
.DS_Store
32+
33+
#IDE
34+
.idea

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "eureka-js-client",
3-
"version": "4.4.1",
3+
"version": "4.4.2",
44
"description": "A JavaScript implementation the Netflix OSS service registry, Eureka.",
55
"main": "lib/index.js",
66
"scripts": {

src/EurekaClient.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,6 @@ export default class Eureka extends EventEmitter {
484484
}
485485

486486
modifyInstance(cache, instance) {
487-
if (!this.validateInstance(instance)) return;
488487
const vipAddresses = this.splitVipAddress(instance.vipAddress);
489488
const appName = instance.app.toUpperCase();
490489
vipAddresses.forEach((vipAddress) => {

test/EurekaClient.test.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1178,6 +1178,27 @@ describe('Eureka client', () => {
11781178
expect(client.cache.app.THEAPP[0]).to.have.property('newProp');
11791179
});
11801180

1181+
it('should modify instances even when status is not UP', () => {
1182+
const appDelta = [
1183+
{
1184+
instance: [
1185+
{ hostName: '127.0.0.1', port: { $: 1000 }, app: 'THEAPP', vipAddress: 'thevip', status: 'DOWN', actionType: 'MODIFIED', newProp: 'foo' },
1186+
],
1187+
},
1188+
];
1189+
const original = { hostName: '127.0.0.1', port: { $: 1000 }, app: 'THEAPP', vipAddress: 'thevip', status: 'UP', actionType: 'MODIFIED' };
1190+
client.cache = {
1191+
app: { THEAPP: [original] },
1192+
vip: { thevip: [original] },
1193+
};
1194+
1195+
client.handleDelta(client.cache, appDelta);
1196+
expect(client.cache.vip.thevip).to.have.length(1);
1197+
expect(client.cache.app.THEAPP).to.have.length(1);
1198+
expect(client.cache.vip.thevip[0]).to.have.property('newProp');
1199+
expect(client.cache.app.THEAPP[0]).to.have.property('newProp');
1200+
});
1201+
11811202
it('should add if instance doesnt exist when modifying', () => {
11821203
const appDelta = [
11831204
{

0 commit comments

Comments
 (0)