@olane/o-client-limited 0.7.39 → 0.7.41
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { oNodeConnection } from '@olane/o-node';
|
|
2
|
-
import type { oNodeConnectionConfig } from '@olane/o-node
|
|
2
|
+
import type { oNodeConnectionConfig } from '@olane/o-node';
|
|
3
3
|
/**
|
|
4
4
|
* oLimitedConnection extends oNodeConnection with stream reuse enabled
|
|
5
5
|
* This is optimized for limited connections where creating new streams is expensive
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"o-limited-connection.d.ts","sourceRoot":"","sources":["../../../src/connection/o-limited-connection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"o-limited-connection.d.ts","sourceRoot":"","sources":["../../../src/connection/o-limited-connection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAE3D;;;GAGG;AACH,qBAAa,kBAAmB,SAAQ,eAAe;gBACzC,MAAM,EAAE,qBAAqB;CAQ1C"}
|
|
@@ -5,9 +5,11 @@ import { oNodeConnection } from '@olane/o-node';
|
|
|
5
5
|
*/
|
|
6
6
|
export class oLimitedConnection extends oNodeConnection {
|
|
7
7
|
constructor(config) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
const reusePolicy = config.reusePolicy ?? 'reuse';
|
|
9
|
+
super({
|
|
10
|
+
...config,
|
|
11
|
+
reusePolicy: reusePolicy,
|
|
12
|
+
});
|
|
13
|
+
this.reusePolicy = reusePolicy;
|
|
12
14
|
}
|
|
13
15
|
}
|
|
@@ -51,7 +51,7 @@ describe('Error Handling & Resource Management', () => {
|
|
|
51
51
|
// Should not throw
|
|
52
52
|
const stream = await connection.getOrCreateStream();
|
|
53
53
|
expect(stream).toBeDefined();
|
|
54
|
-
expect(stream.status).toBe('open');
|
|
54
|
+
expect(stream.p2pStream.status).toBe('open');
|
|
55
55
|
});
|
|
56
56
|
});
|
|
57
57
|
describe('Stream Creation Failures', () => {
|
|
@@ -111,7 +111,7 @@ describe('Error Handling & Resource Management', () => {
|
|
|
111
111
|
expect(streams.length).toBe(10);
|
|
112
112
|
streams.forEach((stream) => {
|
|
113
113
|
expect(stream).toBeDefined();
|
|
114
|
-
expect(stream.protocol).toBe(testProtocol);
|
|
114
|
+
expect(stream.p2pStream.protocol).toBe(testProtocol);
|
|
115
115
|
});
|
|
116
116
|
// With stream reuse, they should all get the same stream
|
|
117
117
|
// (since the first one creates it, rest reuse it)
|
|
@@ -160,7 +160,7 @@ describe('Error Handling & Resource Management', () => {
|
|
|
160
160
|
const stream2 = await stream2Promise;
|
|
161
161
|
// Should reuse the same stream
|
|
162
162
|
expect(stream2).toBe(stream1);
|
|
163
|
-
expect(stream2.status).toBe('open');
|
|
163
|
+
expect(stream2.p2pStream.status).toBe('open');
|
|
164
164
|
});
|
|
165
165
|
});
|
|
166
166
|
describe('Stream State Edge Cases', () => {
|
|
@@ -191,7 +191,7 @@ describe('Error Handling & Resource Management', () => {
|
|
|
191
191
|
// Next call should create a new stream (not reuse the reset one)
|
|
192
192
|
const secondStream = await connection.getOrCreateStream();
|
|
193
193
|
expect(secondStream).not.toBe(stream1);
|
|
194
|
-
expect(secondStream.status).toBe('open');
|
|
194
|
+
expect(secondStream.p2pStream.status).toBe('open');
|
|
195
195
|
});
|
|
196
196
|
it('should handle stream that becomes non-writable', async () => {
|
|
197
197
|
const mockConnection = createMockP2PConnection('test-conn', 'open');
|
|
@@ -216,7 +216,7 @@ describe('Error Handling & Resource Management', () => {
|
|
|
216
216
|
// Should create new stream instead of using non-writable one
|
|
217
217
|
const newStream = await connection.getOrCreateStream();
|
|
218
218
|
expect(newStream).not.toBe(stream);
|
|
219
|
-
expect(newStream.writeStatus).toBe('writable');
|
|
219
|
+
expect(newStream.p2pStream.writeStatus).toBe('writable');
|
|
220
220
|
});
|
|
221
221
|
it('should handle stream where remote side closes read', async () => {
|
|
222
222
|
const mockConnection = createMockP2PConnection('test-conn', 'open');
|
|
@@ -241,7 +241,7 @@ describe('Error Handling & Resource Management', () => {
|
|
|
241
241
|
// Should create new stream
|
|
242
242
|
const newStream = await connection.getOrCreateStream();
|
|
243
243
|
expect(newStream).not.toBe(stream);
|
|
244
|
-
expect(newStream.remoteReadStatus).toBe('readable');
|
|
244
|
+
expect(newStream.p2pStream.remoteReadStatus).toBe('readable');
|
|
245
245
|
});
|
|
246
246
|
});
|
|
247
247
|
describe('Resource Cleanup', () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@olane/o-client-limited",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.41",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"types": "dist/src/index.d.ts",
|
|
@@ -53,13 +53,13 @@
|
|
|
53
53
|
"typescript": "5.4.5"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@olane/o-config": "0.7.
|
|
57
|
-
"@olane/o-core": "0.7.
|
|
58
|
-
"@olane/o-node": "0.7.
|
|
59
|
-
"@olane/o-protocol": "0.7.
|
|
60
|
-
"@olane/o-tool": "0.7.
|
|
56
|
+
"@olane/o-config": "0.7.41",
|
|
57
|
+
"@olane/o-core": "0.7.41",
|
|
58
|
+
"@olane/o-node": "0.7.41",
|
|
59
|
+
"@olane/o-protocol": "0.7.41",
|
|
60
|
+
"@olane/o-tool": "0.7.41",
|
|
61
61
|
"debug": "^4.4.1",
|
|
62
62
|
"dotenv": "^16.5.0"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "f705ab1099e0df6220c8f1d9a44e5b6cd09eb224"
|
|
65
65
|
}
|