@rljson/server 0.0.6 → 0.0.7

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.
package/dist/server.d.ts CHANGED
@@ -41,6 +41,14 @@ export interface ServerOptions {
41
41
  * Defaults to the SyncConfig's ackTimeoutMs (or 10 000 ms).
42
42
  */
43
43
  ackTimeoutMs?: number;
44
+ /**
45
+ * When true, the server's IoMulti and BsMulti will NOT include a local
46
+ * in-memory cache (IoMem / BsMem). The server will only read data from
47
+ * connected client peers. Useful when the server should act as a pure
48
+ * relay without caching any data locally.
49
+ * Defaults to false (local cache enabled).
50
+ */
51
+ disableLocalCache?: boolean;
44
52
  }
45
53
  export declare class Server extends BaseNode {
46
54
  private _route;
@@ -66,6 +74,7 @@ export declare class Server extends BaseNode {
66
74
  private _refLog;
67
75
  private _refLogSize;
68
76
  private _ackTimeoutMs;
77
+ private _disableLocalCache;
69
78
  private _latestRef;
70
79
  private _bootstrapHeartbeatTimer?;
71
80
  private _tornDown;
@@ -126,10 +135,18 @@ export declare class Server extends BaseNode {
126
135
  * Returns the typed sync event names.
127
136
  */
128
137
  get events(): SyncEventNames;
138
+ /**
139
+ * Returns the configured maximum ref log size.
140
+ */
141
+ get refLogSize(): number;
129
142
  /**
130
143
  * Returns the current ref log contents (for diagnostics / testing).
131
144
  */
132
145
  get refLog(): readonly ConnectorPayload[];
146
+ /**
147
+ * Returns whether the local cache is disabled.
148
+ */
149
+ get isLocalCacheDisabled(): boolean;
133
150
  /**
134
151
  * Returns the latest ref tracked by the server (for bootstrap / diagnostics).
135
152
  */
package/dist/server.js CHANGED
@@ -1407,6 +1407,7 @@ class Server extends BaseNode {
1407
1407
  this._localBs = _localBs;
1408
1408
  this._logger = options?.logger ?? noopLogger;
1409
1409
  this._peerInitTimeoutMs = options?.peerInitTimeoutMs ?? 3e4;
1410
+ this._disableLocalCache = options?.disableLocalCache ?? false;
1410
1411
  this._syncConfig = options?.syncConfig;
1411
1412
  this._refLogSize = options?.refLogSize ?? 1e3;
1412
1413
  this._ackTimeoutMs = options?.ackTimeoutMs ?? options?.syncConfig?.ackTimeoutMs ?? 1e4;
@@ -1422,23 +1423,27 @@ class Server extends BaseNode {
1422
1423
  }, evictionMs);
1423
1424
  this._refEvictionTimer.unref();
1424
1425
  }
1425
- const ioMultiIoLocal = {
1426
- io: this._localIo,
1427
- dump: true,
1428
- read: true,
1429
- write: true,
1430
- priority: 1
1431
- };
1432
- this._ios.push(ioMultiIoLocal);
1426
+ if (!this._disableLocalCache) {
1427
+ const ioMultiIoLocal = {
1428
+ io: this._localIo,
1429
+ dump: true,
1430
+ read: true,
1431
+ write: true,
1432
+ priority: 1
1433
+ };
1434
+ this._ios.push(ioMultiIoLocal);
1435
+ }
1433
1436
  this._ioMulti = new IoMulti(this._ios);
1434
1437
  this._ioServer = new IoServer(this._ioMulti);
1435
- const bsMultiBsLocal = {
1436
- bs: this._localBs,
1437
- read: true,
1438
- write: true,
1439
- priority: 1
1440
- };
1441
- this._bss.push(bsMultiBsLocal);
1438
+ if (!this._disableLocalCache) {
1439
+ const bsMultiBsLocal = {
1440
+ bs: this._localBs,
1441
+ read: true,
1442
+ write: true,
1443
+ priority: 1
1444
+ };
1445
+ this._bss.push(bsMultiBsLocal);
1446
+ }
1442
1447
  this._bsMulti = new BsMulti(this._bss);
1443
1448
  this._bsServer = new BsServer(this._bsMulti);
1444
1449
  }
@@ -1471,6 +1476,8 @@ class Server extends BaseNode {
1471
1476
  _refLog = [];
1472
1477
  _refLogSize;
1473
1478
  _ackTimeoutMs;
1479
+ // Local cache toggle
1480
+ _disableLocalCache;
1474
1481
  // Bootstrap state
1475
1482
  _latestRef;
1476
1483
  _bootstrapHeartbeatTimer;
@@ -1660,12 +1667,24 @@ class Server extends BaseNode {
1660
1667
  get events() {
1661
1668
  return this._events;
1662
1669
  }
1670
+ /**
1671
+ * Returns the configured maximum ref log size.
1672
+ */
1673
+ get refLogSize() {
1674
+ return this._refLogSize;
1675
+ }
1663
1676
  /**
1664
1677
  * Returns the current ref log contents (for diagnostics / testing).
1665
1678
  */
1666
1679
  get refLog() {
1667
1680
  return this._refLog;
1668
1681
  }
1682
+ /**
1683
+ * Returns whether the local cache is disabled.
1684
+ */
1685
+ get isLocalCacheDisabled() {
1686
+ return this._disableLocalCache;
1687
+ }
1669
1688
  /**
1670
1689
  * Returns the latest ref tracked by the server (for bootstrap / diagnostics).
1671
1690
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rljson/server",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "description": "Rljson server description",
5
5
  "homepage": "https://github.com/rljson/server",
6
6
  "bugs": "https://github.com/rljson/server/issues",