@mark1russell7/service 0.8.4 → 0.8.6
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/build/{backoff-B-jGWVDm.d.ts → backoff-QTRGfkEK.d.ts} +1 -4
- package/build/backoff.d.ts +1 -1
- package/build/backoff.js +1 -2
- package/build/{builder-DQj3NNNc.d.ts → builder-zO48Vgoj.d.ts} +4 -11
- package/build/{call-context-gR8FhbF_.d.ts → call-context-DDhcVvn5.d.ts} +1 -4
- package/build/channel.d.ts +1 -4
- package/build/channel.js +1 -2
- package/build/{core-Dt0HEVMq.d.ts → core-BSzt4RI2.d.ts} +5 -10
- package/build/{dial-CSQOl-yj.d.ts → dial-ChwIcvd4.d.ts} +2 -5
- package/build/grpc.d.ts +5 -16
- package/build/grpc.js +7 -12
- package/build/grpc.js.map +1 -1
- package/build/heartbeat.d.ts +1 -4
- package/build/heartbeat.js +1 -2
- package/build/host.d.ts +10 -25
- package/build/host.js +21 -33
- package/build/host.js.map +1 -1
- package/build/http-client.d.ts +5 -18
- package/build/http-client.js +7 -13
- package/build/http-client.js.map +1 -1
- package/build/http.d.ts +4 -11
- package/build/http.js +6 -10
- package/build/http.js.map +1 -1
- package/build/index.d.ts +11 -24
- package/build/index.js +26 -43
- package/build/index.js.map +1 -1
- package/build/{knobs-D2ClI68I.js → knobs-BJcz6m01.js} +3 -5
- package/build/{knobs-D2ClI68I.js.map → knobs-BJcz6m01.js.map} +1 -1
- package/build/{lifecycle-Br0jAjTk.d.ts → lifecycle-D0J-zwZF.d.ts} +2 -15
- package/build/{limiter-BTgM4aXZ.js → limiter-BwGxEWpP.js} +4 -6
- package/build/{limiter-BTgM4aXZ.js.map → limiter-BwGxEWpP.js.map} +1 -1
- package/build/{limiter-D1aluA0V.d.ts → limiter-Djw39d_S.d.ts} +3 -6
- package/build/limiter.d.ts +3 -3
- package/build/limiter.js +2 -2
- package/build/{logger-BN2BfPgU.d.ts → logger-B6drv9w0.d.ts} +2 -17
- package/build/{machine-p4lENJ86.js → machine-mIW1qgEE.js} +7 -11
- package/build/{machine-p4lENJ86.js.map → machine-mIW1qgEE.js.map} +1 -1
- package/build/mongodb.d.ts +4 -15
- package/build/mongodb.js +6 -11
- package/build/mongodb.js.map +1 -1
- package/build/{operation-DL5RxFds.js → operation-DF73RZOI.js} +2 -3
- package/build/{operation-DL5RxFds.js.map → operation-DF73RZOI.js.map} +1 -1
- package/build/otel.d.ts +3 -6
- package/build/otel.js +1 -2
- package/build/pg.d.ts +3 -14
- package/build/pg.js +6 -11
- package/build/pg.js.map +1 -1
- package/build/{policy-G-Y3Meku.js → policy-B23MY52l.js} +2 -3
- package/build/{policy-G-Y3Meku.js.map → policy-B23MY52l.js.map} +1 -1
- package/build/{policy-CwYR95Sz.d.ts → policy-CBcK2XGg.d.ts} +1 -4
- package/build/{ports-CSr7qWrA.d.ts → ports-DZoipkSD.d.ts} +2 -5
- package/build/{process-DG_im2zc.js → process-Oe0Abbsm.js} +2 -3
- package/build/{process-DG_im2zc.js.map → process-Oe0Abbsm.js.map} +1 -1
- package/build/{queue-fIkOXKVG.d.ts → queue-DXdw1vLO.d.ts} +3 -8
- package/build/rabbitmq.d.ts +5 -16
- package/build/rabbitmq.js +6 -11
- package/build/rabbitmq.js.map +1 -1
- package/build/redis.d.ts +4 -17
- package/build/redis.js +10 -16
- package/build/redis.js.map +1 -1
- package/build/{requests-BIq9Tr4P.js → requests-DD2ALv0_.js} +6 -9
- package/build/{requests-BIq9Tr4P.js.map → requests-DD2ALv0_.js.map} +1 -1
- package/build/{retrier-Nt6r4r6R.js → retrier-BObZq10-.js} +3 -4
- package/build/{retrier-Nt6r4r6R.js.map → retrier-BObZq10-.js.map} +1 -1
- package/build/{rules-BBRopO1e.d.ts → rules-HyFCBStQ.d.ts} +1 -6
- package/build/rules.d.ts +1 -1
- package/build/rules.js +1 -2
- package/build/{store-1CsNoJ8O.d.ts → store-DFwFKrsB.d.ts} +2 -5
- package/build/testing.d.ts +5 -16
- package/build/testing.js +9 -15
- package/build/testing.js.map +1 -1
- package/build/{timing-DGRi3XCI.js → timing-DZl36uXs.js} +2 -3
- package/build/{timing-DGRi3XCI.js.map → timing-DZl36uXs.js.map} +1 -1
- package/build/websocket.d.ts +4 -15
- package/build/websocket.js +7 -12
- package/build/websocket.js.map +1 -1
- package/package.json +11 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retrier-
|
|
1
|
+
{"version":3,"file":"retrier-BObZq10-.js","names":[],"sources":["../src/retrier.ts"],"sourcesContent":["import type { Backoff } from \"./backoff.ts\";\nimport { backoffDelay, backoffProblems } from \"./backoff.ts\";\nimport type { Cancel, Clock } from \"./clock.ts\";\nimport { realClock } from \"./clock.ts\";\n\n/** These options make a retrier: a backoff policy, the clock of its timers, and the signal that cancels it. */\nexport interface RetrierOptions extends Backoff {\n /** This clock starts each retry. The default is the real clock. A test gives a fake clock. */\n readonly clock?: Clock | undefined;\n /** This function gives a number in [0, 1) for the jitter of each delay. The default is `Math.random`. */\n readonly random?: (() => number) | undefined;\n /**\n * This signal cancels the retrier when it aborts, for example the `signal` of the lifecycle, which\n * aborts in the drain. After the abort, `schedule` starts nothing.\n */\n readonly signal?: AbortSignal | undefined;\n}\n\n/** A retrier starts a function again after the backoff of each try, on its clock. */\nexport interface Retrier {\n /** This count is the number of tries since the last reset. */\n readonly attempts: number;\n /** This flag tells if a retry waits for its timer. */\n readonly pending: boolean;\n /**\n * This method counts one more try, and starts `run` after the backoff delay of that try. It gives\n * the delay in milliseconds. A retry that waits stops, thus one retry at most waits. After the\n * abort of the signal, it starts nothing and gives null. The function catches its own errors.\n */\n schedule(run: () => void): number | null;\n /** This method sets the count of tries to 0, for example after a start that succeeded. A retry that waits stays. */\n reset(): void;\n /** This method stops the retry that waits. The count of tries stays. */\n cancel(): void;\n}\n\n/** This function makes a retrier with no check of its policy. A client of the package uses it with its own knobs. */\nexport const retrierOn = (clock: Clock, backoff: Backoff, random: () => number, signal?: AbortSignal): Retrier => {\n let tries = 0;\n let timer: Cancel | null = null;\n const cancel = (): void => {\n timer?.();\n timer = null;\n };\n signal?.addEventListener(\"abort\", cancel, { once: true });\n return {\n get attempts() {\n return tries;\n },\n get pending() {\n return timer !== null;\n },\n schedule(run) {\n if (signal?.aborted === true) return null;\n tries += 1;\n const delay = Math.round(backoffDelay(backoff, tries, random));\n timer?.();\n timer = clock.after(delay, () => {\n timer = null;\n run();\n });\n return delay;\n },\n cancel,\n reset() {\n tries = 0;\n },\n };\n};\n\n/**\n * This function makes a retrier over `backoffDelay`. The first try waits `base`, and each try after\n * it waits `factor` times more, to the `cap`, with the jitter of the policy. It refuses a policy\n * with a problem of `backoffProblems`.\n */\nexport const retrier = (options: RetrierOptions): Retrier => {\n const { clock = realClock, random = Math.random, signal, ...backoff } = options;\n const problems = backoffProblems(backoff);\n if (problems.length > 0) throw new Error(`the retrier has a bad backoff: ${problems.join(\"; \")}`);\n return retrierOn(clock, backoff, random, signal);\n};\n\n/** These options make one call with retries: the most tries, the errors to retry, and the policy of a retrier. */\nexport interface RetryOptions extends RetrierOptions {\n /** This number is the most tries of the call, the first try included. It is 1 or more. */\n readonly tries: number;\n /** This function tells if a try starts again after this error. The default retries each error. */\n readonly retryable?: ((error: unknown) => boolean) | undefined;\n /**\n * This function gives the delay in milliseconds before the next try, in place of the backoff. An example\n * is the `Retry-After` header of an HTTP 429. Null, undefined, NaN, an infinite or a negative number keeps\n * the backoff delay. The retry puts no cap on this delay, so the caller caps it, for example at 60 s.\n */\n readonly delayOf?: ((error: unknown, attempt: number) => number | null | undefined) | undefined;\n}\n\n/**\n * This function gives the wait of a `Retry-After` header (RFC 9110) in milliseconds: a count of seconds,\n * or an HTTP date after `now`. It gives null for a header with no valid value. A date before `now` gives 0.\n */\nexport const retryAfterDelay = (header: string | null | undefined, now: number): number | null => {\n const text = header?.trim() ?? \"\";\n if (text === \"\") return null;\n if (/^\\d+$/.test(text)) return Number(text) * 1000;\n // An HTTP date has the name of its day and month. Without a letter, Date.parse reads \"-3\" as a year.\n const at = /[A-Za-z]/.test(text) ? Date.parse(text) : Number.NaN;\n return Number.isNaN(at) ? null : Math.max(0, at - now);\n};\n\n/**\n * This function starts `run`, and starts it again after an error, to the count of `tries`. The delay\n * before try n + 1 is `delayOf(error, n)`, else the `backoffDelay` of try n, on the clock. The call gives\n * the value of the first try that succeeds. After the last try, an error that is not retryable, or the\n * abort of the signal, it throws the last error. It refuses a policy with a problem of `backoffProblems`.\n */\nexport const retry = async <T>(run: (attempt: number) => Promise<T>, options: RetryOptions): Promise<T> => {\n const { tries, retryable = () => true, delayOf, clock = realClock, random = Math.random, signal, ...backoff } = options;\n if (!Number.isInteger(tries) || tries < 1) throw new Error(`retry needs a whole number of tries of 1 or more, not ${tries}`);\n const problems = backoffProblems(backoff);\n if (problems.length > 0) throw new Error(`the retry has a bad backoff: ${problems.join(\"; \")}`);\n for (let attempt = 1; ; attempt += 1) {\n try {\n return await run(attempt);\n } catch (error) {\n if (attempt >= tries || signal?.aborted === true || !retryable(error)) throw error;\n const own = delayOf?.(error, attempt);\n // A bad delay (NaN, an infinite or a negative number) gets the backoff, so that it cannot start the tries at once.\n const valid = typeof own === \"number\" && Number.isFinite(own) && own >= 0;\n const delay = Math.round(valid ? own : backoffDelay(backoff, attempt, random));\n await new Promise<void>((resume, stop) => {\n const abort = (): void => {\n cancel();\n stop(error);\n };\n const cancel = clock.after(delay, () => {\n signal?.removeEventListener(\"abort\", abort);\n resume();\n });\n signal?.addEventListener(\"abort\", abort, { once: true });\n });\n }\n }\n};\n"],"mappings":";;;;AAqCA,MAAa,aAAa,OAAc,SAAkB,QAAsB,WAAkC;CAChH,IAAI,QAAQ;CACZ,IAAI,QAAuB;CAC3B,MAAM,eAAqB;EACzB,QAAQ;EACR,QAAQ;CACV;CACA,QAAQ,iBAAiB,SAAS,QAAQ,EAAE,MAAM,KAAK,CAAC;CACxD,OAAO;EACL,IAAI,WAAW;GACb,OAAO;EACT;EACA,IAAI,UAAU;GACZ,OAAO,UAAU;EACnB;EACA,SAAS,KAAK;GACZ,IAAI,QAAQ,YAAY,MAAM,OAAO;GACrC,SAAS;GACT,MAAM,QAAQ,KAAK,MAAM,aAAa,SAAS,OAAO,MAAM,CAAC;GAC7D,QAAQ;GACR,QAAQ,MAAM,MAAM,aAAa;IAC/B,QAAQ;IACR,IAAI;GACN,CAAC;GACD,OAAO;EACT;EACA;EACA,QAAQ;GACN,QAAQ;EACV;CACF;AACF;;;;;;AAOA,MAAa,WAAW,YAAqC;CAC3D,MAAM,EAAE,QAAQ,WAAW,SAAS,KAAK,QAAQ,QAAQ,GAAG,YAAY;CACxE,MAAM,WAAW,gBAAgB,OAAO;CACxC,IAAI,SAAS,SAAS,GAAG,MAAM,IAAI,MAAM,kCAAkC,SAAS,KAAK,IAAI,GAAG;CAChG,OAAO,UAAU,OAAO,SAAS,QAAQ,MAAM;AACjD;;;;;AAoBA,MAAa,mBAAmB,QAAmC,QAA+B;CAChG,MAAM,OAAO,QAAQ,KAAK,KAAK;CAC/B,IAAI,SAAS,IAAI,OAAO;CACxB,IAAI,QAAQ,KAAK,IAAI,GAAG,OAAO,OAAO,IAAI,IAAI;CAE9C,MAAM,KAAK,WAAW,KAAK,IAAI,IAAI,KAAK,MAAM,IAAI,IAAI;CACtD,OAAO,OAAO,MAAM,EAAE,IAAI,OAAO,KAAK,IAAI,GAAG,KAAK,GAAG;AACvD;;;;;;;AAQA,MAAa,QAAQ,OAAU,KAAsC,YAAsC;CACzG,MAAM,EAAE,OAAO,kBAAkB,MAAM,SAAS,QAAQ,WAAW,SAAS,KAAK,QAAQ,QAAQ,GAAG,YAAY;CAChH,IAAI,CAAC,OAAO,UAAU,KAAK,KAAK,QAAQ,GAAG,MAAM,IAAI,MAAM,yDAAyD,OAAO;CAC3H,MAAM,WAAW,gBAAgB,OAAO;CACxC,IAAI,SAAS,SAAS,GAAG,MAAM,IAAI,MAAM,gCAAgC,SAAS,KAAK,IAAI,GAAG;CAC9F,KAAK,IAAI,UAAU,IAAK,WAAW,GACjC,IAAI;EACF,OAAO,MAAM,IAAI,OAAO;CAC1B,SAAS,OAAO;EACd,IAAI,WAAW,SAAS,QAAQ,YAAY,QAAQ,CAAC,UAAU,KAAK,GAAG,MAAM;EAC7E,MAAM,MAAM,UAAU,OAAO,OAAO;EAGpC,MAAM,QAAQ,KAAK,MADL,OAAO,QAAQ,YAAY,OAAO,SAAS,GAAG,KAAK,OAAO,IACvC,MAAM,aAAa,SAAS,SAAS,MAAM,CAAC;EAC7E,MAAM,IAAI,SAAe,QAAQ,SAAS;GACxC,MAAM,cAAoB;IACxB,OAAO;IACP,KAAK,KAAK;GACZ;GACA,MAAM,SAAS,MAAM,MAAM,aAAa;IACtC,QAAQ,oBAAoB,SAAS,KAAK;IAC1C,OAAO;GACT,CAAC;GACD,QAAQ,iBAAiB,SAAS,OAAO,EAAE,MAAM,KAAK,CAAC;EACzD,CAAC;CACH;AAEJ"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/law.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* This module is the evaluator of the timer-ordering law. Its decisions are the same as the
|
|
4
3
|
* decisions of the research evaluator, except when absent timers leave no order (`evaluate`). The
|
|
@@ -121,8 +120,6 @@ declare const compress: (bind: Binding, k: number, marks: TimerMarks) => Compres
|
|
|
121
120
|
* hides is as wrong as one that it makes. The unmarked symbols are the symbols that the rules read.
|
|
122
121
|
*/
|
|
123
122
|
declare const compression: (rules: readonly Rule[], bind: Binding, k: number, marks: TimerMarks) => Compression;
|
|
124
|
-
//#endregion
|
|
125
|
-
//#region src/rules.d.ts
|
|
126
123
|
/**
|
|
127
124
|
* O04 with the hold of the service. The listener of a pod stays open through the preStop sleep and
|
|
128
125
|
* then through the hold of `fail readiness`. Thus the sum of the two must cover the propagation of
|
|
@@ -140,6 +137,4 @@ declare const O16: Rule;
|
|
|
140
137
|
* rules of this set that guard that way. `DRAIN_RULE_IDS` gives their identifiers.
|
|
141
138
|
*/
|
|
142
139
|
declare const DRAIN_RULES: readonly Rule[];
|
|
143
|
-
|
|
144
|
-
export { symbolsOf as C, inequalities as S, TimerMarks as _, O16 as a, compression as b, Change as c, Evaluated as d, Inequality as f, TimerMark as g, Term as h, O10 as i, Compressed as l, Side as m, O04 as n, Binding as o, Rule as p, O09 as r, Bound as s, DRAIN_RULES as t, Compression as u, Verdict as v, verdictOf as w, evaluate as x, compress as y };
|
|
145
|
-
//# sourceMappingURL=rules-BBRopO1e.d.ts.map
|
|
140
|
+
export { symbolsOf as C, inequalities as S, TimerMarks as _, O16 as a, compression as b, Change as c, Evaluated as d, Inequality as f, TimerMark as g, Term as h, O10 as i, Compressed as l, Side as m, O04 as n, Binding as o, Rule as p, O09 as r, Bound as s, DRAIN_RULES as t, Compression as u, Verdict as v, verdictOf as w, evaluate as x, compress as y };
|
package/build/rules.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as O16, i as O10, n as O04, p as Rule, r as O09, t as DRAIN_RULES } from "./rules-
|
|
1
|
+
import { a as O16, i as O10, n as O04, p as Rule, r as O09, t as DRAIN_RULES } from "./rules-HyFCBStQ.js";
|
|
2
2
|
export { DRAIN_RULES, O04, O09, O10, O16, type Rule };
|
package/build/rules.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/rules.ts
|
|
2
2
|
/**
|
|
3
3
|
* O04 with the hold of the service. The listener of a pod stays open through the preStop sleep and
|
|
4
4
|
* then through the hold of `fail readiness`. Thus the sum of the two must cover the propagation of
|
|
@@ -122,7 +122,6 @@ const DRAIN_RULES = [
|
|
|
122
122
|
O10,
|
|
123
123
|
O16
|
|
124
124
|
];
|
|
125
|
-
//#endregion
|
|
126
125
|
export { DRAIN_RULES, O04, O09, O10, O16 };
|
|
127
126
|
|
|
128
127
|
//# sourceMappingURL=rules.js.map
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { n as Clock } from "./clock-DpVgpY4h.js";
|
|
2
|
-
import { l as LimiterSpec, o as LimitRule, r as Decision } from "./policy-
|
|
3
|
-
//#region src/limiter/store.d.ts
|
|
2
|
+
import { l as LimiterSpec, o as LimitRule, r as Decision } from "./policy-CBcK2XGg.js";
|
|
4
3
|
/** A take request is one take of one key, with the rule and the cap of its limiter in numbers. */
|
|
5
4
|
interface TakeRequest {
|
|
6
5
|
/** This name is the limiter. A store keeps the keys of each limiter apart. */
|
|
@@ -89,6 +88,4 @@ interface LocalLimiter extends KeyedLimiter {
|
|
|
89
88
|
*/
|
|
90
89
|
declare function keyedLimiter(name: string, spec: LimiterSpec, store: MemoryStore): LocalLimiter;
|
|
91
90
|
declare function keyedLimiter(name: string, spec: LimiterSpec, store: LimiterStore): KeyedLimiter;
|
|
92
|
-
|
|
93
|
-
export { TakeRequest as a, MemoryStore as i, LimiterStore as n, keyedLimiter as o, LocalLimiter as r, memoryStore as s, KeyedLimiter as t };
|
|
94
|
-
//# sourceMappingURL=store-1CsNoJ8O.d.ts.map
|
|
91
|
+
export { TakeRequest as a, MemoryStore as i, LimiterStore as n, keyedLimiter as o, LocalLimiter as r, memoryStore as s, KeyedLimiter as t };
|
package/build/testing.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
+
import { D as CheckFn, F as Outcome, _ as RequestFn, d as TransportImpl, h as RequestEnd, r as Lifecycle } from "./lifecycle-D0J-zwZF.js";
|
|
2
|
+
import { K as ExitSignal, Q as ProcessPort, c as Logger, i as LogEntry, q as ExitTrigger, s as LogLevel, tt as UncaughtOrigin } from "./logger-B6drv9w0.js";
|
|
1
3
|
import { n as Clock } from "./clock-DpVgpY4h.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { n as ServiceBuilder } from "./builder-DQj3NNNc.js";
|
|
5
|
-
import { c as ProcessMark, d as StopSignal, i as CommandResult, n as CommandOptions, o as HostPorts, t as ChildHandle, u as SpawnRequest } from "./ports-CSr7qWrA.js";
|
|
4
|
+
import { n as ServiceBuilder } from "./builder-zO48Vgoj.js";
|
|
5
|
+
import { c as ProcessMark, d as StopSignal, i as CommandResult, n as CommandOptions, o as HostPorts, t as ChildHandle, u as SpawnRequest } from "./ports-DZoipkSD.js";
|
|
6
6
|
import { FakeClock, fakeClock } from "@mark1russell7/algebra/clock";
|
|
7
|
-
//#region src/fakes.d.ts
|
|
8
7
|
/** A fake process receives triggers from a test, and keeps each exit code in place of an exit. */
|
|
9
8
|
interface FakeProcess extends ProcessPort {
|
|
10
9
|
/** This method sends a signal to each handler of it. */
|
|
@@ -44,8 +43,6 @@ export declare const fakeProcess: (options?: FakeProcessOptions) => FakeProcess;
|
|
|
44
43
|
* `mulberry32` of @mark1russell7/rigor-generators.
|
|
45
44
|
*/
|
|
46
45
|
export declare const seeded: (seed: number) => (() => number);
|
|
47
|
-
//#endregion
|
|
48
|
-
//#region src/contract.d.ts
|
|
49
46
|
/** A contract case is one generated case of the contract test of a declaration. It throws on a failure. */
|
|
50
47
|
interface ContractCase {
|
|
51
48
|
readonly name: string;
|
|
@@ -73,8 +70,6 @@ interface ContractOptions {
|
|
|
73
70
|
* A dependency that no check exercises is a finding: the service cannot see it fail.
|
|
74
71
|
*/
|
|
75
72
|
export declare const contractCases: (declare: () => ServiceBuilder, options?: ContractOptions) => ContractCase[];
|
|
76
|
-
//#endregion
|
|
77
|
-
//#region src/conformance.d.ts
|
|
78
73
|
/** A held work is one unit of work that stays in flight until the test releases it. */
|
|
79
74
|
interface HeldWork {
|
|
80
75
|
/** This method lets the work end. Its promise ends when the caller of the work has its answer, or its error. */
|
|
@@ -193,8 +188,6 @@ interface ConformanceOptions {
|
|
|
193
188
|
* - At the deadline of the drain, the cut ends an open stream, and its caller gets the end.
|
|
194
189
|
*/
|
|
195
190
|
export declare const transportConformance: (make: SubjectFactory, options?: ConformanceOptions) => ContractCase[];
|
|
196
|
-
//#endregion
|
|
197
|
-
//#region src/host/fakes.d.ts
|
|
198
191
|
/** A fake child is a child process of a fake host. A test ends it, or a stop ends it. */
|
|
199
192
|
interface FakeChild extends ChildHandle {
|
|
200
193
|
readonly request: SpawnRequest;
|
|
@@ -272,8 +265,6 @@ interface FakeHost {
|
|
|
272
265
|
}
|
|
273
266
|
/** This function makes a fake host. Give its `ports` to the host functions in a test. */
|
|
274
267
|
export declare const fakeHost: (options?: FakeHostOptions) => FakeHost;
|
|
275
|
-
//#endregion
|
|
276
|
-
//#region src/testing.d.ts
|
|
277
268
|
/**
|
|
278
269
|
* A behavior is what a scripted check does when the runtime starts it:
|
|
279
270
|
* - `"ok"`, `"error"` and `"indeterminate"` give that outcome at once.
|
|
@@ -324,6 +315,4 @@ export interface QuietServer {
|
|
|
324
315
|
* and a black hole that keeps the connection look the same.
|
|
325
316
|
*/
|
|
326
317
|
export declare const quietServer: () => Promise<QuietServer>;
|
|
327
|
-
|
|
328
|
-
export { type CallerView, type ConformanceOptions, type ConformanceRecord, type ContractCase, type ContractOptions, type FakeChild, type FakeClock, type FakeHost, type FakeHostOptions, type FakeProcess, type FakeProcessOptions, type HeldWork, type RecordedCommand, type RecordedSignal, type SeenEnd, type StreamCall, type SubjectFactory, type TransportSubject, fakeClock };
|
|
329
|
-
//# sourceMappingURL=testing.d.ts.map
|
|
318
|
+
export { type CallerView, type ConformanceOptions, type ConformanceRecord, type ContractCase, type ContractOptions, type FakeChild, type FakeClock, type FakeHost, type FakeHostOptions, type FakeProcess, type FakeProcessOptions, type HeldWork, type RecordedCommand, type RecordedSignal, type SeenEnd, type StreamCall, type SubjectFactory, type TransportSubject, fakeClock };
|
package/build/testing.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
+
import { a as recoverSpan, r as failSpan } from "./timing-DZl36uXs.js";
|
|
1
2
|
import { realClock } from "./clock.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { t as tracker } from "./requests-BIq9Tr4P.js";
|
|
3
|
+
import { s as ownStream } from "./knobs-BJcz6m01.js";
|
|
4
|
+
import { t as tracker } from "./requests-DD2ALv0_.js";
|
|
5
5
|
import { valueIn } from "@mark1russell7/quantity";
|
|
6
6
|
import { fakeClock } from "@mark1russell7/algebra/clock";
|
|
7
7
|
import { createServer } from "node:net";
|
|
8
8
|
import { mulberry32 } from "@mark1russell7/rigor-generators";
|
|
9
9
|
import "node:events";
|
|
10
|
-
|
|
10
|
+
// src/fakes.ts
|
|
11
11
|
/** This function makes a fake process. */
|
|
12
12
|
const fakeProcess = (options = {}) => {
|
|
13
13
|
const handlers = /* @__PURE__ */ new Map();
|
|
@@ -95,8 +95,7 @@ const fakeProcess = (options = {}) => {
|
|
|
95
95
|
* `mulberry32` of @mark1russell7/rigor-generators.
|
|
96
96
|
*/
|
|
97
97
|
const seeded = (seed) => mulberry32(seed);
|
|
98
|
-
|
|
99
|
-
//#region src/contract.ts
|
|
98
|
+
// src/contract.ts
|
|
100
99
|
const ms = (amount) => valueIn(amount, "ms");
|
|
101
100
|
/** The part of a verdict that the contract compares: what a caller and the platform see. */
|
|
102
101
|
const visible = (verdict) => ({
|
|
@@ -274,8 +273,7 @@ const contractCases = (declare, options = {}) => {
|
|
|
274
273
|
});
|
|
275
274
|
return cases;
|
|
276
275
|
};
|
|
277
|
-
|
|
278
|
-
//#region src/http/fake-server.ts
|
|
276
|
+
// src/http/fake-server.ts
|
|
279
277
|
/** This function makes a pushed source, a stream of a work for the tests of a stream. */
|
|
280
278
|
const pushedSource = () => {
|
|
281
279
|
const queue = [];
|
|
@@ -332,8 +330,7 @@ const pushedSource = () => {
|
|
|
332
330
|
}
|
|
333
331
|
};
|
|
334
332
|
};
|
|
335
|
-
|
|
336
|
-
//#region src/conformance.ts
|
|
333
|
+
// src/conformance.ts
|
|
337
334
|
/**
|
|
338
335
|
* This function gives a detached lifecycle: a lifecycle with no service, for the start of a
|
|
339
336
|
* transport in a test. Its state is `running`, it keeps each connection, and nothing is in flight. Each request
|
|
@@ -794,8 +791,7 @@ const transportConformance = (make, options = {}) => {
|
|
|
794
791
|
];
|
|
795
792
|
return [...cases, ...streamCases];
|
|
796
793
|
};
|
|
797
|
-
|
|
798
|
-
//#region src/host/fakes.ts
|
|
794
|
+
// src/host/fakes.ts
|
|
799
795
|
const encoder = new TextEncoder();
|
|
800
796
|
const decoder = new TextDecoder();
|
|
801
797
|
const bytesOf = (data) => typeof data === "string" ? encoder.encode(data) : data;
|
|
@@ -1019,8 +1015,7 @@ const fakeHost = (options = {}) => {
|
|
|
1019
1015
|
};
|
|
1020
1016
|
return host;
|
|
1021
1017
|
};
|
|
1022
|
-
|
|
1023
|
-
//#region src/testing.ts
|
|
1018
|
+
// src/testing.ts
|
|
1024
1019
|
/** This function makes a scripted check with a behavior at the start. */
|
|
1025
1020
|
const scriptedCheck = (behavior = "ok") => {
|
|
1026
1021
|
let calls = 0;
|
|
@@ -1108,7 +1103,6 @@ const quietServer = async () => {
|
|
|
1108
1103
|
})
|
|
1109
1104
|
};
|
|
1110
1105
|
};
|
|
1111
|
-
//#endregion
|
|
1112
1106
|
export { contractCases, detachedLifecycle, fakeClock, fakeHost, fakeProcess, quietServer, scriptedCheck, seeded, testLogger, transportConformance };
|
|
1113
1107
|
|
|
1114
1108
|
//# sourceMappingURL=testing.js.map
|