@olane/o-node 0.7.12-alpha.21 → 0.7.12-alpha.23

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 (175) hide show
  1. package/dist/o-core/src/connection/o-response.d.ts +26 -0
  2. package/dist/o-core/src/connection/o-response.d.ts.map +1 -0
  3. package/dist/o-core/src/connection/o-response.js +45 -0
  4. package/dist/o-core/src/error/enums/codes.error.d.ts +20 -0
  5. package/dist/o-core/src/error/enums/codes.error.d.ts.map +1 -0
  6. package/dist/o-core/src/error/enums/codes.error.js +20 -0
  7. package/dist/o-core/src/error/interfaces/o-error.interface.d.ts +6 -0
  8. package/dist/o-core/src/error/interfaces/o-error.interface.d.ts.map +1 -0
  9. package/dist/o-core/src/error/interfaces/o-error.interface.js +1 -0
  10. package/dist/o-core/src/error/o-error.d.ts +15 -0
  11. package/dist/o-core/src/error/o-error.d.ts.map +1 -0
  12. package/dist/o-core/src/error/o-error.js +27 -0
  13. package/dist/o-core/src/streaming/index.d.ts +11 -0
  14. package/dist/o-core/src/streaming/index.d.ts.map +1 -0
  15. package/dist/o-core/src/streaming/index.js +14 -0
  16. package/dist/o-core/src/streaming/protocol-builder.d.ts +62 -0
  17. package/dist/o-core/src/streaming/protocol-builder.d.ts.map +1 -0
  18. package/dist/o-core/src/streaming/protocol-builder.js +93 -0
  19. package/dist/o-core/src/streaming/stream-config.d.ts +36 -0
  20. package/dist/o-core/src/streaming/stream-config.d.ts.map +1 -0
  21. package/dist/o-core/src/streaming/stream-config.js +19 -0
  22. package/dist/o-core/src/streaming/stream-handler.base.d.ts +85 -0
  23. package/dist/o-core/src/streaming/stream-handler.base.d.ts.map +1 -0
  24. package/dist/o-core/src/streaming/stream-handler.base.js +112 -0
  25. package/dist/o-core/src/streaming/stream-transport.interface.d.ts +61 -0
  26. package/dist/o-core/src/streaming/stream-transport.interface.d.ts.map +1 -0
  27. package/dist/o-core/src/streaming/stream-transport.interface.js +10 -0
  28. package/dist/o-core/src/utils/streaming.utils.d.ts +37 -0
  29. package/dist/o-core/src/utils/streaming.utils.d.ts.map +1 -0
  30. package/dist/o-core/src/utils/streaming.utils.js +71 -0
  31. package/dist/o-node/src/connection/index.d.ts +5 -0
  32. package/dist/o-node/src/connection/index.d.ts.map +1 -0
  33. package/dist/o-node/src/connection/index.js +4 -0
  34. package/dist/o-node/src/connection/interfaces/o-node-connection-manager.config.d.ts +6 -0
  35. package/dist/o-node/src/connection/interfaces/o-node-connection-manager.config.d.ts.map +1 -0
  36. package/dist/o-node/src/connection/interfaces/o-node-connection-manager.config.js +1 -0
  37. package/dist/o-node/src/connection/interfaces/o-node-connection.config.d.ts +6 -0
  38. package/dist/o-node/src/connection/interfaces/o-node-connection.config.d.ts.map +1 -0
  39. package/dist/o-node/src/connection/interfaces/o-node-connection.config.js +1 -0
  40. package/dist/o-node/src/connection/o-node-connection.d.ts +20 -0
  41. package/dist/o-node/src/connection/o-node-connection.d.ts.map +1 -0
  42. package/dist/o-node/src/connection/o-node-connection.js +146 -0
  43. package/dist/o-node/src/connection/o-node-connection.manager.d.ts +19 -0
  44. package/dist/o-node/src/connection/o-node-connection.manager.d.ts.map +1 -0
  45. package/dist/o-node/src/connection/o-node-connection.manager.js +92 -0
  46. package/dist/o-node/src/index.d.ts +10 -0
  47. package/dist/o-node/src/index.d.ts.map +1 -0
  48. package/dist/o-node/src/index.js +9 -0
  49. package/dist/o-node/src/interfaces/i-heartbeatable-node.d.ts +49 -0
  50. package/dist/o-node/src/interfaces/i-heartbeatable-node.d.ts.map +1 -0
  51. package/dist/o-node/src/interfaces/i-heartbeatable-node.js +1 -0
  52. package/dist/o-node/src/interfaces/i-reconnectable-node.d.ts +46 -0
  53. package/dist/o-node/src/interfaces/i-reconnectable-node.d.ts.map +1 -0
  54. package/dist/o-node/src/interfaces/i-reconnectable-node.js +1 -0
  55. package/dist/o-node/src/interfaces/o-node.config.d.ts +66 -0
  56. package/dist/o-node/src/interfaces/o-node.config.d.ts.map +1 -0
  57. package/dist/o-node/src/interfaces/o-node.config.js +1 -0
  58. package/dist/o-node/src/interfaces/o-node.tool-config.d.ts +4 -0
  59. package/dist/o-node/src/interfaces/o-node.tool-config.d.ts.map +1 -0
  60. package/dist/o-node/src/interfaces/o-node.tool-config.js +1 -0
  61. package/dist/o-node/src/lib/network-activity.lib.d.ts +1 -0
  62. package/dist/o-node/src/lib/network-activity.lib.d.ts.map +1 -0
  63. package/dist/o-node/src/lib/network-activity.lib.js +34 -0
  64. package/dist/o-node/src/managers/o-connection-heartbeat.manager.d.ts +62 -0
  65. package/dist/o-node/src/managers/o-connection-heartbeat.manager.d.ts.map +1 -0
  66. package/dist/o-node/src/managers/o-connection-heartbeat.manager.js +213 -0
  67. package/dist/o-node/src/managers/o-reconnection.manager.d.ts +51 -0
  68. package/dist/o-node/src/managers/o-reconnection.manager.d.ts.map +1 -0
  69. package/dist/o-node/src/managers/o-reconnection.manager.js +266 -0
  70. package/dist/o-node/src/nodes/client.node.d.ts +7 -0
  71. package/dist/o-node/src/nodes/client.node.d.ts.map +1 -0
  72. package/dist/o-node/src/nodes/client.node.js +16 -0
  73. package/dist/o-node/src/nodes/index.d.ts +4 -0
  74. package/dist/o-node/src/nodes/index.d.ts.map +1 -0
  75. package/dist/o-node/src/nodes/index.js +3 -0
  76. package/dist/o-node/src/nodes/server.node.d.ts +7 -0
  77. package/dist/o-node/src/nodes/server.node.d.ts.map +1 -0
  78. package/dist/o-node/src/nodes/server.node.js +20 -0
  79. package/dist/o-node/src/nodes/websocket.node.d.ts +7 -0
  80. package/dist/o-node/src/nodes/websocket.node.d.ts.map +1 -0
  81. package/dist/o-node/src/nodes/websocket.node.js +18 -0
  82. package/dist/o-node/src/o-node.d.ts +72 -0
  83. package/dist/o-node/src/o-node.d.ts.map +1 -0
  84. package/dist/o-node/src/o-node.hierarchy-manager.d.ts +15 -0
  85. package/dist/o-node/src/o-node.hierarchy-manager.d.ts.map +1 -0
  86. package/dist/o-node/src/o-node.hierarchy-manager.js +15 -0
  87. package/dist/o-node/src/o-node.js +420 -0
  88. package/dist/o-node/src/o-node.notification-manager.d.ts +52 -0
  89. package/dist/o-node/src/o-node.notification-manager.d.ts.map +1 -0
  90. package/dist/o-node/src/o-node.notification-manager.js +185 -0
  91. package/dist/o-node/src/o-node.tool.d.ts +18 -0
  92. package/dist/o-node/src/o-node.tool.d.ts.map +1 -0
  93. package/dist/o-node/src/o-node.tool.js +116 -0
  94. package/dist/o-node/src/router/index.d.ts +6 -0
  95. package/dist/o-node/src/router/index.d.ts.map +1 -0
  96. package/dist/o-node/src/router/index.js +5 -0
  97. package/dist/o-node/src/router/interfaces/o-node-router.config.d.ts +3 -0
  98. package/dist/o-node/src/router/interfaces/o-node-router.config.d.ts.map +1 -0
  99. package/dist/o-node/src/router/interfaces/o-node-router.config.js +1 -0
  100. package/dist/o-node/src/router/interfaces/o-node-router.response.d.ts +8 -0
  101. package/dist/o-node/src/router/interfaces/o-node-router.response.d.ts.map +1 -0
  102. package/dist/o-node/src/router/interfaces/o-node-router.response.js +1 -0
  103. package/dist/o-node/src/router/o-node.address.d.ts +18 -0
  104. package/dist/o-node/src/router/o-node.address.d.ts.map +1 -0
  105. package/dist/o-node/src/router/o-node.address.js +29 -0
  106. package/dist/o-node/src/router/o-node.router.d.ts +45 -0
  107. package/dist/o-node/src/router/o-node.router.d.ts.map +1 -0
  108. package/dist/o-node/src/router/o-node.router.js +125 -0
  109. package/dist/o-node/src/router/o-node.routing-policy.d.ts +30 -0
  110. package/dist/o-node/src/router/o-node.routing-policy.d.ts.map +1 -0
  111. package/dist/o-node/src/router/o-node.routing-policy.js +57 -0
  112. package/dist/o-node/src/router/o-node.transport.d.ts +11 -0
  113. package/dist/o-node/src/router/o-node.transport.d.ts.map +1 -0
  114. package/dist/o-node/src/router/o-node.transport.js +18 -0
  115. package/dist/o-node/src/router/resolvers/index.d.ts +4 -0
  116. package/dist/o-node/src/router/resolvers/index.d.ts.map +1 -0
  117. package/dist/o-node/src/router/resolvers/index.js +3 -0
  118. package/dist/o-node/src/router/resolvers/o-node.leader-resolver-fallback.d.ts +8 -0
  119. package/dist/o-node/src/router/resolvers/o-node.leader-resolver-fallback.d.ts.map +1 -0
  120. package/dist/o-node/src/router/resolvers/o-node.leader-resolver-fallback.js +35 -0
  121. package/dist/o-node/src/router/resolvers/o-node.resolver.d.ts +11 -0
  122. package/dist/o-node/src/router/resolvers/o-node.resolver.d.ts.map +1 -0
  123. package/dist/o-node/src/router/resolvers/o-node.resolver.js +41 -0
  124. package/dist/o-node/src/router/resolvers/o-node.search-resolver.d.ts +170 -0
  125. package/dist/o-node/src/router/resolvers/o-node.search-resolver.d.ts.map +1 -0
  126. package/dist/o-node/src/router/resolvers/o-node.search-resolver.js +285 -0
  127. package/dist/o-node/src/router/route.request.d.ts +14 -0
  128. package/dist/o-node/src/router/route.request.d.ts.map +1 -0
  129. package/dist/o-node/src/router/route.request.js +1 -0
  130. package/dist/o-node/src/streaming/index.d.ts +10 -0
  131. package/dist/o-node/src/streaming/index.d.ts.map +1 -0
  132. package/dist/o-node/src/streaming/index.js +12 -0
  133. package/dist/o-node/src/streaming/libp2p-stream-transport.d.ts +50 -0
  134. package/dist/o-node/src/streaming/libp2p-stream-transport.d.ts.map +1 -0
  135. package/dist/o-node/src/streaming/libp2p-stream-transport.js +137 -0
  136. package/dist/o-node/src/streaming/node-stream-handler.d.ts +65 -0
  137. package/dist/o-node/src/streaming/node-stream-handler.d.ts.map +1 -0
  138. package/dist/o-node/src/streaming/node-stream-handler.js +101 -0
  139. package/dist/o-node/src/utils/circuit-breaker.d.ts +107 -0
  140. package/dist/o-node/src/utils/circuit-breaker.d.ts.map +1 -0
  141. package/dist/o-node/src/utils/circuit-breaker.js +175 -0
  142. package/dist/o-node/src/utils/circuit-breaker.test.d.ts +2 -0
  143. package/dist/o-node/src/utils/circuit-breaker.test.d.ts.map +1 -0
  144. package/dist/o-node/src/utils/circuit-breaker.test.js +262 -0
  145. package/dist/o-node/src/utils/leader-request-wrapper.d.ts +66 -0
  146. package/dist/o-node/src/utils/leader-request-wrapper.d.ts.map +1 -0
  147. package/dist/o-node/src/utils/leader-request-wrapper.js +160 -0
  148. package/dist/o-node/src/utils/leader-request-wrapper.test.d.ts +1 -0
  149. package/dist/o-node/src/utils/leader-request-wrapper.test.d.ts.map +1 -0
  150. package/dist/o-node/src/utils/leader-request-wrapper.test.js +246 -0
  151. package/dist/o-node/src/utils/network.utils.d.ts +20 -0
  152. package/dist/o-node/src/utils/network.utils.d.ts.map +1 -0
  153. package/dist/o-node/src/utils/network.utils.js +74 -0
  154. package/dist/o-node/test/o-node.spec.d.ts +2 -0
  155. package/dist/o-node/test/o-node.spec.d.ts.map +1 -0
  156. package/dist/o-node/test/o-node.spec.js +20 -0
  157. package/dist/o-node/test/search-resolver.spec.d.ts +2 -0
  158. package/dist/o-node/test/search-resolver.spec.d.ts.map +1 -0
  159. package/dist/o-node/test/search-resolver.spec.js +693 -0
  160. package/dist/src/connection/o-node-connection.d.ts +7 -0
  161. package/dist/src/connection/o-node-connection.d.ts.map +1 -1
  162. package/dist/src/connection/o-node-connection.js +89 -2
  163. package/dist/src/connection/o-node-connection.manager.d.ts +2 -0
  164. package/dist/src/connection/o-node-connection.manager.d.ts.map +1 -1
  165. package/dist/src/connection/o-node-connection.manager.js +5 -1
  166. package/dist/src/interfaces/o-node.config.d.ts +16 -0
  167. package/dist/src/interfaces/o-node.config.d.ts.map +1 -1
  168. package/dist/src/o-node.d.ts +1 -1
  169. package/dist/src/o-node.d.ts.map +1 -1
  170. package/dist/src/o-node.js +5 -1
  171. package/dist/src/o-node.tool.d.ts.map +1 -1
  172. package/dist/src/o-node.tool.js +37 -7
  173. package/dist/src/router/resolvers/o-node.search-resolver.d.ts.map +1 -1
  174. package/dist/src/router/resolvers/o-node.search-resolver.js +10 -3
  175. package/package.json +6 -6
