@mark1russell7/service 0.5.10 → 0.5.11
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/{builder-DyDB7zM9.d.ts → builder-Dn0cby6Q.d.ts} +3 -3
- package/build/{clock-D-38uH_z.d.ts → clock-mVqhXD0b.d.ts} +2 -2
- package/build/clock.d.ts +1 -1
- package/build/clock.js +11 -3
- package/build/clock.js.map +1 -1
- package/build/heartbeat.d.ts +1 -1
- package/build/http.d.ts +2 -2
- package/build/index.d.ts +9 -7
- package/build/index.js +261 -239
- package/build/index.js.map +1 -1
- package/build/{lifecycle-Chu9Pri2.d.ts → lifecycle-CGEegMI0.d.ts} +2 -2
- package/build/{limiter-DCDdzVwe.d.ts → limiter-B0849Vhp.d.ts} +2 -2
- package/build/limiter.d.ts +2 -2
- package/build/redis.d.ts +4 -4
- package/build/{store-DzTyosou.d.ts → store-D5HLgBnW.d.ts} +2 -2
- package/build/testing.d.ts +3 -3
- package/package.json +3 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { n as Clock } from "./clock-
|
|
1
|
+
import { n as Clock } from "./clock-mVqhXD0b.js";
|
|
2
2
|
import { c as LimiterSpec } from "./policy-G4QJ1ZZq.js";
|
|
3
|
-
import { B as Gate, Ct as Operation, D as Outcome, E as CheckFn, F as CooperativeFloor, H as Phase, I as Coupling, J as Poll, L as Dependency, N as Check, R as ExitCodes, T as StartOptions, U as RepeatSignal, V as MessageTrigger, W as ServiceDescription, X as Timing, ct as ExitTrigger, d as TransportImpl, k as Trace, mt as ProcessTrigger, n as HealthServer, nt as OperationOf, o as PhaseWork, r as Lifecycle, s as RunOptions, t as DependencyHandle, x as Health } from "./lifecycle-
|
|
3
|
+
import { B as Gate, Ct as Operation, D as Outcome, E as CheckFn, F as CooperativeFloor, H as Phase, I as Coupling, J as Poll, L as Dependency, N as Check, R as ExitCodes, T as StartOptions, U as RepeatSignal, V as MessageTrigger, W as ServiceDescription, X as Timing, ct as ExitTrigger, d as TransportImpl, k as Trace, mt as ProcessTrigger, n as HealthServer, nt as OperationOf, o as PhaseWork, r as Lifecycle, s as RunOptions, t as DependencyHandle, x as Health } from "./lifecycle-CGEegMI0.js";
|
|
4
4
|
import { Extent, Quantity } from "@mark1russell7/quantity";
|
|
5
5
|
//#region src/profiles.d.ts
|
|
6
6
|
/**
|
|
@@ -208,4 +208,4 @@ interface ServiceBuilder {
|
|
|
208
208
|
declare const service: (name: string) => ServiceBuilder;
|
|
209
209
|
//#endregion
|
|
210
210
|
export { WatchdogSpec as a, Profile as c, kubernetes as d, localDev as f, Watchdog as i, daemon as l, ServiceBuilder as n, watchdog as o, service as r, PodTiming as s, ControllerBuilder as t, ephemeral as u };
|
|
211
|
-
//# sourceMappingURL=builder-
|
|
211
|
+
//# sourceMappingURL=builder-Dn0cby6Q.d.ts.map
|
|
@@ -24,7 +24,7 @@ interface PlatformClockOptions {
|
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
26
|
* This function makes a clock of the platform: `performance.now()` and `setTimeout`. Each cancel
|
|
27
|
-
* that it gives also has `unref`.
|
|
27
|
+
* that it gives also has `unref`. A delay longer than `setTimeout` takes waits in steps.
|
|
28
28
|
*/
|
|
29
29
|
declare const platformClock: (options?: PlatformClockOptions) => Clock;
|
|
30
30
|
/**
|
|
@@ -34,4 +34,4 @@ declare const platformClock: (options?: PlatformClockOptions) => Clock;
|
|
|
34
34
|
declare const realClock: Clock;
|
|
35
35
|
//#endregion
|
|
36
36
|
export { realClock as a, platformClock as i, Clock as n, PlatformClockOptions as r, Cancel as t };
|
|
37
|
-
//# sourceMappingURL=clock-
|
|
37
|
+
//# sourceMappingURL=clock-mVqhXD0b.d.ts.map
|
package/build/clock.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as realClock, i as platformClock, n as Clock, r as PlatformClockOptions, t as Cancel } from "./clock-
|
|
1
|
+
import { a as realClock, i as platformClock, n as Clock, r as PlatformClockOptions, t as Cancel } from "./clock-mVqhXD0b.js";
|
|
2
2
|
export { Cancel, Clock, PlatformClockOptions, platformClock, realClock };
|
package/build/clock.js
CHANGED
|
@@ -4,18 +4,26 @@ const monotonic = () => {
|
|
|
4
4
|
const performance = globalThis.performance;
|
|
5
5
|
return performance === void 0 ? Date.now() : performance.now();
|
|
6
6
|
};
|
|
7
|
+
/** This delay is the longest that `setTimeout` takes, in milliseconds. A longer delay starts the function after 1 ms. */
|
|
8
|
+
const LONGEST_DELAY = 2147483647;
|
|
7
9
|
/**
|
|
8
10
|
* This function makes a clock of the platform: `performance.now()` and `setTimeout`. Each cancel
|
|
9
|
-
* that it gives also has `unref`.
|
|
11
|
+
* that it gives also has `unref`. A delay longer than `setTimeout` takes waits in steps.
|
|
10
12
|
*/
|
|
11
13
|
const platformClock = (options = {}) => ({
|
|
12
14
|
now: monotonic,
|
|
13
15
|
after(ms, run) {
|
|
14
|
-
|
|
16
|
+
let unrefed = options.unref === true;
|
|
17
|
+
const arm = (left) => {
|
|
18
|
+
const step = left > LONGEST_DELAY ? setTimeout(() => timer = arm(left - LONGEST_DELAY), LONGEST_DELAY) : setTimeout(run, Math.max(0, left));
|
|
19
|
+
if (unrefed) step.unref?.();
|
|
20
|
+
return step;
|
|
21
|
+
};
|
|
22
|
+
let timer = arm(ms);
|
|
15
23
|
const unref = () => {
|
|
24
|
+
unrefed = true;
|
|
16
25
|
timer.unref?.();
|
|
17
26
|
};
|
|
18
|
-
if (options.unref === true) unref();
|
|
19
27
|
return Object.assign(() => clearTimeout(timer), { unref });
|
|
20
28
|
}
|
|
21
29
|
});
|
package/build/clock.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clock.js","names":[],"sources":["../src/clock.ts"],"sourcesContent":["// @mark1russell7/service/clock: the clock of the runtime, with no other part of the package. It\n// imports no `node:` module and no zod. Thus a client in a browser can use it.\n\n/**\n * This function stops a timer that `Clock.after` started. A second use does nothing. A clock of\n * the platform also gives `unref`: after it, the timer does not keep a Node process alive.\n */\nexport type Cancel = (() => void) & { readonly unref?: (() => void) | undefined };\n\n/**\n * A clock gives the monotonic time in milliseconds, and it starts a function after a delay. The\n * runtime reads time only through a clock. Thus a test can give a fake clock, and the timing of\n * the runtime is then exact and repeatable.\n */\nexport interface Clock {\n /** This method gives the monotonic time, in milliseconds. A step of the wall clock does not move it. */\n now(): number;\n /** This method starts `run` after `ms` milliseconds, and gives the function that stops it. */\n after(ms: number, run: () => void): Cancel;\n}\n\n/** These options make a clock of the platform. */\nexport interface PlatformClockOptions {\n /** True makes each timer not keep a Node process alive. The default is false, as with `setTimeout`. */\n readonly unref?: boolean | undefined;\n}\n\n/** This function gives the monotonic time: `performance.now()`, or `Date.now()` on a platform without `performance`. */\nconst monotonic = (): number => {\n const performance = (globalThis as { performance?: { now(): number } }).performance;\n return performance === undefined ? Date.now() : performance.now();\n};\n\n/**\n * This function makes a clock of the platform: `performance.now()` and `setTimeout`. Each cancel\n * that it gives also has `unref
|
|
1
|
+
{"version":3,"file":"clock.js","names":[],"sources":["../src/clock.ts"],"sourcesContent":["// @mark1russell7/service/clock: the clock of the runtime, with no other part of the package. It\n// imports no `node:` module and no zod. Thus a client in a browser can use it.\n\n/**\n * This function stops a timer that `Clock.after` started. A second use does nothing. A clock of\n * the platform also gives `unref`: after it, the timer does not keep a Node process alive.\n */\nexport type Cancel = (() => void) & { readonly unref?: (() => void) | undefined };\n\n/**\n * A clock gives the monotonic time in milliseconds, and it starts a function after a delay. The\n * runtime reads time only through a clock. Thus a test can give a fake clock, and the timing of\n * the runtime is then exact and repeatable.\n */\nexport interface Clock {\n /** This method gives the monotonic time, in milliseconds. A step of the wall clock does not move it. */\n now(): number;\n /** This method starts `run` after `ms` milliseconds, and gives the function that stops it. */\n after(ms: number, run: () => void): Cancel;\n}\n\n/** These options make a clock of the platform. */\nexport interface PlatformClockOptions {\n /** True makes each timer not keep a Node process alive. The default is false, as with `setTimeout`. */\n readonly unref?: boolean | undefined;\n}\n\n/** This function gives the monotonic time: `performance.now()`, or `Date.now()` on a platform without `performance`. */\nconst monotonic = (): number => {\n const performance = (globalThis as { performance?: { now(): number } }).performance;\n return performance === undefined ? Date.now() : performance.now();\n};\n\n/** This delay is the longest that `setTimeout` takes, in milliseconds. A longer delay starts the function after 1 ms. */\nconst LONGEST_DELAY = 0x7fffffff;\n\n/**\n * This function makes a clock of the platform: `performance.now()` and `setTimeout`. Each cancel\n * that it gives also has `unref`. A delay longer than `setTimeout` takes waits in steps.\n */\nexport const platformClock = (options: PlatformClockOptions = {}): Clock => ({\n now: monotonic,\n after(ms, run) {\n let unrefed = options.unref === true;\n const arm = (left: number): ReturnType<typeof setTimeout> => {\n const step =\n left > LONGEST_DELAY ? setTimeout(() => (timer = arm(left - LONGEST_DELAY)), LONGEST_DELAY) : setTimeout(run, Math.max(0, left));\n if (unrefed) (step as { unref?: () => void }).unref?.();\n return step;\n };\n let timer = arm(ms);\n const unref = (): void => {\n unrefed = true;\n (timer as { unref?: () => void }).unref?.();\n };\n return Object.assign(() => clearTimeout(timer), { unref });\n },\n});\n\n/**\n * This clock reads `performance.now()` and uses `setTimeout`. Its timers do not keep a Node\n * process alive, thus a timer that is not stopped cannot stop the exit of the process.\n */\nexport const realClock: Clock = /* @__PURE__ */ platformClock({ unref: true });\n"],"mappings":";;AA4BA,MAAM,kBAA0B;CAC9B,MAAM,cAAe,WAAmD;CACxE,OAAO,gBAAgB,KAAA,IAAY,KAAK,IAAI,IAAI,YAAY,IAAI;AAClE;;AAGA,MAAM,gBAAgB;;;;;AAMtB,MAAa,iBAAiB,UAAgC,CAAC,OAAc;CAC3E,KAAK;CACL,MAAM,IAAI,KAAK;EACb,IAAI,UAAU,QAAQ,UAAU;EAChC,MAAM,OAAO,SAAgD;GAC3D,MAAM,OACJ,OAAO,gBAAgB,iBAAkB,QAAQ,IAAI,OAAO,aAAa,GAAI,aAAa,IAAI,WAAW,KAAK,KAAK,IAAI,GAAG,IAAI,CAAC;GACjI,IAAI,SAAS,KAAiC,QAAQ;GACtD,OAAO;EACT;EACA,IAAI,QAAQ,IAAI,EAAE;EAClB,MAAM,cAAoB;GACxB,UAAU;GACV,MAAkC,QAAQ;EAC5C;EACA,OAAO,OAAO,aAAa,aAAa,KAAK,GAAG,EAAE,MAAM,CAAC;CAC3D;AACF;;;;;AAMA,MAAa,YAAmC,8BAAc,EAAE,OAAO,KAAK,CAAC"}
|
package/build/heartbeat.d.ts
CHANGED
package/build/http.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { n as Clock } from "./clock-
|
|
1
|
+
import { n as Clock } from "./clock-mVqhXD0b.js";
|
|
2
2
|
import { d as Refused } from "./policy-G4QJ1ZZq.js";
|
|
3
|
-
import { d as TransportImpl, m as RequestEnd, n as HealthServer, r as Lifecycle, v as RequestStream, w as ProbeKind, x as Health, y as RequestWork } from "./lifecycle-
|
|
3
|
+
import { d as TransportImpl, m as RequestEnd, n as HealthServer, r as Lifecycle, v as RequestStream, w as ProbeKind, x as Health, y as RequestWork } from "./lifecycle-CGEegMI0.js";
|
|
4
4
|
import { Extent, Quantity } from "@mark1russell7/quantity";
|
|
5
5
|
import { ListenOptions } from "node:net";
|
|
6
6
|
import { IncomingMessage, Server, ServerEventMap, ServerResponse } from "node:http";
|
package/build/index.d.ts
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import { a as backoffDelay, i as backoffBand, n as DelayBand, o as backoffProblems, r as Jitter, t as Backoff } from "./backoff-B-jGWVDm.js";
|
|
2
|
-
import { a as realClock, i as platformClock, n as Clock, r as PlatformClockOptions, t as Cancel } from "./clock-
|
|
2
|
+
import { a as realClock, i as platformClock, n as Clock, r as PlatformClockOptions, t as Cancel } from "./clock-mVqhXD0b.js";
|
|
3
3
|
import { Heartbeat, HeartbeatOptions, detectionTime, heartbeat } from "./heartbeat.js";
|
|
4
4
|
import { S as retryAfterSeconds, _ as freeAt, a as LimitRule, b as limiterProblems, c as LimiterSpec, d as Refused, f as SlidingWindow, g as decide, h as TokenBucket, i as LimitPolicy, l as LimiterStoreSpec, m as TakeStep, n as Decision, o as Limiter, p as StoreFailure, r as KeyState, s as LimiterEviction, t as Allowed, u as RefusalCause, v as idleSpan, x as longestRetryAfter, y as limitRule } from "./policy-G4QJ1ZZq.js";
|
|
5
|
-
import { $ as failSpan, A as LifecycleEvent, B as Gate, C as ProbeAnswer, Ct as Operation, D as Outcome, E as CheckFn, F as CooperativeFloor, G as Step, H as Phase, I as Coupling, J as Poll, K as Transport, L as Dependency, M as Recorder, N as Check, O as Result, P as Controller, Q as asWindow, R as ExitCodes, S as HealthVerdict, St as Idempotency, T as StartOptions, U as RepeatSignal, V as MessageTrigger, W as ServiceDescription, X as Timing, Y as Span, Z as asDebounce, _ as RequestOptions, _t as isExitSignal, a as PhaseContext, at as EXIT_SIGNALS, b as CheckVerdict, bt as nodeProcess, c as STAGES, ct as ExitTrigger, d as TransportImpl, dt as PROCESS_TRIGGERS, et as heartbeatDetection, f as cooperativeAbortAt, ft as ProcessHost, g as RequestFn, gt as isExitCode, h as RequestEvent, ht as embeddedProcess, i as LifecycleState, it as RouteRequest, j as MachineName, l as ShutdownOptions, lt as HostStream, m as RequestEnd, mt as ProcessTrigger, n as HealthServer, nt as OperationOf, o as PhaseWork, ot as EmbeddedProcess, p as stageRank, pt as ProcessPort, q as FailsBy, r as Lifecycle, rt as RoutePattern, s as RunOptions, st as ExitSignal, t as DependencyHandle, tt as recoverSpan, u as Stage, ut as MessageShape, v as RequestStream, vt as isMessageShape, w as ProbeKind, wt as mayReissue, x as Health, xt as processPortOf, y as RequestWork, yt as matchesMessage, z as FORMAT } from "./lifecycle-
|
|
6
|
-
import { a as WatchdogSpec, c as Profile, d as kubernetes, f as localDev, i as Watchdog, l as daemon, n as ServiceBuilder, o as watchdog, r as service, s as PodTiming, t as ControllerBuilder, u as ephemeral } from "./builder-
|
|
7
|
-
import { a as keyedLimiter, i as TakeRequest, n as LimiterStore, o as memoryStore, r as MemoryStore, t as KeyedLimiter } from "./store-
|
|
8
|
-
import { a as limiterStateOf, i as limiterMachine, n as SLIDING_WINDOW_MACHINE, r as TOKEN_BUCKET_MACHINE, t as LimiterState } from "./limiter-
|
|
5
|
+
import { $ as failSpan, A as LifecycleEvent, B as Gate, C as ProbeAnswer, Ct as Operation, D as Outcome, E as CheckFn, F as CooperativeFloor, G as Step, H as Phase, I as Coupling, J as Poll, K as Transport, L as Dependency, M as Recorder, N as Check, O as Result, P as Controller, Q as asWindow, R as ExitCodes, S as HealthVerdict, St as Idempotency, T as StartOptions, U as RepeatSignal, V as MessageTrigger, W as ServiceDescription, X as Timing, Y as Span, Z as asDebounce, _ as RequestOptions, _t as isExitSignal, a as PhaseContext, at as EXIT_SIGNALS, b as CheckVerdict, bt as nodeProcess, c as STAGES, ct as ExitTrigger, d as TransportImpl, dt as PROCESS_TRIGGERS, et as heartbeatDetection, f as cooperativeAbortAt, ft as ProcessHost, g as RequestFn, gt as isExitCode, h as RequestEvent, ht as embeddedProcess, i as LifecycleState, it as RouteRequest, j as MachineName, l as ShutdownOptions, lt as HostStream, m as RequestEnd, mt as ProcessTrigger, n as HealthServer, nt as OperationOf, o as PhaseWork, ot as EmbeddedProcess, p as stageRank, pt as ProcessPort, q as FailsBy, r as Lifecycle, rt as RoutePattern, s as RunOptions, st as ExitSignal, t as DependencyHandle, tt as recoverSpan, u as Stage, ut as MessageShape, v as RequestStream, vt as isMessageShape, w as ProbeKind, wt as mayReissue, x as Health, xt as processPortOf, y as RequestWork, yt as matchesMessage, z as FORMAT } from "./lifecycle-CGEegMI0.js";
|
|
6
|
+
import { a as WatchdogSpec, c as Profile, d as kubernetes, f as localDev, i as Watchdog, l as daemon, n as ServiceBuilder, o as watchdog, r as service, s as PodTiming, t as ControllerBuilder, u as ephemeral } from "./builder-Dn0cby6Q.js";
|
|
7
|
+
import { a as keyedLimiter, i as TakeRequest, n as LimiterStore, o as memoryStore, r as MemoryStore, t as KeyedLimiter } from "./store-D5HLgBnW.js";
|
|
8
|
+
import { a as limiterStateOf, i as limiterMachine, n as SLIDING_WINDOW_MACHINE, r as TOKEN_BUCKET_MACHINE, t as LimiterState } from "./limiter-B0849Vhp.js";
|
|
9
9
|
import { Extent, Quantity } from "@mark1russell7/quantity";
|
|
10
10
|
import { replay } from "@mark1russell7/algebra/replay";
|
|
11
11
|
import { Machine } from "@mark1russell7/algebra";
|
|
12
12
|
//#region src/law.d.ts
|
|
13
13
|
/**
|
|
14
14
|
* This module is the evaluator of the timer-ordering law. Its decisions are the same as the
|
|
15
|
-
* decisions of the research evaluator
|
|
15
|
+
* decisions of the research evaluator, except when absent timers leave no order (`evaluate`). The
|
|
16
|
+
* rules are data, and the caller gives them. Each rule
|
|
16
17
|
* is one or more linear inequalities over symbols at a hop (`readiness_detection_window@pod`),
|
|
17
18
|
* with a margin. A binding maps `symbol@hop` to seconds, or to "inf" for a timer that is absent.
|
|
18
19
|
*/
|
|
@@ -71,7 +72,8 @@ export declare const symbolsOf: (rule: Rule) => string[];
|
|
|
71
72
|
/**
|
|
72
73
|
* This function evaluates each inequality on one binding. "<" holds when lhs + margin < rhs, and
|
|
73
74
|
* ">" holds when lhs > rhs + margin. Only the inequalities with all their symbols bound apply.
|
|
74
|
-
* The others are null.
|
|
75
|
+
* The others are null. Absent timers can leave no order: the same infinity on each side, or both
|
|
76
|
+
* signs of infinity on one side. Then the inequality holds only because a timer is absent.
|
|
75
77
|
*/
|
|
76
78
|
export declare const evaluate: (rule: Rule, bind: Binding) => Evaluated[];
|
|
77
79
|
/**
|