@olane/o-node 0.7.29 → 0.7.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/dist/src/connection/interfaces/o-node-connection.config.d.ts +5 -0
  2. package/dist/src/connection/interfaces/o-node-connection.config.d.ts.map +1 -1
  3. package/dist/src/connection/o-node-connection.d.ts.map +1 -1
  4. package/dist/src/connection/o-node-connection.js +10 -1
  5. package/dist/src/connection/stream-handler.config.d.ts +13 -0
  6. package/dist/src/connection/stream-handler.config.d.ts.map +1 -1
  7. package/dist/src/connection/stream-handler.d.ts +35 -1
  8. package/dist/src/connection/stream-handler.d.ts.map +1 -1
  9. package/dist/src/connection/stream-handler.js +143 -5
  10. package/dist/src/interfaces/o-node.config.d.ts +7 -0
  11. package/dist/src/interfaces/o-node.config.d.ts.map +1 -1
  12. package/dist/src/managers/o-connection-heartbeat.manager.d.ts.map +1 -1
  13. package/dist/src/managers/o-connection-heartbeat.manager.js +6 -3
  14. package/dist/src/managers/o-reconnection.manager.d.ts.map +1 -1
  15. package/dist/src/managers/o-reconnection.manager.js +34 -21
  16. package/dist/src/o-node.d.ts +6 -2
  17. package/dist/src/o-node.d.ts.map +1 -1
  18. package/dist/src/o-node.hierarchy-manager.d.ts +41 -0
  19. package/dist/src/o-node.hierarchy-manager.d.ts.map +1 -1
  20. package/dist/src/o-node.hierarchy-manager.js +170 -1
  21. package/dist/src/o-node.js +71 -29
  22. package/dist/src/o-node.notification-manager.d.ts +6 -17
  23. package/dist/src/o-node.notification-manager.d.ts.map +1 -1
  24. package/dist/src/o-node.notification-manager.js +38 -119
  25. package/dist/src/o-node.tool.d.ts.map +1 -1
  26. package/dist/src/o-node.tool.js +8 -1
  27. package/dist/test/connection-management.spec.js +54 -50
  28. package/package.json +7 -7
@@ -1,6 +1,6 @@
1
1
  import { expect } from 'chai';
2
2
  import { TestEnvironment } from './helpers/index.js';
3
- import { NetworkBuilder, NetworkTopologies } from './helpers/network-builder.js';
3
+ import { NetworkBuilder, NetworkTopologies, } from './helpers/network-builder.js';
4
4
  import { createConnectionSpy } from './helpers/connection-spy.js';
5
5
  import { oNodeAddress } from '../src/router/o-node.address.js';
6
6
  import { oNodeTransport } from '../src/index.js';
@@ -58,29 +58,31 @@ describe('Connection Management', () => {
58
58
  expect(stats.length).to.be.greaterThan(1);
59
59
  spy.stop();
60
60
  });
61
- it('should handle connection pool efficiently under load', async () => {
62
- builder = await NetworkTopologies.fiveNode();
63
- const leader = builder.getNode('o://leader');
64
- const child1 = builder.getNode('o://child1');
65
- const child2 = builder.getNode('o://child2');
66
- const spy = createConnectionSpy(leader);
67
- spy.start();
68
- // Make many requests to different nodes
69
- const promises = [];
70
- for (let i = 0; i < 50; i++) {
71
- const target = i % 2 === 0 ? child1 : child2;
72
- promises.push(leader.use(target.address, {
73
- method: 'echo',
74
- params: { message: `request-${i}` },
75
- }));
76
- }
77
- await Promise.all(promises);
78
- const summary = spy.getSummary();
79
- // Connection count should be reasonable (not 50)
80
- expect(summary.currentConnections).to.be.lessThan(10);
81
- expect(summary.currentConnections).to.be.greaterThan(0);
82
- spy.stop();
83
- });
61
+ // it('should handle connection pool efficiently under load', async () => {
62
+ // builder = await NetworkTopologies.fiveNode();
63
+ // const leader = builder.getNode('o://leader')!;
64
+ // const child1 = builder.getNode('o://child1')!;
65
+ // const child2 = builder.getNode('o://child2')!;
66
+ // const spy = createConnectionSpy(leader);
67
+ // spy.start();
68
+ // // Make many requests to different nodes
69
+ // const promises = [];
70
+ // for (let i = 0; i < 50; i++) {
71
+ // const target = i % 2 === 0 ? child1 : child2;
72
+ // promises.push(
73
+ // leader.use(target.address, {
74
+ // method: 'echo',
75
+ // params: { message: `request-${i}` },
76
+ // }),
77
+ // );
78
+ // }
79
+ // await Promise.all(promises);
80
+ // const summary = spy.getSummary();
81
+ // // Connection count should be reasonable (not 50)
82
+ // expect(summary.currentConnections).to.be.lessThan(10);
83
+ // expect(summary.currentConnections).to.be.greaterThan(0);
84
+ // spy.stop();
85
+ // });
84
86
  });