@@ -8,6 +8,13 @@ export declare class oNodeConnection extends oConnection {
8
8
  read(source: Stream): Promise<any>;
9
9
  validate(): void;
10
10
  transmit(request: oRequest): Promise<oResponse>;
11
+ /**
12
+ * Transmit a request and receive streaming chunks via callback
13
+ * @param request The request to send
14
+ * @param onChunk Callback function called for each chunk received
15
+ * @returns Promise that resolves when stream is complete
16
+ */
17
+ transmitStreaming(request: oRequest, onChunk: (chunk: any, sequence: number, isLast: boolean) => void): Promise<void>;
11
18
  close(): Promise<void>;
12
19
  }
13
20
  //# sourceMappingURL=o-node-connection.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"o-node-connection.d.ts","sourceRoot":"","sources":["../../../src/connection/o-node-connection.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EAIV,MAAM,EAEP,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,WAAW,EAGX,QAAQ,EACR,SAAS,EACV,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AAEjF,qBAAa,eAAgB,SAAQ,WAAW;IAGlC,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,qBAAqB;IAFrD,aAAa,EAAE,UAAU,CAAC;gBAEF,MAAM,EAAE,qBAAqB;IAKtD,IAAI,CAAC,MAAM,EAAE,MAAM;IAWzB,QAAQ;IAOF,QAAQ,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC;IAiD/C,KAAK;CAKZ"}
