@actuallab/rpc 12.4.9 → 13.0.4
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/index.cjs +110 -78
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +69 -25
- package/dist/index.d.ts +69 -25
- package/dist/index.js +110 -78
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -23,6 +23,7 @@ declare const RpcSystemCalls: {
|
|
|
23
23
|
readonly item: "$sys.I:2";
|
|
24
24
|
readonly batch: "$sys.B:2";
|
|
25
25
|
readonly end: "$sys.End:2";
|
|
26
|
+
readonly disconnect: "$sys.Disconnect:1";
|
|
26
27
|
};
|
|
27
28
|
/** Wire-format RPC message envelope. */
|
|
28
29
|
interface RpcMessage {
|
|
@@ -788,16 +789,14 @@ declare abstract class RpcPeer {
|
|
|
788
789
|
* entered only after the handshake has succeeded. */
|
|
789
790
|
readonly connectionStateChanged: EventHandlerSet<RpcConnectionState>;
|
|
790
791
|
protected _connection: RpcConnection | undefined;
|
|
791
|
-
/** Mirror of `_connectionState === Connected
|
|
792
|
-
* handshake round-trip completes
|
|
793
|
-
*
|
|
794
|
-
*
|
|
795
|
-
*
|
|
796
|
-
*
|
|
797
|
-
* hub removed it mid-handshake. */
|
|
792
|
+
/** Mirror of `_connectionState === Connected`. True only after the
|
|
793
|
+
* handshake round-trip completes; outbound `call()` checks this to
|
|
794
|
+
* decide between sending now and deferring until the next `Connected`
|
|
795
|
+
* transition. Kept as its own field so it can stay false through the
|
|
796
|
+
* Handshaking phase without exposing the run loop's `_connection`
|
|
797
|
+
* bookkeeping. */
|
|
798
798
|
protected _isConnected: boolean;
|
|
799
799
|
protected _connectionState: RpcConnectionState;
|
|
800
|
-
protected _pendingSends: RpcOutboundCall[];
|
|
801
800
|
private _keepAliveTimer;
|
|
802
801
|
private _keepAliveWatchdog;
|
|
803
802
|
/** Wall-clock time of the last inbound `$sys.KeepAlive`, or 0 if none yet
|
|
@@ -832,8 +831,6 @@ declare abstract class RpcPeer {
|
|
|
832
831
|
* stays in the hub and all client proxies bound to it remain valid. */
|
|
833
832
|
disconnect(): void;
|
|
834
833
|
close(): void;
|
|
835
|
-
/** Send any messages buffered while disconnected. Call after connection + handshake are ready. */
|
|
836
|
-
protected _flushPendingSends(): void;
|
|
837
834
|
/** Send pre-serialized wire data through the current connection. */
|
|
838
835
|
protected _sendWireData(data: string | Uint8Array): void;
|
|
839
836
|
/** Override in subclasses to handle the remote peer's handshake response. */
|
|
@@ -854,11 +851,16 @@ declare abstract class RpcPeer {
|
|
|
854
851
|
* arrives — records the timestamp and re-arms the silence watchdog. */
|
|
855
852
|
notifyKeepAliveReceived(): void;
|
|
856
853
|
}
|
|
857
|
-
/** Connection state for
|
|
854
|
+
/** Connection state for RpcPeer. Mirrors .NET `RpcPeerConnectionState`'s
|
|
855
|
+
* observable phases: the transport is `Connecting` until the WebSocket
|
|
856
|
+
* opens, `Handshaking` from WS-open until the server's handshake reply
|
|
857
|
+
* arrives, and `Connected` once the handshake completes. Outbound calls
|
|
858
|
+
* are gated on `Connected`. */
|
|
858
859
|
declare const enum RpcConnectionState {
|
|
859
860
|
Disconnected = 0,
|
|
860
861
|
Connecting = 1,
|
|
861
|
-
|
|
862
|
+
Handshaking = 2,
|
|
863
|
+
Connected = 3
|
|
862
864
|
}
|
|
863
865
|
/** Client-side RPC peer — initiates WebSocket connection. ref = URL. */
|
|
864
866
|
declare class RpcClientPeer extends RpcPeer {
|
|
@@ -1002,12 +1004,17 @@ declare class RpcSystemCallHandler {
|
|
|
1002
1004
|
* - Server sends End to signal completion (with optional error)
|
|
1003
1005
|
* - Client sends AckEnd to acknowledge completion
|
|
1004
1006
|
*
|
|
1005
|
-
* The
|
|
1006
|
-
*
|
|
1007
|
-
*
|
|
1008
|
-
*
|
|
1009
|
-
*
|
|
1010
|
-
*
|
|
1007
|
+
* The sender uses a single ACK-driven loop:
|
|
1008
|
+
* - On each ACK, drain the source synchronously into the ring buffer up to
|
|
1009
|
+
* `effectiveBufferSize` (this lets us pre-buffer past `ackAdvance`).
|
|
1010
|
+
* - For real-time, optionally compact the unsent suffix to the latest
|
|
1011
|
+
* buffered `canSkipTo` item.
|
|
1012
|
+
* - Send items up to the `ackAdvance` flow-control window.
|
|
1013
|
+
* - Wait for the next ACK.
|
|
1014
|
+
*
|
|
1015
|
+
* Setting `bufferSize > ackAdvance` lets the sender pre-buffer items past
|
|
1016
|
+
* the in-flight window so a fresh ACK can be served from RAM instead of
|
|
1017
|
+
* waiting on the source.
|
|
1011
1018
|
*
|
|
1012
1019
|
* Direct port of .NET `RpcSharedStream<T>` at
|
|
1013
1020
|
* src/ActualLab.Rpc/Infrastructure/RpcSharedStream.cs.
|
|
@@ -1021,6 +1028,18 @@ declare class RpcStreamSender<T> implements IRpcObject {
|
|
|
1021
1028
|
readonly canSkipTo: (item: T) => boolean;
|
|
1022
1029
|
readonly peer: RpcPeer;
|
|
1023
1030
|
readonly ackPeriod: number;
|
|
1031
|
+
/**
|
|
1032
|
+
* Wire-level flow-control window: the maximum index the sender may
|
|
1033
|
+
* advance past the most recently acknowledged index. Mirrors .NET
|
|
1034
|
+
* `RpcStream.AckAdvance`.
|
|
1035
|
+
*/
|
|
1036
|
+
readonly ackAdvance: number;
|
|
1037
|
+
/**
|
|
1038
|
+
* Effective local ring buffer capacity used by the pump. Set larger
|
|
1039
|
+
* than `ackAdvance` to pre-buffer items beyond the in-flight window;
|
|
1040
|
+
* values below `ackAdvance` are clamped up (with a warning) at
|
|
1041
|
+
* construction time. Not transmitted on the wire.
|
|
1042
|
+
*/
|
|
1024
1043
|
readonly bufferSize: number;
|
|
1025
1044
|
/**
|
|
1026
1045
|
* If true, the source was produced by a factory `(abortSignal) => AsyncIterable<T>`
|
|
@@ -1047,12 +1066,19 @@ declare class RpcStreamSender<T> implements IRpcObject {
|
|
|
1047
1066
|
* watchdog so it can distinguish "stuck" (no ACK > N s) from
|
|
1048
1067
|
* "throttled" (ACKs flowing). */
|
|
1049
1068
|
onAckProcessed?: () => void;
|
|
1069
|
+
/** Fires after each item is pushed onto the local ring buffer. The
|
|
1070
|
+
* argument is the buffer count *after* the push. Together with
|
|
1071
|
+
* `onAckProcessed` (which is the only place items leave the buffer),
|
|
1072
|
+
* this gives controllers a complete picture of buffer utilization.
|
|
1073
|
+
* When `bufferedCount === bufferSize`, the source pull is paused
|
|
1074
|
+
* until the next ACK frees space. Listener errors are swallowed. */
|
|
1075
|
+
onBuffered?: (bufferedCount: number) => void;
|
|
1050
1076
|
get nextIndex(): number;
|
|
1051
1077
|
get lastAckIndex(): number;
|
|
1052
1078
|
get skipCount(): number;
|
|
1053
1079
|
private _acks;
|
|
1054
1080
|
private _whenAckReady;
|
|
1055
|
-
constructor(peer: RpcPeer, ackPeriod?: number,
|
|
1081
|
+
constructor(peer: RpcPeer, ackPeriod?: number, ackAdvance?: number, allowReconnect?: boolean, isRealTime?: boolean, canSkipTo?: (item: T) => boolean, sourceUsesAbortSignal?: boolean, bufferSize?: number);
|
|
1056
1082
|
/** AbortSignal that is aborted when the sender is disconnected. */
|
|
1057
1083
|
get abortSignal(): AbortSignal;
|
|
1058
1084
|
/** Returns the stream reference string for the $sys.Ok response. */
|
|
@@ -1089,8 +1115,10 @@ declare class RpcStreamSender<T> implements IRpcObject {
|
|
|
1089
1115
|
writeFrom(source: AsyncIterable<T>): Promise<void>;
|
|
1090
1116
|
/**
|
|
1091
1117
|
* ACK-driven pump. Non-real-time streams apply normal backpressure at
|
|
1092
|
-
* `
|
|
1118
|
+
* `ackAdvance`; real-time streams may compact the already-buffered unsent
|
|
1093
1119
|
* suffix to the latest buffered `canSkipTo` item after the consumer ACKs.
|
|
1120
|
+
* With `bufferSize > ackAdvance` the local ring buffer holds more than the
|
|
1121
|
+
* in-flight window — real-time mode uses the extra space to pre-buffer.
|
|
1094
1122
|
*/
|
|
1095
1123
|
private _run;
|
|
1096
1124
|
/** Drain all queued ACKs, returning the most recent one (or null if none). */
|
|
@@ -1107,7 +1135,7 @@ interface RpcStreamRef {
|
|
|
1107
1135
|
readonly hostId: string;
|
|
1108
1136
|
readonly localId: number;
|
|
1109
1137
|
readonly ackPeriod: number;
|
|
1110
|
-
readonly
|
|
1138
|
+
readonly ackAdvance: number;
|
|
1111
1139
|
readonly allowReconnect: boolean;
|
|
1112
1140
|
readonly isRealTime: boolean;
|
|
1113
1141
|
}
|
|
@@ -1121,13 +1149,24 @@ type RpcStreamSource<T> = AsyncIterable<T> | ((abortSignal: AbortSignal) => Asyn
|
|
|
1121
1149
|
/** Configuration options for creating a local (origin-side) RpcStream. */
|
|
1122
1150
|
interface RpcStreamOptions<T> {
|
|
1123
1151
|
ackPeriod?: number;
|
|
1152
|
+
/**
|
|
1153
|
+
* Wire-level flow-control window: the maximum index the sender may advance
|
|
1154
|
+
* past the last acknowledged index. Mirrors .NET `RpcStream.AckAdvance`.
|
|
1155
|
+
*/
|
|
1156
|
+
ackAdvance?: number;
|
|
1157
|
+
/**
|
|
1158
|
+
* Local-only sender ring buffer capacity. When undefined (or smaller than
|
|
1159
|
+
* `ackAdvance`), `ackAdvance` is used as the buffer size.
|
|
1160
|
+
* Set this larger than `ackAdvance` to let the sender pre-buffer items
|
|
1161
|
+
* beyond the in-flight window. Not transmitted on the wire.
|
|
1162
|
+
*/
|
|
1124
1163
|
bufferSize?: number;
|
|
1125
1164
|
allowReconnect?: boolean;
|
|
1126
1165
|
isRealTime?: boolean;
|
|
1127
1166
|
canSkipTo?: (item: T) => boolean;
|
|
1128
1167
|
}
|
|
1129
1168
|
/**
|
|
1130
|
-
* Parses a stream reference string of the form "{hostId},{localId},{ackPeriod},{
|
|
1169
|
+
* Parses a stream reference string of the form "{hostId},{localId},{ackPeriod},{ackAdvance}".
|
|
1131
1170
|
* Returns null if the value is not a valid stream reference.
|
|
1132
1171
|
*/
|
|
1133
1172
|
declare function parseStreamRef(value: unknown): RpcStreamRef | null;
|
|
@@ -1159,7 +1198,12 @@ declare class RpcStream<T> implements AsyncIterable<T>, IRpcObject {
|
|
|
1159
1198
|
readonly isRealTime: boolean;
|
|
1160
1199
|
readonly canSkipTo: (item: T) => boolean;
|
|
1161
1200
|
readonly ackPeriod: number;
|
|
1162
|
-
readonly
|
|
1201
|
+
readonly ackAdvance: number;
|
|
1202
|
+
/**
|
|
1203
|
+
* Local-only ring buffer capacity hint for the sender. Undefined means
|
|
1204
|
+
* "use ackAdvance as the buffer size". Not part of the wire ref.
|
|
1205
|
+
*/
|
|
1206
|
+
readonly bufferSize?: number;
|
|
1163
1207
|
readonly localSource?: RpcStreamSource<T>;
|
|
1164
1208
|
readonly peer: RpcPeer;
|
|
1165
1209
|
private _sender?;
|
|
@@ -1193,7 +1237,7 @@ declare class RpcStream<T> implements AsyncIterable<T>, IRpcObject {
|
|
|
1193
1237
|
* stream reference.
|
|
1194
1238
|
*
|
|
1195
1239
|
* For binary peers the ref is a MessagePack-compatible object
|
|
1196
|
-
* (`{ SerializedId, AckPeriod,
|
|
1240
|
+
* (`{ SerializedId, AckPeriod, AckAdvance, AllowReconnect }`);
|
|
1197
1241
|
* for text peers it is a comma-separated string.
|
|
1198
1242
|
*
|
|
1199
1243
|
* Can only be called once per stream.
|
|
@@ -1219,7 +1263,7 @@ declare class RpcStream<T> implements AsyncIterable<T>, IRpcObject {
|
|
|
1219
1263
|
* Recursively walks a deserialized value and replaces any stream ref strings
|
|
1220
1264
|
* with live RpcStream<unknown> instances registered on the given peer.
|
|
1221
1265
|
* This handles nested stream refs inside complex return types (e.g. Table<T>
|
|
1222
|
-
* containing RpcStream<Row<T>> fields serialized as "{hostId},{localId},{ackPeriod},{
|
|
1266
|
+
* containing RpcStream<Row<T>> fields serialized as "{hostId},{localId},{ackPeriod},{ackAdvance}").
|
|
1223
1267
|
*/
|
|
1224
1268
|
declare function resolveStreamRefs(value: unknown, peer: RpcPeer): unknown;
|
|
1225
1269
|
|
package/dist/index.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ declare const RpcSystemCalls: {
|
|
|
23
23
|
readonly item: "$sys.I:2";
|
|
24
24
|
readonly batch: "$sys.B:2";
|
|
25
25
|
readonly end: "$sys.End:2";
|
|
26
|
+
readonly disconnect: "$sys.Disconnect:1";
|
|
26
27
|
};
|
|
27
28
|
/** Wire-format RPC message envelope. */
|
|
28
29
|
interface RpcMessage {
|
|
@@ -788,16 +789,14 @@ declare abstract class RpcPeer {
|
|
|
788
789
|
* entered only after the handshake has succeeded. */
|
|
789
790
|
readonly connectionStateChanged: EventHandlerSet<RpcConnectionState>;
|
|
790
791
|
protected _connection: RpcConnection | undefined;
|
|
791
|
-
/** Mirror of `_connectionState === Connected
|
|
792
|
-
* handshake round-trip completes
|
|
793
|
-
*
|
|
794
|
-
*
|
|
795
|
-
*
|
|
796
|
-
*
|
|
797
|
-
* hub removed it mid-handshake. */
|
|
792
|
+
/** Mirror of `_connectionState === Connected`. True only after the
|
|
793
|
+
* handshake round-trip completes; outbound `call()` checks this to
|
|
794
|
+
* decide between sending now and deferring until the next `Connected`
|
|
795
|
+
* transition. Kept as its own field so it can stay false through the
|
|
796
|
+
* Handshaking phase without exposing the run loop's `_connection`
|
|
797
|
+
* bookkeeping. */
|
|
798
798
|
protected _isConnected: boolean;
|
|
799
799
|
protected _connectionState: RpcConnectionState;
|
|
800
|
-
protected _pendingSends: RpcOutboundCall[];
|
|
801
800
|
private _keepAliveTimer;
|
|
802
801
|
private _keepAliveWatchdog;
|
|
803
802
|
/** Wall-clock time of the last inbound `$sys.KeepAlive`, or 0 if none yet
|
|
@@ -832,8 +831,6 @@ declare abstract class RpcPeer {
|
|
|
832
831
|
* stays in the hub and all client proxies bound to it remain valid. */
|
|
833
832
|
disconnect(): void;
|
|
834
833
|
close(): void;
|
|
835
|
-
/** Send any messages buffered while disconnected. Call after connection + handshake are ready. */
|
|
836
|
-
protected _flushPendingSends(): void;
|
|
837
834
|
/** Send pre-serialized wire data through the current connection. */
|
|
838
835
|
protected _sendWireData(data: string | Uint8Array): void;
|
|
839
836
|
/** Override in subclasses to handle the remote peer's handshake response. */
|
|
@@ -854,11 +851,16 @@ declare abstract class RpcPeer {
|
|
|
854
851
|
* arrives — records the timestamp and re-arms the silence watchdog. */
|
|
855
852
|
notifyKeepAliveReceived(): void;
|
|
856
853
|
}
|
|
857
|
-
/** Connection state for
|
|
854
|
+
/** Connection state for RpcPeer. Mirrors .NET `RpcPeerConnectionState`'s
|
|
855
|
+
* observable phases: the transport is `Connecting` until the WebSocket
|
|
856
|
+
* opens, `Handshaking` from WS-open until the server's handshake reply
|
|
857
|
+
* arrives, and `Connected` once the handshake completes. Outbound calls
|
|
858
|
+
* are gated on `Connected`. */
|
|
858
859
|
declare const enum RpcConnectionState {
|
|
859
860
|
Disconnected = 0,
|
|
860
861
|
Connecting = 1,
|
|
861
|
-
|
|
862
|
+
Handshaking = 2,
|
|
863
|
+
Connected = 3
|
|
862
864
|
}
|
|
863
865
|
/** Client-side RPC peer — initiates WebSocket connection. ref = URL. */
|
|
864
866
|
declare class RpcClientPeer extends RpcPeer {
|
|
@@ -1002,12 +1004,17 @@ declare class RpcSystemCallHandler {
|
|
|
1002
1004
|
* - Server sends End to signal completion (with optional error)
|
|
1003
1005
|
* - Client sends AckEnd to acknowledge completion
|
|
1004
1006
|
*
|
|
1005
|
-
* The
|
|
1006
|
-
*
|
|
1007
|
-
*
|
|
1008
|
-
*
|
|
1009
|
-
*
|
|
1010
|
-
*
|
|
1007
|
+
* The sender uses a single ACK-driven loop:
|
|
1008
|
+
* - On each ACK, drain the source synchronously into the ring buffer up to
|
|
1009
|
+
* `effectiveBufferSize` (this lets us pre-buffer past `ackAdvance`).
|
|
1010
|
+
* - For real-time, optionally compact the unsent suffix to the latest
|
|
1011
|
+
* buffered `canSkipTo` item.
|
|
1012
|
+
* - Send items up to the `ackAdvance` flow-control window.
|
|
1013
|
+
* - Wait for the next ACK.
|
|
1014
|
+
*
|
|
1015
|
+
* Setting `bufferSize > ackAdvance` lets the sender pre-buffer items past
|
|
1016
|
+
* the in-flight window so a fresh ACK can be served from RAM instead of
|
|
1017
|
+
* waiting on the source.
|
|
1011
1018
|
*
|
|
1012
1019
|
* Direct port of .NET `RpcSharedStream<T>` at
|
|
1013
1020
|
* src/ActualLab.Rpc/Infrastructure/RpcSharedStream.cs.
|
|
@@ -1021,6 +1028,18 @@ declare class RpcStreamSender<T> implements IRpcObject {
|
|
|
1021
1028
|
readonly canSkipTo: (item: T) => boolean;
|
|
1022
1029
|
readonly peer: RpcPeer;
|
|
1023
1030
|
readonly ackPeriod: number;
|
|
1031
|
+
/**
|
|
1032
|
+
* Wire-level flow-control window: the maximum index the sender may
|
|
1033
|
+
* advance past the most recently acknowledged index. Mirrors .NET
|
|
1034
|
+
* `RpcStream.AckAdvance`.
|
|
1035
|
+
*/
|
|
1036
|
+
readonly ackAdvance: number;
|
|
1037
|
+
/**
|
|
1038
|
+
* Effective local ring buffer capacity used by the pump. Set larger
|
|
1039
|
+
* than `ackAdvance` to pre-buffer items beyond the in-flight window;
|
|
1040
|
+
* values below `ackAdvance` are clamped up (with a warning) at
|
|
1041
|
+
* construction time. Not transmitted on the wire.
|
|
1042
|
+
*/
|
|
1024
1043
|
readonly bufferSize: number;
|
|
1025
1044
|
/**
|
|
1026
1045
|
* If true, the source was produced by a factory `(abortSignal) => AsyncIterable<T>`
|
|
@@ -1047,12 +1066,19 @@ declare class RpcStreamSender<T> implements IRpcObject {
|
|
|
1047
1066
|
* watchdog so it can distinguish "stuck" (no ACK > N s) from
|
|
1048
1067
|
* "throttled" (ACKs flowing). */
|
|
1049
1068
|
onAckProcessed?: () => void;
|
|
1069
|
+
/** Fires after each item is pushed onto the local ring buffer. The
|
|
1070
|
+
* argument is the buffer count *after* the push. Together with
|
|
1071
|
+
* `onAckProcessed` (which is the only place items leave the buffer),
|
|
1072
|
+
* this gives controllers a complete picture of buffer utilization.
|
|
1073
|
+
* When `bufferedCount === bufferSize`, the source pull is paused
|
|
1074
|
+
* until the next ACK frees space. Listener errors are swallowed. */
|
|
1075
|
+
onBuffered?: (bufferedCount: number) => void;
|
|
1050
1076
|
get nextIndex(): number;
|
|
1051
1077
|
get lastAckIndex(): number;
|
|
1052
1078
|
get skipCount(): number;
|
|
1053
1079
|
private _acks;
|
|
1054
1080
|
private _whenAckReady;
|
|
1055
|
-
constructor(peer: RpcPeer, ackPeriod?: number,
|
|
1081
|
+
constructor(peer: RpcPeer, ackPeriod?: number, ackAdvance?: number, allowReconnect?: boolean, isRealTime?: boolean, canSkipTo?: (item: T) => boolean, sourceUsesAbortSignal?: boolean, bufferSize?: number);
|
|
1056
1082
|
/** AbortSignal that is aborted when the sender is disconnected. */
|
|
1057
1083
|
get abortSignal(): AbortSignal;
|
|
1058
1084
|
/** Returns the stream reference string for the $sys.Ok response. */
|
|
@@ -1089,8 +1115,10 @@ declare class RpcStreamSender<T> implements IRpcObject {
|
|
|
1089
1115
|
writeFrom(source: AsyncIterable<T>): Promise<void>;
|
|
1090
1116
|
/**
|
|
1091
1117
|
* ACK-driven pump. Non-real-time streams apply normal backpressure at
|
|
1092
|
-
* `
|
|
1118
|
+
* `ackAdvance`; real-time streams may compact the already-buffered unsent
|
|
1093
1119
|
* suffix to the latest buffered `canSkipTo` item after the consumer ACKs.
|
|
1120
|
+
* With `bufferSize > ackAdvance` the local ring buffer holds more than the
|
|
1121
|
+
* in-flight window — real-time mode uses the extra space to pre-buffer.
|
|
1094
1122
|
*/
|
|
1095
1123
|
private _run;
|
|
1096
1124
|
/** Drain all queued ACKs, returning the most recent one (or null if none). */
|
|
@@ -1107,7 +1135,7 @@ interface RpcStreamRef {
|
|
|
1107
1135
|
readonly hostId: string;
|
|
1108
1136
|
readonly localId: number;
|
|
1109
1137
|
readonly ackPeriod: number;
|
|
1110
|
-
readonly
|
|
1138
|
+
readonly ackAdvance: number;
|
|
1111
1139
|
readonly allowReconnect: boolean;
|
|
1112
1140
|
readonly isRealTime: boolean;
|
|
1113
1141
|
}
|
|
@@ -1121,13 +1149,24 @@ type RpcStreamSource<T> = AsyncIterable<T> | ((abortSignal: AbortSignal) => Asyn
|
|
|
1121
1149
|
/** Configuration options for creating a local (origin-side) RpcStream. */
|
|
1122
1150
|
interface RpcStreamOptions<T> {
|
|
1123
1151
|
ackPeriod?: number;
|
|
1152
|
+
/**
|
|
1153
|
+
* Wire-level flow-control window: the maximum index the sender may advance
|
|
1154
|
+
* past the last acknowledged index. Mirrors .NET `RpcStream.AckAdvance`.
|
|
1155
|
+
*/
|
|
1156
|
+
ackAdvance?: number;
|
|
1157
|
+
/**
|
|
1158
|
+
* Local-only sender ring buffer capacity. When undefined (or smaller than
|
|
1159
|
+
* `ackAdvance`), `ackAdvance` is used as the buffer size.
|
|
1160
|
+
* Set this larger than `ackAdvance` to let the sender pre-buffer items
|
|
1161
|
+
* beyond the in-flight window. Not transmitted on the wire.
|
|
1162
|
+
*/
|
|
1124
1163
|
bufferSize?: number;
|
|
1125
1164
|
allowReconnect?: boolean;
|
|
1126
1165
|
isRealTime?: boolean;
|
|
1127
1166
|
canSkipTo?: (item: T) => boolean;
|
|
1128
1167
|
}
|
|
1129
1168
|
/**
|
|
1130
|
-
* Parses a stream reference string of the form "{hostId},{localId},{ackPeriod},{
|
|
1169
|
+
* Parses a stream reference string of the form "{hostId},{localId},{ackPeriod},{ackAdvance}".
|
|
1131
1170
|
* Returns null if the value is not a valid stream reference.
|
|
1132
1171
|
*/
|
|
1133
1172
|
declare function parseStreamRef(value: unknown): RpcStreamRef | null;
|
|
@@ -1159,7 +1198,12 @@ declare class RpcStream<T> implements AsyncIterable<T>, IRpcObject {
|
|
|
1159
1198
|
readonly isRealTime: boolean;
|
|
1160
1199
|
readonly canSkipTo: (item: T) => boolean;
|
|
1161
1200
|
readonly ackPeriod: number;
|
|
1162
|
-
readonly
|
|
1201
|
+
readonly ackAdvance: number;
|
|
1202
|
+
/**
|
|
1203
|
+
* Local-only ring buffer capacity hint for the sender. Undefined means
|
|
1204
|
+
* "use ackAdvance as the buffer size". Not part of the wire ref.
|
|
1205
|
+
*/
|
|
1206
|
+
readonly bufferSize?: number;
|
|
1163
1207
|
readonly localSource?: RpcStreamSource<T>;
|
|
1164
1208
|
readonly peer: RpcPeer;
|
|
1165
1209
|
private _sender?;
|
|
@@ -1193,7 +1237,7 @@ declare class RpcStream<T> implements AsyncIterable<T>, IRpcObject {
|
|
|
1193
1237
|
* stream reference.
|
|
1194
1238
|
*
|
|
1195
1239
|
* For binary peers the ref is a MessagePack-compatible object
|
|
1196
|
-
* (`{ SerializedId, AckPeriod,
|
|
1240
|
+
* (`{ SerializedId, AckPeriod, AckAdvance, AllowReconnect }`);
|
|
1197
1241
|
* for text peers it is a comma-separated string.
|
|
1198
1242
|
*
|
|
1199
1243
|
* Can only be called once per stream.
|
|
@@ -1219,7 +1263,7 @@ declare class RpcStream<T> implements AsyncIterable<T>, IRpcObject {
|
|
|
1219
1263
|
* Recursively walks a deserialized value and replaces any stream ref strings
|
|
1220
1264
|
* with live RpcStream<unknown> instances registered on the given peer.
|
|
1221
1265
|
* This handles nested stream refs inside complex return types (e.g. Table<T>
|
|
1222
|
-
* containing RpcStream<Row<T>> fields serialized as "{hostId},{localId},{ackPeriod},{
|
|
1266
|
+
* containing RpcStream<Row<T>> fields serialized as "{hostId},{localId},{ackPeriod},{ackAdvance}").
|
|
1223
1267
|
*/
|
|
1224
1268
|
declare function resolveStreamRefs(value: unknown, peer: RpcPeer): unknown;
|
|
1225
1269
|
|