@olane/o-node 0.7.51 → 0.7.53

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 (48) hide show
  1. package/dist/src/connection/index.d.ts +6 -5
  2. package/dist/src/connection/index.d.ts.map +1 -1
  3. package/dist/src/connection/index.js +6 -5
  4. package/dist/src/connection/interfaces/{o-node-connection-stream.config.d.ts → o-node-stream.config.d.ts} +2 -2
  5. package/dist/src/connection/interfaces/o-node-stream.config.d.ts.map +1 -0
  6. package/dist/src/connection/interfaces/stream-init-message.d.ts +29 -0
  7. package/dist/src/connection/interfaces/stream-init-message.d.ts.map +1 -0
  8. package/dist/src/connection/interfaces/stream-init-message.js +8 -0
  9. package/dist/src/connection/interfaces/stream-manager.config.d.ts +8 -0
  10. package/dist/src/connection/interfaces/stream-manager.config.d.ts.map +1 -0
  11. package/dist/src/connection/o-node-connection.d.ts +5 -7
  12. package/dist/src/connection/o-node-connection.d.ts.map +1 -1
  13. package/dist/src/connection/o-node-connection.js +26 -56
  14. package/dist/src/connection/o-node-connection.manager.d.ts +7 -0
  15. package/dist/src/connection/o-node-connection.manager.d.ts.map +1 -1
  16. package/dist/src/connection/o-node-connection.manager.js +23 -5
  17. package/dist/src/connection/{o-node-connection-stream.d.ts → o-node-stream.d.ts} +6 -6
  18. package/dist/src/connection/o-node-stream.d.ts.map +1 -0
  19. package/dist/src/connection/{o-node-connection-stream.js → o-node-stream.js} +2 -2
  20. package/dist/src/connection/o-node-stream.manager.d.ts +181 -0
  21. package/dist/src/connection/o-node-stream.manager.d.ts.map +1 -0
  22. package/dist/src/connection/o-node-stream.manager.js +526 -0
  23. package/dist/src/connection/stream-manager.events.d.ts +83 -0
  24. package/dist/src/connection/stream-manager.events.d.ts.map +1 -0
  25. package/dist/src/connection/stream-manager.events.js +18 -0
  26. package/dist/src/o-node.tool.d.ts +0 -1
  27. package/dist/src/o-node.tool.d.ts.map +1 -1
  28. package/dist/src/o-node.tool.js +30 -20
  29. package/dist/test/helpers/stream-pool-test-helpers.d.ts +0 -75
  30. package/dist/test/helpers/stream-pool-test-helpers.d.ts.map +1 -1
  31. package/dist/test/helpers/stream-pool-test-helpers.js +262 -229
  32. package/dist/test/parent-child-registration.spec.js +2 -1
  33. package/package.json +7 -7
  34. package/dist/src/connection/interfaces/o-node-connection-stream.config.d.ts.map +0 -1
  35. package/dist/src/connection/interfaces/stream-pool-manager.config.d.ts +0 -41
  36. package/dist/src/connection/interfaces/stream-pool-manager.config.d.ts.map +0 -1
  37. package/dist/src/connection/o-node-connection-stream.d.ts.map +0 -1
  38. package/dist/src/connection/stream-handler.d.ts +0 -102
  39. package/dist/src/connection/stream-handler.d.ts.map +0 -1
  40. package/dist/src/connection/stream-handler.js +0 -357
  41. package/dist/src/connection/stream-pool-manager.d.ts +0 -86
  42. package/dist/src/connection/stream-pool-manager.d.ts.map +0 -1
  43. package/dist/src/connection/stream-pool-manager.events.d.ts +0 -57
  44. package/dist/src/connection/stream-pool-manager.events.d.ts.map +0 -1
  45. package/dist/src/connection/stream-pool-manager.events.js +0 -14
  46. package/dist/src/connection/stream-pool-manager.js +0 -356
  47. /package/dist/src/connection/interfaces/{o-node-connection-stream.config.js → o-node-stream.config.js} +0 -0
  48. /package/dist/src/connection/interfaces/{stream-pool-manager.config.js → stream-manager.config.js} +0 -0