1
+ {"version":3,"file":"o-node-connection.d.ts","sourceRoot":"","sources":["../../../src/connection/o-node-connection.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EAIV,MAAM,EAEP,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,WAAW,EAGX,QAAQ,EACR,SAAS,EACV,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AAEjF,qBAAa,eAAgB,SAAQ,WAAW;IAGlC,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,qBAAqB;IAFrD,aAAa,EAAE,UAAU,CAAC;gBAEF,MAAM,EAAE,qBAAqB;IAKtD,IAAI,CAAC,MAAM,EAAE,MAAM;IAWzB,QAAQ;IAOF,QAAQ,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC;IAmDrD;;;;;OAKG;IACG,iBAAiB,CACrB,OAAO,EAAE,QAAQ,EACjB,OAAO,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,KAAK,IAAI,GAC/D,OAAO,CAAC,IAAI,CAAC;IAuGV,KAAK;CAKZ"}
@@ -9,7 +9,7 @@ export class oNodeConnection extends oConnection {
9
9
  async read(source) {
10
10
  const bytes = byteStream(source);
11
11
  const output = await bytes.read({
12
- signal: AbortSignal.timeout(120000), // 2 min timeout
12
+ signal: AbortSignal.timeout(this.config.readTimeoutMs ?? 120000), // Default: 2 min timeout
13
13
  });
14
14
  const outputObj = output instanceof Uint8ArrayList ? output.subarray() : output;
15
15
  const jsonStr = new TextDecoder().decode(outputObj);
@@ -39,7 +39,9 @@ export class oNodeConnection extends oConnection {
39
39
  // If send() returns false, wait for the stream to drain before continuing
40
40
  if (!sent) {
41
41
  this.logger.debug('Stream buffer full, waiting for drain...');
42
- await stream.onDrain({ signal: AbortSignal.timeout(30000) }); // 30 second timeout
42
+ await stream.onDrain({
43
+ signal: AbortSignal.timeout(this.config.drainTimeoutMs ?? 30000),
44
+ }); // Default: 30 second timeout
43
45
  }
44
46
  const res = await this.read(stream);
45
47
  await stream.close();
@@ -56,6 +58,91 @@ export class oNodeConnection extends oConnection {
56
58
  throw error;
57
59
  }
58
60
  }
61
+ /**
62
+ * Transmit a request and receive streaming chunks via callback
63
+ * @param request The request to send
64
+ * @param onChunk Callback function called for each chunk received
65
+ * @returns Promise that resolves when stream is complete
66
+ */
67
+ async transmitStreaming(request, onChunk) {
68
+ try {
69
+ const stream = await this.p2pConnection.newStream(this.nextHopAddress.protocol, {
70
+ maxOutboundStreams: Infinity,
71
+ runOnLimitedConnection: true,
72
+ });
73
+ if (!stream || (stream.status !== 'open' && stream.status !== 'reset')) {
74
+ throw new oError(oErrorCodes.FAILED_TO_DIAL_TARGET, 'Failed to dial target');
75
+ }
76
+ if (stream.status === 'reset') {
77
+ throw new oError(oErrorCodes.CONNECTION_LIMIT_REACHED, 'Connection limit reached');
78
+ }
79
+ // Send the request
80
+ const data = new TextEncoder().encode(request.toString());
81
+ const sent = stream.send(data);
82
+ if (!sent) {
83
+ this.logger.debug('Stream buffer full, waiting for drain...');
84
+ await stream.onDrain({
85
+ signal: AbortSignal.timeout(this.config.drainTimeoutMs ?? 30000),
86
+ });
87
+ }
88
+ // Set up to receive multiple chunks
89
+ return new Promise((resolve, reject) => {
90
+ const messageHandler = async (event) => {
91
+ try {
92
+ const bytes = event.data instanceof Uint8ArrayList
93
+ ? event.data.subarray()
94
+ : event.data;
95
+ const jsonStr = new TextDecoder().decode(bytes);
96
+ const response = JSON.parse(jsonStr);
97
+ // Check if this is a streaming response
98
+ if (response.result &&
99
+ response.result._streaming === true) {
100
+ const { _data, _sequence, _isLast } = response.result;
101
+ onChunk(_data, _sequence, _isLast);
102
+ if (_isLast) {
103
+ stream.removeEventListener('message', messageHandler);
104
+ await stream.close();
105
+ resolve();
106
+ }
107
+ }
108
+ else {
109
+ // Non-streaming response (fallback for compatibility)
110
+ onChunk(response.result, 1, true);
111
+ stream.removeEventListener('message', messageHandler);
112
+ await stream.close();
113
+ resolve();
114
+ }
115
+ }
116
+ catch (error) {
117
+ stream.removeEventListener('message', messageHandler);
118
+ await stream.close().catch(() => { });
119
+ reject(error);
120
+ }
121
+ };
122
+ stream.addEventListener('message', messageHandler);
123
+ // Set up timeout for receiving first chunk
124
+ const timeout = setTimeout(async () => {
125
+ stream.removeEventListener('message', messageHandler);
126
+ await stream.close().catch(() => { });
127
+ reject(new oError(oErrorCodes.TIMEOUT, 'Timeout waiting for streaming response'));
128
+ }, this.config.readTimeoutMs ?? 120000);
129
+ // Clear timeout when first chunk arrives
130
+ const originalHandler = messageHandler;
131
+ const wrappedHandler = async (event) => {
132
+ clearTimeout(timeout);
133
+ await originalHandler(event);
134
+ };
135
+ stream.removeEventListener('message', messageHandler);
136
+ stream.addEventListener('message', wrappedHandler);
137
+ });
138
+ }
139
+ catch (error) {
140
+ if (error?.name === 'UnsupportedProtocolError') {
141
+ throw new oError(oErrorCodes.NOT_FOUND, 'Address not found');
142
+ }
143
+ throw error;
144
+ }
145
+ }
59
146
  async close() {
60
147
  this.logger.debug('Closing connection');
61
148
  await this.p2pConnection.close();
@@ -4,6 +4,8 @@ import { oNodeConnectionManagerConfig } from './interfaces/o-node-connection-man
4
4
  import { oNodeConnection } from './o-node-connection.js';
5
5
  export declare class oNodeConnectionManager extends oConnectionManager {
6
6
  private p2pNode;
7
+ private defaultReadTimeoutMs?;
8
+ private defaultDrainTimeoutMs?;
7
9
  constructor(config: oNodeConnectionManagerConfig);
8
10
  /**
9
11
  * Connect to a given address with exponential backoff retry
@@ -1 +1 @@
1
- {"version":3,"file":"o-node-connection.manager.d.ts","sourceRoot":"","sources":["../../../src/connection/o-node-connection.manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,EAAE,4BAA4B,EAAE,MAAM,kDAAkD,CAAC;AAEhG,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,qBAAa,sBAAuB,SAAQ,kBAAkB;IAC5D,OAAO,CAAC,OAAO,CAAS;gBAEZ,MAAM,EAAE,4BAA4B;IAKhD;;;;OAIG;IACG,OAAO,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,eAAe,CAAC;IAqFlE,QAAQ,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO;IAIpC,mBAAmB,CAAC,OAAO,EAAE,QAAQ,GAAG,WAAW,GAAG,IAAI;CAe3D"}
1
+ {"version":3,"file":"o-node-connection.manager.d.ts","sourceRoot":"","sources":["../../../src/connection/o-node-connection.manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,EAAE,4BAA4B,EAAE,MAAM,kDAAkD,CAAC;AAEhG,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,qBAAa,sBAAuB,SAAQ,kBAAkB;IAC5D,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,oBAAoB,CAAC,CAAS;IACtC,OAAO,CAAC,qBAAqB,CAAC,CAAS;gBAE3B,MAAM,EAAE,4BAA4B;IAOhD;;;;OAIG;IACG,OAAO,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,eAAe,CAAC;IA6FlE,QAAQ,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO;IAIpC,mBAAmB,CAAC,OAAO,EAAE,QAAQ,GAAG,WAAW,GAAG,IAAI;CAe3D"}
@@ -4,6 +4,8 @@ export class oNodeConnectionManager extends oConnectionManager {
4
4
  constructor(config) {
5
5
  super(config);
6
6
  this.p2pNode = config.p2pNode;
7
+ this.defaultReadTimeoutMs = config.defaultReadTimeoutMs;
8
+ this.defaultDrainTimeoutMs = config.defaultDrainTimeoutMs;
7
9
  }
8
10
  /**
9
11
  * Connect to a given address with exponential backoff retry
@@ -11,7 +13,7 @@ export class oNodeConnectionManager extends oConnectionManager {
11
13
  * @returns The connection object
12
14
  */
13
15
  async connect(config) {
14
- const { address, nextHopAddress, callerAddress } = config;
16
+ const { address, nextHopAddress, callerAddress, readTimeoutMs, drainTimeoutMs, } = config;
15
17
  // check if we already have a connection to this address
16
18
  // TODO: how can we enable caching of connections & connection lifecycles
17
19
  if (this.isCached(nextHopAddress)) {
@@ -46,6 +48,8 @@ export class oNodeConnectionManager extends oConnectionManager {
46
48
  address: address,
47
49
  p2pConnection: p2pConnection,
48
50
  callerAddress: callerAddress,
51
+ readTimeoutMs: readTimeoutMs ?? this.defaultReadTimeoutMs,
52
+ drainTimeoutMs: drainTimeoutMs ?? this.defaultDrainTimeoutMs,
49
53
  });
50
54
  if (attempt > 0) {
51
55
  this.logger.info(`Successfully connected to ${nextHopAddress.toString()} on retry attempt ${attempt}`);
@@ -46,5 +46,21 @@ export interface oNodeConfig extends oCoreConfig {
46
46
  halfOpenMaxAttempts?: number;
47
47
  };
48
48
  };
49
+ /**
50
+ * Connection timeout configuration
51
+ * Controls timeouts for stream read and drain operations in connections
52
+ */
53
+ connectionTimeouts?: {
54
+ /**
55
+ * Timeout in milliseconds for reading response data from a stream
56
+ * Default: 120000 (2 minutes)
57
+ */
58
+ readTimeoutMs?: number;
59
+ /**
60
+ * Timeout in milliseconds for waiting for stream buffer to drain when backpressure occurs
61
+ * Default: 30000 (30 seconds)
62
+ */
63
+ drainTimeoutMs?: number;
64
+ };
49
65
  }
50
66
  //# sourceMappingURL=o-node.config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"o-node.config.d.ts","sourceRoot":"","sources":["../../../src/interfaces/o-node.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE3D,MAAM,WAAW,WAAY,SAAQ,WAAW;IAC9C,MAAM,EAAE,YAAY,GAAG,IAAI,CAAC;IAC5B,MAAM,EAAE,YAAY,GAAG,IAAI,CAAC;IAE5B;;;OAGG;IACH,mBAAmB,CAAC,EAAE;QACpB,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,aAAa,CAAC,EAAE,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AAE,MAAM,CAAC;QACpB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,aAAa,CAAC,EAAE,OAAO,CAAC;QACxB,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB,WAAW,CAAC,EAAE,OAAO,CAAC;KACvB,CAAC;IAEF;;;OAGG;IACH,YAAY,CAAC,EAAE;QACb,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,iBAAiB,CAAC,EAAE,OAAO,CAAC;QAC5B,yBAAyB,CAAC,EAAE,MAAM,CAAC;QACnC,yBAAyB,CAAC,EAAE,MAAM,CAAC;KACpC,CAAC;IAEF;;;OAGG;IACH,WAAW,CAAC,EAAE;QACZ,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,cAAc,CAAC,EAAE;YACf,OAAO,CAAC,EAAE,OAAO,CAAC;YAClB,gBAAgB,CAAC,EAAE,MAAM,CAAC;YAC1B,aAAa,CAAC,EAAE,MAAM,CAAC;YACvB,mBAAmB,CAAC,EAAE,MAAM,CAAC;SAC9B,CAAC;KACH,CAAC;IAEF;;;OAGG;IACH,kBAAkB,CAAC,EAAE;QACnB;;;WAGG;QACH,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB;;;WAGG;QACH,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB,CAAC;CACH"}
@@ -45,7 +45,7 @@ export declare class oNode extends oToolBase {
45
45
  */
46
46
  configure(): Promise<Libp2pConfig>;
47
47
  protected createNode(): Promise<Libp2p>;
48
- connect(nextHopAddress: oNodeAddress, targetAddress: oNodeAddress): Promise<oNodeConnection>;
48
+ connect(nextHopAddress: oNodeAddress, targetAddress: oNodeAddress, readTimeoutMs?: number, drainTimeoutMs?: number): Promise<oNodeConnection>;
49
49
  initConnectionManager(): Promise<void>;
50
50
  initReconnectionManager(): Promise<void>;
51
51
  hookInitializeFinished(): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"o-node.d.ts","sourceRoot":"","sources":["../../src/o-node.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,MAAM,EACN,YAAY,EACb,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzC,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAIL,QAAQ,EACR,QAAQ,EAER,oBAAoB,EACrB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACpE,OAAO,EAAE,sBAAsB,EAAE,MAAM,2CAA2C,CAAC;AAGnF,OAAO,EAAmB,SAAS,EAAE,MAAM,eAAe,CAAC;AAI3D,OAAO,EAAE,2BAA2B,EAAE,MAAM,8CAA8C,CAAC;AAC3F,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAC5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAEzE,qBAAa,KAAM,SAAQ,SAAS;IAC3B,MAAM,EAAG,MAAM,CAAC;IAChB,OAAO,EAAG,MAAM,CAAC;IACjB,OAAO,EAAG,YAAY,CAAC;IACvB,MAAM,EAAE,WAAW,CAAC;IACpB,iBAAiB,EAAG,sBAAsB,CAAC;IAC3C,gBAAgB,EAAG,qBAAqB,CAAC;IACzC,0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AmB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC;IAG1D;;;OAGG;IACG,SAAS,IAAI,OAAO,CAAC,YAAY,CAAC;cAqHxB,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC;IAMvC,OAAO,CACX,cAAc,EAAE,YAAY,EAC5B,aAAa,EAAE,YAAY,EAC3B,aAAa,CAAC,EAAE,MAAM,EACtB,cAAc,CAAC,EAAE,MAAM,GACtB,OAAO,CAAC,eAAe,CAAC;IA4BrB,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC;IAQtC,uBAAuB,IAAI,OAAO,CAAC,IAAI,CAAC;IAiBxC,sBAAsB,IAAI,OAAO,CAAC,IAAI,CAAC;IAEvC,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC;IAsBlC,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAgEjC;;OAEG;IACG,GAAG,CACP,OAAO,EAAE,QAAQ,EACjB,IAAI,CAAC,EAAE;QACL,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,MAAM,CAAC,EAAE;YAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;SAAE,CAAC;QAChC,EAAE,CAAC,EAAE,MAAM,CAAC;KACb,EACD,OAAO,CAAC,EAAE;QACR,SAAS,CAAC,EAAE,OAAO,CAAC;KACrB,GACA,OAAO,CAAC,GAAG,CAAC;IAUT,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAc/B,UAAU,IAAI,YAAY,EAAE;IAI5B,UAAU,IAAI,YAAY,EAAE;IAI5B,WAAW,IAAI,YAAY,EAAE;IAI7B,WAAW,CAAC,YAAY,EAAE,YAAY,GAAG,IAAI;CAG9C"}
@@ -279,7 +279,7 @@ export class oNode extends oToolBase {
279
279
  this.p2pNode = await createNode(params);
280
280
  return this.p2pNode;
281
281
  }
282
- async connect(nextHopAddress, targetAddress) {
282
+ async connect(nextHopAddress, targetAddress, readTimeoutMs, drainTimeoutMs) {
283
283
  if (!this.connectionManager) {
284
284
  this.logger.error('Connection manager not initialized');
285
285
  throw new Error('Node is not ready to connect to other nodes');
@@ -289,6 +289,8 @@ export class oNode extends oToolBase {
289
289
  address: targetAddress,
290
290
  nextHopAddress,
291
291
  callerAddress: this.address,
292
+ readTimeoutMs,
293
+ drainTimeoutMs,
292
294
  })
293
295
  .catch((error) => {
294
296
  // TODO: we need to handle this better and document
@@ -305,6 +307,8 @@ export class oNode extends oToolBase {
305
307
  async initConnectionManager() {
306
308
  this.connectionManager = new oNodeConnectionManager({
307
309
  p2pNode: this.p2pNode,
310
+ defaultReadTimeoutMs: this.config.connectionTimeouts?.readTimeoutMs,
311
+ defaultDrainTimeoutMs: this.config.connectionTimeouts?.drainTimeoutMs,
308
312
  });
309
313
  }
310
314
  async initReconnectionManager() {
@@ -1 +1 @@
1
- {"version":3,"file":"o-node.tool.d.ts","sourceRoot":"","sources":["../../src/o-node.tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAGR,QAAQ,EAGT,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;;AAIrD;;;;GAIG;AACH,qBAAa,SAAU,SAAQ,cAAkB;IACzC,cAAc,CAAC,OAAO,EAAE,QAAQ;IAQhC,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAW3B,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAiDnE,cAAc,IAAI,OAAO,CAAC,GAAG,CAAC;IAQ9B,oBAAoB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC;CA2B5D"}
1
+ {"version":3,"file":"o-node.tool.d.ts","sourceRoot":"","sources":["../../src/o-node.tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAGR,QAAQ,EAGT,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;;AAIrD;;;;GAIG;AACH,qBAAa,SAAU,SAAQ,cAAkB;IACzC,cAAc,CAAC,OAAO,EAAE,QAAQ;IAQhC,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAW3B,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAiGnE,cAAc,IAAI,OAAO,CAAC,GAAG,CAAC;IAQ9B,oBAAoB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC;CA2B5D"}
@@ -46,16 +46,46 @@ export class oNodeTool extends oTool(oServerNode) {
46
46
  error: responseError.toJSON(),
47
47
  };
48
48
  });
49
- if (success) {
50
- this.metrics.successCount++;
49
+ // Check if result is a streaming AsyncGenerator
50
+ if (CoreUtils.isAsyncGenerator(result)) {
51
+ this.logger.debug('Handling streaming response for: ' + request.method);
52
+ let sequence = 0;
53
+ try {
54
+ for await (const chunk of result) {
55
+ sequence++;
56
+ const isLast = false; // We'll handle the last chunk separately
57
+ await CoreUtils.sendStreamChunk(chunk, stream, sequence, isLast, request);
58
+ if (success) {
59
+ this.metrics.successCount++;
60
+ }
61
+ }
62
+ // Send final empty chunk to signal completion
63
+ await CoreUtils.sendStreamChunk(null, stream, sequence + 1, true, request);
64
+ }
65
+ catch (error) {
66
+ this.logger.error('Error in streaming response: ', error);
67
+ success = false;
68
+ this.metrics.errorCount++;
69
+ // Send error chunk
70
+ const responseError = error instanceof oError
71
+ ? error
72
+ : new oError(oErrorCodes.UNKNOWN, error.message);
73
+ await CoreUtils.sendStreamChunk({ error: responseError.toJSON() }, stream, sequence + 1, true, request);
74
+ }
51
75
  }
52
76
  else {
53
- this.metrics.errorCount++;
77
+ // Non-streaming response - original behavior
78
+ if (success) {
79
+ this.metrics.successCount++;
80
+ }
81
+ else {
82
+ this.metrics.errorCount++;
83
+ }
84
+ // compose the response & add the expected connection + request fields
85
+ const response = CoreUtils.buildResponse(request, result, result?.error);
86
+ // add the request method to the response
87
+ await CoreUtils.sendResponse(response, stream);
54
88
  }
55
- // compose the response & add the expected connection + request fields
56
- const response = CoreUtils.buildResponse(request, result, result?.error);
57
- // add the request method to the response
58
- await CoreUtils.sendResponse(response, stream);
59
89
  };
60
90
  // Attach listener synchronously before any async operations
61
91
  stream.addEventListener('message', messageHandler);
@@ -1 +1 @@
1
- {"version":3,"file":"o-node.search-resolver.d.ts","sourceRoot":"","sources":["../../../../src/router/resolvers/o-node.search-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,gBAAgB,EAChB,KAAK,EAEL,UAAU,EACV,cAAc,EAEd,aAAa,EAEd,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+DG;AACH,qBAAa,eAAgB,SAAQ,gBAAgB;IACvC,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,QAAQ;gBAAjB,OAAO,EAAE,QAAQ;IAIhD,IAAI,gBAAgB,IAAI,UAAU,EAAE,CAEnC;IAED;;;;OAIG;IACH,SAAS,CAAC,kBAAkB,IAAI,QAAQ;IAIxC;;;;OAIG;IACH,SAAS,CAAC,eAAe,IAAI,MAAM;IAInC;;;;;OAKG;IACH,SAAS,CAAC,iBAAiB,CAAC,OAAO,EAAE,QAAQ,GAAG,GAAG;IAOnD;;;;;;OAMG;IACH,SAAS,CAAC,mBAAmB,CAAC,OAAO,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,KAAK,GAAG,GAAG,EAAE;IASjE;;;;;OAKG;IACH,SAAS,CAAC,YAAY,CAAC,OAAO,EA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G;IACH,SAAS,CAAC,mBAAmB,CAAC,OAAO,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,KAAK,GAAG,GAAG,EAAE;IASjE;;;;;OAKG;IACH,SAAS,CAAC,YAAY,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI;IAIlD;;;;;OAKG;IACH,SAAS,CAAC,aAAa,CAAC,MAAM,EAAE,GAAG,GAAG,cAAc,EAAE;IAOtD;;;;;;;;;;;OAWG;IACH,SAAS,CAAC,wBAAwB,CAChC,OAAO,EAAE,QAAQ,EACjB,gBAAgB,EAAE,cAAc,EAAE,EAClC,IAAI,EAAE,KAAK,GACV,cAAc,EAAE;IAgBnB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAyCG;IACH,SAAS,CAAC,gBAAgB,CACxB,IAAI,EAAE,KAAK,EACX,qBAAqB,EAAE,QAAQ,EAC/B,YAAY,EAAE,GAAG,GAChB,QAAQ;IAeL,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC;CAsG/D"}
@@ -1,4 +1,4 @@
1
- import { oAddress, oAddressResolver, oCustomTransport, RestrictedAddresses, } from '@olane/o-core';
1
+ import { NodeState, oAddress, oAddressResolver, oCustomTransport, RestrictedAddresses, } from '@olane/o-core';
2
2
  import { oNodeTransport } from '../o-node.transport.js';
3
3
  /**
4
4
  * Address resolver that searches a registry to find transports for addresses.
@@ -78,7 +78,7 @@ export class oSearchResolver extends oAddressResolver {
78
78
  * @returns The registry address to query
79
79
  */
80
80
  getRegistryAddress() {
81
- return new oAddress(RestrictedAddresses.REGISTRY);
81
+ return new oAddress('o://leader/registry');
82
82
  }
83
83
  /**
84
84
  * Returns the method name to call on the registry.
@@ -217,12 +217,19 @@ export class oSearchResolver extends oAddressResolver {
217
217
  requestOverride: resolveRequest,
218
218
  };
219
219
  }
220
+ if (node.state !== NodeState.RUNNING) {
221
+ return {
222
+ nextHopAddress: address,
223
+ targetAddress: targetAddress,
224
+ requestOverride: resolveRequest,
225
+ };
226
+ }
220
227
  // Perform registry search with error handling
221
228
  const searchParams = this.buildSearchParams(address);
222
229
  const registryAddress = this.getRegistryAddress();
223
230
  let searchResponse;
224
231
  try {
225
- searchResponse = await node.useChild(registryAddress, {
232
+ searchResponse = await node.use(registryAddress, {
226
233
  method: this.getSearchMethod(),
227
234
  params: searchParams,
228
235
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@olane/o-node",
3
- "version": "0.7.12-alpha.21",
3
+ "version": "0.7.12-alpha.23",
4
4
  "type": "module",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",
@@ -54,12 +54,12 @@
54
54
  "typescript": "5.4.5"
55
55
  },
56
56
  "dependencies": {
57
- "@olane/o-config": "0.7.12-alpha.21",
58
- "@olane/o-core": "0.7.12-alpha.21",
59
- "@olane/o-protocol": "0.7.12-alpha.21",
60
- "@olane/o-tool": "0.7.12-alpha.21",
57
+ "@olane/o-config": "0.7.12-alpha.23",
58
+ "@olane/o-core": "0.7.12-alpha.23",
59
+ "@olane/o-protocol": "0.7.12-alpha.23",
60
+ "@olane/o-tool": "0.7.12-alpha.23",
61
61
  "debug": "^4.4.1",
62
62
  "dotenv": "^16.5.0"
63
63
  },
64
- "gitHead": "d3bfb08e99cae168b9a6276e45b8e38b25857ae4"
64
+ "gitHead": "26031c23b8802d7ad89ec333f2c5c5b082333119"
65
65
  }