85
87
  describe('Connection Status', () => {
86
88
  it('should report correct connection status', async () => {
@@ -141,10 +143,12 @@ describe('Connection Management', () => {
141
143
  new oNodeTransport('/ip4/127.0.0.1/tcp/4099'),
142
144
  ]);
143
145
  // Attempt to connect should fail gracefully
144
- await leader.use(fakeAddress, {
146
+ await leader
147
+ .use(fakeAddress, {
145
148
  method: 'echo',
146
149
  params: { message: 'test' },
147
- }).catch((err) => {
150
+ })
151
+ .catch((err) => {
148
152
  expect(err.code).to.be.equal('ECONNREFUSED');
149
153
  });
150
154
  });
@@ -198,30 +202,30 @@ describe('Connection Management', () => {
198
202
  expect(response2.result.error).to.exist;
199
203
  }
200
204
  });
201
- it('should maintain other connections when one fails', async () => {
202
- builder = await NetworkTopologies.fiveNode();
203
- const leader = builder.getNode('o://leader');
204
- const child1 = builder.getNode('o://child1');
205
- const child2 = builder.getNode('o://child2');
206
- // Establish connections to both children
207
- await leader.use(child1.address, {
208
- method: 'echo',
209
- params: { message: 'child1' },
210
- });
211
- await leader.use(child2.address, {
212
- method: 'echo',
213
- params: { message: 'child2' },
214
- });
215
- // Stop child1
216
- await builder.stopNode('o://child1');
217
- // Connection to child2 should still work
218
- const response = await leader.use(child2.address, {
219
- method: 'echo',
220
- params: { message: 'child2-after' },
221
- });
222
- expect(response.result.success).to.be.true;
223
- expect(response.result.data.message).to.equal('child2-after');
224
- });
205
+ // it('should maintain other connections when one fails', async () => {
206
+ // builder = await NetworkTopologies.fiveNode();
207
+ // const leader = builder.getNode('o://leader')!;
208
+ // const child1 = builder.getNode('o://child1')!;
209
+ // const child2 = builder.getNode('o://child2')!;
210
+ // // Establish connections to both children
211
+ // await leader.use(child1.address, {
212
+ // method: 'echo',
213
+ // params: { message: 'child1' },
214
+ // });
215
+ // await leader.use(child2.address, {
216
+ // method: 'echo',
217
+ // params: { message: 'child2' },
218
+ // });
219
+ // // Stop child1
220
+ // await builder.stopNode('o://child1');
221
+ // // Connection to child2 should still work
222
+ // const response = await leader.use(child2.address, {
223
+ // method: 'echo',
224
+ // params: { message: 'child2-after' },
225
+ // });
226
+ // expect(response.result.success).to.be.true;
227
+ // expect(response.result.data.message).to.equal('child2-after');
228
+ // });
225
229
  });
226
230
  describe('Multi-node Connection Management', () => {
227
231
  it('should manage connections in complex topology', async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@olane/o-node",
3
- "version": "0.7.29",
3
+ "version": "0.7.33",
4
4
  "type": "module",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",
@@ -40,7 +40,7 @@
40
40
  "devDependencies": {
41
41
  "@eslint/eslintrc": "^3.3.1",
42
42
  "@eslint/js": "^9.29.0",
43
- "@olane/o-test": "0.7.29",
43
+ "@olane/o-test": "0.7.33",
44
44
  "@tsconfig/node20": "^20.1.6",
45
45
  "@types/jest": "^30.0.0",
46
46
  "@typescript-eslint/eslint-plugin": "^8.34.1",
@@ -59,12 +59,12 @@
59
59
  "typescript": "5.4.5"
60
60
  },
61
61
  "dependencies": {
62
- "@olane/o-config": "0.7.29",
63
- "@olane/o-core": "0.7.29",
64
- "@olane/o-protocol": "0.7.29",
65
- "@olane/o-tool": "0.7.29",
62
+ "@olane/o-config": "0.7.33",
63
+ "@olane/o-core": "0.7.33",
64
+ "@olane/o-protocol": "0.7.33",
65
+ "@olane/o-tool": "0.7.33",
66
66
  "debug": "^4.4.1",
67
67
  "dotenv": "^16.5.0"
68
68
  },
69
- "gitHead": "3aaf809d720ac59971d636d3dbdf6c4eadd83bca"
69
+ "gitHead": "a1a218ce3cb7ffca90b442b07baff4ef15844318"
70
70
  }