@@ -1,229 +1,262 @@
1
- import { oNodeConnectionStream } from '../../src/connection/o-node-connection-stream.js';
2
- /**
3
- * Create a mock stream for testing
4
- */
5
- export function createMockStream(id = 'test-stream', options = {}) {
6
- const stream = {
7
- id,
8
- status: options.status || 'open',
9
- writeStatus: options.writeStatus || 'writable',
10
- readStatus: options.readStatus || 'readable',
11
- remoteReadStatus: options.remoteReadStatus || 'readable',
12
- protocol: '/test/1.0.0',
13
- direction: 'outbound',
14
- timeline: { open: Date.now() },
15
- source: [],
16
- sink: async () => { },
17
- close: async () => { },
18
- closeRead: async () => { },
19
- closeWrite: async () => { },
20
- abort: async () => { },
21
- reset: () => {
22
- stream.status = 'reset';
23
- },
24
- };
25
- return stream;
26
- }
27
- /**
28
- * Create a mock P2P connection for testing
29
- */
30
- export function createMockP2PConnection(id = 'test-connection', status = 'open') {
31
- const streams = [];
32
- return {
33
- id,
34
- status,
35
- remotePeer: { toString: () => 'test-peer' },
36
- streams: () => streams,
37
- newStream: async (protocols) => {
38
- const stream = createMockStream(`stream-${streams.length}`, {
39
- status: 'open',
40
- });
41
- stream.protocol = protocols[0];
42
- streams.push(stream);
43
- return stream;
44
- },
45
- close: async () => {
46
- status = 'closed';
47
- },
48
- };
49
- }
50
- /**
51
- * Create a mock StreamHandler for testing
52
- */
53
- export function createMockStreamHandler() {
54
- const handler = {
55
- handleIncomingStreamCalls: [],
56
- handleOutgoingStreamCalls: [],
57
- shouldFailIncoming: false,
58
- shouldFailOutgoing: false,
59
- incomingStreamPromise: null,
60
- incomingStreamResolve: null,
61
- handleIncomingStream: async (stream, connection, requestHandler) => {
62
- handler.handleIncomingStreamCalls.push({
63
- stream,
64
- connection,
65
- requestHandler,
66
- });
67
- if (handler.shouldFailIncoming) {
68
- throw new Error('Mock incoming stream handler failure');
69
- }
70
- // Create a promise that can be externally resolved to simulate stream closure
71
- return new Promise((resolve) => {
72
- handler.incomingStreamResolve = resolve;
73
- });
74
- },
75
- handleOutgoingStream: async (stream, emitter, config, requestHandler, requestId) => {
76
- handler.handleOutgoingStreamCalls.push({
77
- stream,
78
- emitter,
79
- config,
80
- requestHandler,
81
- requestId,
82
- });
83
- if (handler.shouldFailOutgoing) {
84
- throw new Error('Mock outgoing stream handler failure');
85
- }
86
- return { result: { success: true, data: {} } };
87
- },
88
- // Helper to simulate stream closure/failure
89
- simulateStreamClosure: () => {
90
- if (handler.incomingStreamResolve) {
91
- handler.incomingStreamResolve();
92
- handler.incomingStreamResolve = null;
93
- }
94
- },
95
- // Helper to simulate stream error
96
- simulateStreamError: () => {
97
- if (handler.incomingStreamResolve) {
98
- // Reject the promise by throwing after a small delay
99
- setTimeout(() => {
100
- throw new Error('Stream closed');
101
- }, 10);
102
- }
103
- },
104
- };
105
- return handler;
106
- }
107
- /**
108
- * Create a mock oNodeConnectionStream
109
- */
110
- export function createMockConnectionStream(p2pStream, streamType = 'general') {
111
- const mockP2PStream = p2pStream || createMockStream();
112
- return new oNodeConnectionStream(mockP2PStream, {
113
- direction: 'outbound',
114
- reusePolicy: 'reuse',
115
- remoteAddress: { toString: () => 'o://test' },
116
- streamType,
117
- });
118
- }
119
- /**
120
- * Factory for creating StreamPoolManager test config
121
- */
122
- export function createStreamPoolManagerConfig(overrides = {}) {
123
- const mockP2PConnection = createMockP2PConnection();
124
- const mockStreamHandler = createMockStreamHandler();
125
- let streamCounter = 0;
126
- const defaultConfig = {
127
- poolSize: 10,
128
- readerStreamIndex: 0,
129
- streamHandler: mockStreamHandler,
130
- p2pConnection: mockP2PConnection,
131
- requestHandler: async (request, stream) => {
132
- return { success: true, data: {} };
133
- },
134
- createStream: async () => {
135
- const p2pStream = createMockStream(`stream-${streamCounter++}`);
136
- return createMockConnectionStream(p2pStream, 'general');
137
- },
138
- };
139
- return {
140
- ...defaultConfig,
141
- ...overrides,
142
- };
143
- }
144
- /**
145
- * Event capture helper for testing event emissions
146
- */
147
- export class EventCapture {
148
- constructor(emitter) {
149
- this.emitter = emitter;
150
- this.events = [];
151
- }
152
- /**
153
- * Start capturing events
154
- */
155
- start(eventNames) {
156
- for (const eventName of eventNames) {
157
- this.emitter.on(eventName, (data) => {
158
- this.events.push({
159
- type: eventName,
160
- data,
161
- timestamp: Date.now(),
162
- });
163
- });
164
- }
165
- }
166
- /**
167
- * Get all captured events
168
- */
169
- getEvents() {
170
- return this.events;
171
- }
172
- /**
173
- * Get events of specific type
174
- */
175
- getEventsByType(type) {
176
- return this.events.filter((e) => e.type === type).map((e) => e.data);
177
- }
178
- /**
179
- * Check if event was emitted
180
- */
181
- hasEvent(type) {
182
- return this.events.some((e) => e.type === type);
183
- }
184
- /**
185
- * Get count of specific event type
186
- */
187
- getEventCount(type) {
188
- return this.events.filter((e) => e.type === type).length;
189
- }
190
- /**
191
- * Wait for specific event
192
- */
193
- async waitForEvent(type, timeoutMs = 5000) {
194
- const startTime = Date.now();
195
- while (Date.now() - startTime < timeoutMs) {
196
- const event = this.events.find((e) => e.type === type);
197
- if (event) {
198
- return event.data;
199
- }
200
- await new Promise((resolve) => setTimeout(resolve, 10));
201
- }
202
- throw new Error(`Timeout waiting for event: ${type}`);
203
- }
204
- /**
205
- * Clear captured events
206
- */
207
- clear() {
208
- this.events = [];
209
- }
210
- }
211
- /**
212
- * Helper to make a stream invalid
213
- */
214
- export function makeStreamInvalid(stream) {
215
- stream.p2pStream.status = 'closed';
216
- stream.p2pStream.writeStatus = 'closed';
217
- }
218
- /**
219
- * Helper to wait for condition with timeout
220
- */
221
- export async function waitFor(condition, timeoutMs = 5000, intervalMs = 10) {
222
- const startTime = Date.now();
223
- while (!condition()) {
224
- if (Date.now() - startTime > timeoutMs) {
225
- throw new Error('Timeout waiting for condition');
226
- }
227
- await new Promise((resolve) => setTimeout(resolve, intervalMs));
228
- }
229
- }
1
+ "use strict";
2
+ // import type { Connection } from '@libp2p/interface';
3
+ // import type { Stream } from '@olane/o-config';
4
+ // import { oRequest } from '@olane/o-core';
5
+ // import { StreamHandler } from '../../src/connection/stream-handler.js';
6
+ // import { oNodeConnectionStream } from '../../src/connection/o-node-connection-stream.js';
7
+ // import { StreamPoolManagerConfig } from '../../src/index.js';
8
+ // /**
9
+ // * Create a mock stream for testing
10
+ // */
11
+ // export function createMockStream(
12
+ // id: string = 'test-stream',
13
+ // options: {
14
+ // status?: 'open' | 'closed' | 'reset';
15
+ // writeStatus?: 'writable' | 'writing' | 'closed';
16
+ // readStatus?: 'readable' | 'reading' | 'closed';
17
+ // remoteReadStatus?: 'readable' | 'reading' | 'closed';
18
+ // } = {},
19
+ // ): any {
20
+ // const stream = {
21
+ // id,
22
+ // status: options.status || 'open',
23
+ // writeStatus: options.writeStatus || 'writable',
24
+ // readStatus: options.readStatus || 'readable',
25
+ // remoteReadStatus: options.remoteReadStatus || 'readable',
26
+ // protocol: '/test/1.0.0',
27
+ // direction: 'outbound',
28
+ // timeline: { open: Date.now() },
29
+ // source: [],
30
+ // sink: async () => {},
31
+ // close: async () => {},
32
+ // closeRead: async () => {},
33
+ // closeWrite: async () => {},
34
+ // abort: async () => {},
35
+ // reset: () => {
36
+ // stream.status = 'reset';
37
+ // },
38
+ // };
39
+ // return stream;
40
+ // }
41
+ // /**
42
+ // * Create a mock P2P connection for testing
43
+ // */
44
+ // export function createMockP2PConnection(
45
+ // id: string = 'test-connection',
46
+ // status: 'open' | 'closed' = 'open',
47
+ // ): any {
48
+ // const streams: any[] = [];
49
+ // return {
50
+ // id,
51
+ // status,
52
+ // remotePeer: { toString: () => 'test-peer' },
53
+ // streams: () => streams,
54
+ // newStream: async (protocols: string[]) => {
55
+ // const stream = createMockStream(`stream-${streams.length}`, {
56
+ // status: 'open',
57
+ // });
58
+ // stream.protocol = protocols[0];
59
+ // streams.push(stream);
60
+ // return stream;
61
+ // },
62
+ // close: async () => {
63
+ // status = 'closed';
64
+ // },
65
+ // };
66
+ // }
67
+ // /**
68
+ // * Create a mock StreamHandler for testing
69
+ // */
70
+ // export function createMockStreamHandler(): any {
71
+ // const handler = {
72
+ // handleIncomingStreamCalls: [] as any[],
73
+ // handleOutgoingStreamCalls: [] as any[],
74
+ // shouldFailIncoming: false,
75
+ // shouldFailOutgoing: false,
76
+ // incomingStreamPromise: null as Promise<void> | null,
77
+ // incomingStreamResolve: null as (() => void) | null,
78
+ // handleIncomingStream: async (
79
+ // stream: Stream,
80
+ // connection: Connection,
81
+ // requestHandler: (request: oRequest, stream: Stream) => Promise<any>,
82
+ // ): Promise<void> => {
83
+ // handler.handleIncomingStreamCalls.push({
84
+ // stream,
85
+ // connection,
86
+ // requestHandler,
87
+ // });
88
+ // if (handler.shouldFailIncoming) {
89
+ // throw new Error('Mock incoming stream handler failure');
90
+ // }
91
+ // // Create a promise that can be externally resolved to simulate stream closure
92
+ // return new Promise((resolve) => {
93
+ // handler.incomingStreamResolve = resolve;
94
+ // });
95
+ // },
96
+ // handleOutgoingStream: async (
97
+ // stream: Stream,
98
+ // emitter: any,
99
+ // config: any,
100
+ // requestHandler?: any,
101
+ // requestId?: string | number,
102
+ // ): Promise<any> => {
103
+ // handler.handleOutgoingStreamCalls.push({
104
+ // stream,
105
+ // emitter,
106
+ // config,
107
+ // requestHandler,
108
+ // requestId,
109
+ // });
110
+ // if (handler.shouldFailOutgoing) {
111
+ // throw new Error('Mock outgoing stream handler failure');
112
+ // }
113
+ // return { result: { success: true, data: {} } };
114
+ // },
115
+ // // Helper to simulate stream closure/failure
116
+ // simulateStreamClosure: () => {
117
+ // if (handler.incomingStreamResolve) {
118
+ // handler.incomingStreamResolve();
119
+ // handler.incomingStreamResolve = null;
120
+ // }
121
+ // },
122
+ // // Helper to simulate stream error
123
+ // simulateStreamError: () => {
124
+ // if (handler.incomingStreamResolve) {
125
+ // // Reject the promise by throwing after a small delay
126
+ // setTimeout(() => {
127
+ // throw new Error('Stream closed');
128
+ // }, 10);
129
+ // }
130
+ // },
131
+ // };
132
+ // return handler;
133
+ // }
134
+ // /**
135
+ // * Create a mock oNodeConnectionStream
136
+ // */
137
+ // export function createMockConnectionStream(
138
+ // p2pStream?: any,
139
+ // streamType: 'dedicated-reader' | 'request-response' | 'general' = 'general',
140
+ // ): oNodeConnectionStream {
141
+ // const mockP2PStream = p2pStream || createMockStream();
142
+ // return new oNodeConnectionStream(mockP2PStream, {
143
+ // direction: 'outbound',
144
+ // reusePolicy: 'reuse',
145
+ // remoteAddress: { toString: () => 'o://test' } as any,
146
+ // streamType,
147
+ // });
148
+ // }
149
+ // /**
150
+ // * Factory for creating StreamPoolManager test config
151
+ // */
152
+ // export function createStreamPoolManagerConfig(
153
+ // overrides: Partial<StreamPoolManagerConfig> = {},
154
+ // ): StreamPoolManagerConfig {
155
+ // const mockP2PConnection = createMockP2PConnection();
156
+ // const mockStreamHandler = createMockStreamHandler();
157
+ // let streamCounter = 0;
158
+ // const defaultConfig: StreamPoolManagerConfig = {
159
+ // readerStreamIndex: 0,
160
+ // streamHandler: mockStreamHandler,
161
+ // p2pConnection: mockP2PConnection,
162
+ // requestHandler: async (request: oRequest, stream: Stream) => {
163
+ // return { success: true, data: {} };
164
+ // },
165
+ // createStream: async () => {
166
+ // const p2pStream = createMockStream(`stream-${streamCounter++}`);
167
+ // return createMockConnectionStream(p2pStream, 'general');
168
+ // },
169
+ // };
170
+ // return {
171
+ // ...defaultConfig,
172
+ // ...overrides,
173
+ // };
174
+ // }
175
+ // /**
176
+ // * Event capture helper for testing event emissions
177
+ // */
178
+ // export class EventCapture {
179
+ // private events: Array<{ type: string; data: any; timestamp: number }> = [];
180
+ // constructor(private emitter: any) {}
181
+ // /**
182
+ // * Start capturing events
183
+ // */
184
+ // start(eventNames: string[]): void {
185
+ // for (const eventName of eventNames) {
186
+ // this.emitter.on(eventName, (data: any) => {
187
+ // this.events.push({
188
+ // type: eventName,
189
+ // data,
190
+ // timestamp: Date.now(),
191
+ // });
192
+ // });
193
+ // }
194
+ // }
195
+ // /**
196
+ // * Get all captured events
197
+ // */
198
+ // getEvents(): Array<{ type: string; data: any; timestamp: number }> {
199
+ // return this.events;
200
+ // }
201
+ // /**
202
+ // * Get events of specific type
203
+ // */
204
+ // getEventsByType(type: string): any[] {
205
+ // return this.events.filter((e) => e.type === type).map((e) => e.data);
206
+ // }
207
+ // /**
208
+ // * Check if event was emitted
209
+ // */
210
+ // hasEvent(type: string): boolean {
211
+ // return this.events.some((e) => e.type === type);
212
+ // }
213
+ // /**
214
+ // * Get count of specific event type
215
+ // */
216
+ // getEventCount(type: string): number {
217
+ // return this.events.filter((e) => e.type === type).length;
218
+ // }
219
+ // /**
220
+ // * Wait for specific event
221
+ // */
222
+ // async waitForEvent(type: string, timeoutMs: number = 5000): Promise<any> {
223
+ // const startTime = Date.now();
224
+ // while (Date.now() - startTime < timeoutMs) {
225
+ // const event = this.events.find((e) => e.type === type);
226
+ // if (event) {
227
+ // return event.data;
228
+ // }
229
+ // await new Promise((resolve) => setTimeout(resolve, 10));
230
+ // }
231
+ // throw new Error(`Timeout waiting for event: ${type}`);
232
+ // }
233
+ // /**
234
+ // * Clear captured events
235
+ // */
236
+ // clear(): void {
237
+ // this.events = [];
238
+ // }
239
+ // }
240
+ // /**
241
+ // * Helper to make a stream invalid
242
+ // */
243
+ // export function makeStreamInvalid(stream: any): void {
244
+ // stream.p2pStream.status = 'closed';
245
+ // stream.p2pStream.writeStatus = 'closed';
246
+ // }
247
+ // /**
248
+ // * Helper to wait for condition with timeout
249
+ // */
250
+ // export async function waitFor(
251
+ // condition: () => boolean,
252
+ // timeoutMs: number = 5000,
253
+ // intervalMs: number = 10,
254
+ // ): Promise<void> {
255
+ // const startTime = Date.now();
256
+ // while (!condition()) {
257
+ // if (Date.now() - startTime > timeoutMs) {
258
+ // throw new Error('Timeout waiting for condition');
259
+ // }
260
+ // await new Promise((resolve) => setTimeout(resolve, intervalMs));
261
+ // }
262
+ // }
@@ -13,6 +13,7 @@ describe('Parent-Child Registration', () => {
13
13
  });
14
14
  describe('Basic Registration', () => {
15
15
  it('should register child with parent during startup', async () => {
16
+ console.log('Starting Basic Registration Test');
16
17
  builder = new NetworkBuilder();
17
18
  const leader = await builder.addNode('o://leader');
18
19
  await builder.startNode('o://leader');
@@ -20,7 +21,7 @@ describe('Parent-Child Registration', () => {
20
21
  await builder.startNode('o://child');
21
22
  // Verify child is in parent's hierarchy manager
22
23
  const children = leader.getChildren();
23
- console.log('Leader status:', leader.state);
24
+ console.log('Children', children);
24
25
  expect(children).to.have.lengthOf(1);
25
26
  expect(children[0].toString()).to.include('child');
26
27
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@olane/o-node",
3
- "version": "0.7.51",
3
+ "version": "0.7.53",
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.51",
43
+ "@olane/o-test": "0.7.53",
44
44
  "@tsconfig/node20": "^20.1.6",
45
45
  "@types/jest": "^30.0.0",
46
46
  "@types/json5": "^2.2.0",
@@ -60,13 +60,13 @@
60
60
  "typescript": "5.4.5"
61
61
  },
62
62
  "dependencies": {
63
- "@olane/o-config": "0.7.51",
64
- "@olane/o-core": "0.7.51",
65
- "@olane/o-protocol": "0.7.51",
66
- "@olane/o-tool": "0.7.51",
63
+ "@olane/o-config": "0.7.53",
64
+ "@olane/o-core": "0.7.53",
65
+ "@olane/o-protocol": "0.7.53",
66
+ "@olane/o-tool": "0.7.53",
67
67
  "debug": "^4.4.1",
68
68
  "dotenv": "^16.5.0",
69
69
  "json5": "^2.2.3"
70
70
  },
71
- "gitHead": "f770a110369cb9791d9e9208c7a084feecbb9b2c"
71
+ "gitHead": "cc41cbe72abffd5f2720aec92516aafea50ee9c3"
72
72
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"o-node-connection-stream.config.d.ts","sourceRoot":"","sources":["../../../../src/connection/interfaces/o-node-connection-stream.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAAG,kBAAkB,GAAG,kBAAkB,GAAG,SAAS,CAAC;AAE7E,MAAM,WAAW,2BAA2B;IAC1C,SAAS,EAAE,SAAS,GAAG,UAAU,CAAC;IAClC,WAAW,EAAE,iBAAiB,CAAC;IAC/B,aAAa,EAAE,QAAQ,CAAC;IACxB,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB"}
@@ -1,41 +0,0 @@
1
- import type { Connection } from '@libp2p/interface';
2
- import { oRequest } from '@olane/o-core';
3
- import type { Stream } from '@olane/o-config';
4
- import type { oNodeConnectionStream } from '../o-node-connection-stream.js';
5
- import type { StreamHandler } from '../stream-handler.js';
6
- export interface StreamPoolManagerConfig {
7
- /**
8
- * Pool size (total number of streams to maintain)
9
- * Default: 10 (1 dedicated reader + 9 request-response)
10
- */
11
- poolSize?: number;
12
- /**
13
- * Index of the dedicated reader stream in the pool
14
- * Default: 0
15
- */
16
- readerStreamIndex?: number;
17
- /**
18
- * Stream handler for managing stream communication
19
- */
20
- streamHandler: StreamHandler;
21
- /**
22
- * P2P connection for creating streams
23
- */
24
- p2pConnection: Connection;
25
- /**
26
- * Request handler for incoming requests on the dedicated reader
27
- */
28
- requestHandler?: (request: oRequest, stream: Stream) => Promise<any>;
29
- /**
30
- * Function to create a new stream
31
- */
32
- createStream: () => Promise<oNodeConnectionStream>;
33
- }
34
- export interface StreamPoolStats {
35
- totalStreams: number;
36
- healthyStreams: number;
37
- readerStreamHealth: 'healthy' | 'unhealthy' | 'not-initialized';
38
- requestResponseStreams: number;
39
- failureCount: number;
40
- }
41
- //# sourceMappingURL=stream-pool-manager.config.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stream-pool-manager.config.d.ts","sourceRoot":"","sources":["../../../../src/connection/interfaces/stream-pool-manager.config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAC5E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,MAAM,WAAW,uBAAuB;IACtC;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B;;OAEG;IACH,aAAa,EAAE,aAAa,CAAC;IAE7B;;OAEG;IACH,aAAa,EAAE,UAAU,CAAC;IAE1B;;OAEG;IACH,cAAc,CAAC,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;IAErE;;OAEG;IACH,YAAY,EAAE,MAAM,OAAO,CAAC,qBAAqB,CAAC,CAAC;CACpD;AAED,MAAM,WAAW,eAAe;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,kBAAkB,EAAE,SAAS,GAAG,WAAW,GAAG,iBAAiB,CAAC;IAChE,sBAAsB,EAAE,MAAM,CAAC;IAC/B,YAAY,EAAE,MAAM,CAAC;CACtB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"o-node-connection-stream.d.ts","sourceRoot":"","sources":["../../../src/connection/o-node-connection-stream.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAuB,OAAO,EAAiB,MAAM,eAAe,CAAC;AAC5E,OAAO,EAAE,2BAA2B,EAAE,MAAM,iDAAiD,CAAC;AAE9F;;;;;;;;GAQG;AACH,qBAAa,qBAAsB,SAAQ,OAAO;aAI9B,SAAS,EAAE,MAAM;aACjB,MAAM,EAAE,2BAA2B;IAJrD,SAAgB,SAAS,EAAE,MAAM,CAAC;gBAGhB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,2BAA2B;IAOrD,QAAQ;IA6BR;;;;;;;OAOG;IACH,IAAI,OAAO,IAAI,OAAO,CAMrB;IAED;;OAEG;IACH,IAAI,GAAG,IAAI,MAAM,CAEhB;IAED;;OAEG;IACH,IAAI,UAAU,IAAI,MAAM,CAEvB;IAED;;OAEG;IACH,IAAI,iBAAiB,IAAI,OAAO,CAE/B;IAED;;OAEG;IACH,IAAI,iBAAiB,IAAI,OAAO,CAE/B;IAEK,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAgB7B"}