@plitzi/sdk-kernel 0.0.0-stage → 0.39.2
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/CHANGELOG.md +10 -0
- package/README.md +80 -2
- package/dist/build/esbuild.d.ts +16 -0
- package/dist/build/index.d.ts +1 -0
- package/dist/build/index.mjs +35 -0
- package/dist/cache/CompressedFileCache.d.ts +18 -0
- package/dist/cache/TtlCache.d.ts +65 -0
- package/dist/cache/index.d.ts +3 -0
- package/dist/cache/index.mjs +1 -0
- package/dist/chunks/TtlCache-J_jG9oL9.mjs +200 -0
- package/dist/chunks/channel-DnVf7PJB.mjs +190 -0
- package/dist/chunks/csrf-BLWcaYOV.mjs +295 -0
- package/dist/chunks/link-C9wyDS9H.mjs +124 -0
- package/dist/chunks/query-DGbrN3mN.mjs +20 -0
- package/dist/chunks/scopes-Co6ZjhAm.mjs +46 -0
- package/dist/chunks/serverLog-BKaKjjc4.mjs +137 -0
- package/dist/chunks/session-B-dTEjeG.mjs +253 -0
- package/dist/chunks/sessionActivity-Ch7xuQ_o.mjs +43 -0
- package/dist/chunks/spaceDeployment-J2IMLfij.mjs +76 -0
- package/dist/chunks/stage-y6deE9LJ.mjs +345 -0
- package/dist/chunks/supervisor-Dh34v1vq.mjs +117 -0
- package/dist/chunks/tail-D-USrZIR.mjs +55 -0
- package/dist/chunks/tokens-CBd5tXut.mjs +262 -0
- package/dist/data/index.d.ts +2 -0
- package/dist/data/index.mjs +68 -0
- package/dist/data/projectData.d.ts +21 -0
- package/dist/deployment/hostDeployment.d.ts +8 -0
- package/dist/deployment/index.d.ts +3 -0
- package/dist/deployment/index.mjs +19 -0
- package/dist/deployment/spaceDeployment.d.ts +11 -0
- package/dist/engine/index.d.ts +2 -0
- package/dist/engine/index.mjs +1 -0
- package/dist/engine/page.d.ts +49 -0
- package/dist/engine/rsc.d.ts +32 -0
- package/dist/files/atomicFile.d.ts +10 -0
- package/dist/files/index.d.ts +1 -0
- package/dist/files/index.mjs +32 -0
- package/dist/http/bearer.d.ts +5 -0
- package/dist/http/buildResponseHelpers.d.ts +23 -0
- package/dist/http/closeOnSignals.d.ts +28 -0
- package/dist/http/compress.d.ts +20 -0
- package/dist/http/dispatcher.d.ts +15 -0
- package/dist/http/drain.d.ts +18 -0
- package/dist/http/fleet/channel.d.ts +103 -0
- package/dist/http/fleet/link.d.ts +28 -0
- package/dist/http/fleet/role.d.ts +46 -0
- package/dist/http/fleet/supervisor.d.ts +29 -0
- package/dist/http/freePort.d.ts +24 -0
- package/dist/http/health.d.ts +21 -0
- package/dist/http/index.d.ts +48 -0
- package/dist/http/index.mjs +1313 -0
- package/dist/http/middlewares/auth.d.ts +2 -0
- package/dist/http/middlewares/basicAuth.d.ts +6 -0
- package/dist/http/mimeTypes.d.ts +13 -0
- package/dist/http/navigation.d.ts +14 -0
- package/dist/http/onAbort.d.ts +12 -0
- package/dist/http/probes.d.ts +4 -0
- package/dist/http/requestParser.d.ts +22 -0
- package/dist/http/runMiddlewares.d.ts +6 -0
- package/dist/http/securityHeaders.d.ts +18 -0
- package/dist/http/server.d.ts +39 -0
- package/dist/http/socketResponse.d.ts +18 -0
- package/dist/http/sse.d.ts +26 -0
- package/dist/http/stages/crossSiteWrites.d.ts +24 -0
- package/dist/http/stages/health.d.ts +11 -0
- package/dist/http/stages/middlewares.d.ts +3 -0
- package/dist/http/stages/static.d.ts +4 -0
- package/dist/http/staticFiles.d.ts +3 -0
- package/dist/http/stopping.d.ts +11 -0
- package/dist/http/transports.d.ts +31 -0
- package/dist/http/types.d.ts +29 -0
- package/dist/http/unusedPort.d.ts +10 -0
- package/dist/http/webExchange.d.ts +18 -0
- package/dist/http/wsFrame.d.ts +3 -0
- package/dist/identity/accounts.d.ts +278 -0
- package/dist/identity/authorize.d.ts +96 -0
- package/dist/identity/credentials.d.ts +40 -0
- package/dist/identity/csrf.d.ts +139 -0
- package/dist/identity/debugAuthorization.d.ts +24 -0
- package/dist/identity/domains.d.ts +41 -0
- package/dist/identity/identity.d.ts +119 -0
- package/dist/identity/index.d.ts +21 -0
- package/dist/identity/index.mjs +731 -0
- package/dist/identity/passwords.d.ts +15 -0
- package/dist/identity/previewToken.d.ts +21 -0
- package/dist/identity/requestIdentity.d.ts +14 -0
- package/dist/identity/scopes.d.ts +56 -0
- package/dist/identity/session.d.ts +185 -0
- package/dist/identity/sessionActivity.d.ts +11 -0
- package/dist/identity/spaceTokens.d.ts +174 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.mjs +1 -0
- package/dist/log/index.d.ts +3 -0
- package/dist/log/index.mjs +3 -0
- package/dist/log/serverLog.d.ts +49 -0
- package/dist/log/tail.d.ts +43 -0
- package/dist/mysql/accounts.d.ts +4 -0
- package/dist/mysql/admin.d.ts +58 -0
- package/dist/mysql/config.d.ts +82 -0
- package/dist/mysql/identities.d.ts +35 -0
- package/dist/mysql/index.d.ts +7 -0
- package/dist/mysql/index.mjs +1203 -0
- package/dist/mysql/pool.d.ts +3 -0
- package/dist/mysql/query.d.ts +12 -0
- package/dist/mysql/schema.d.ts +43 -0
- package/dist/mysql/sessions.d.ts +23 -0
- package/dist/mysql/spaceTokens.d.ts +11 -0
- package/dist/mysql/store.d.ts +66 -0
- package/dist/outbound/index.d.ts +4 -0
- package/dist/outbound/index.mjs +314 -0
- package/dist/outbound/inside.d.ts +36 -0
- package/dist/outbound/outboundGuard.d.ts +69 -0
- package/dist/pubsub/index.d.ts +3 -0
- package/dist/pubsub/index.mjs +76 -0
- package/dist/pubsub/memoryPubSub.d.ts +10 -0
- package/dist/pubsub/redisPubSub.d.ts +24 -0
- package/dist/stats/index.d.ts +9 -0
- package/dist/stats/index.mjs +228 -0
- package/dist/stats/load.d.ts +31 -0
- package/dist/stats/memory.d.ts +20 -0
- package/dist/stats/pools.d.ts +15 -0
- package/dist/stats/recorder.d.ts +34 -0
- package/dist/stats/stage.d.ts +15 -0
- package/dist/stats/types.d.ts +309 -0
- package/dist/testing/certificates.d.ts +21 -0
- package/dist/testing/fleet.d.ts +28 -0
- package/dist/testing/goneRuns.d.ts +5 -0
- package/dist/testing/index.d.ts +5 -0
- package/dist/testing/index.mjs +270 -0
- package/dist/testing/keys.d.ts +2 -0
- package/dist/testing/runNames.d.ts +10 -0
- package/dist/tokens/index.d.ts +2 -0
- package/dist/tokens/index.mjs +1 -0
- package/dist/tokens/tokens.d.ts +190 -0
- package/dist/types/adapters.d.ts +388 -0
- package/dist/types/config.d.ts +240 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.mjs +1 -0
- package/dist/types/log.d.ts +119 -0
- package/dist/types/oauth.d.ts +246 -0
- package/dist/types/pipeline.d.ts +239 -0
- package/package.json +67 -3
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the workers of one server say to their primary, and it to them — with nothing here that knows about
|
|
3
|
+
* `node:cluster`, so the rules can be held by tests in one process.
|
|
4
|
+
*
|
|
5
|
+
* Two things cross it:
|
|
6
|
+
*
|
|
7
|
+
* - **Calls to a store the primary holds.** A default kept in memory — an action's `kv`, the job queue, the drafts a
|
|
8
|
+
* preview reads, the sign-in rate limit — is right for one process and wrong for several: a counter that counts
|
|
9
|
+
* one worker's requests, a schedule every worker fires. With workers, the primary keeps the one copy and each
|
|
10
|
+
* worker calls it. One process answering them in turn is what makes `increment` atomic across the fleet.
|
|
11
|
+
* - **Broadcasts.** What one process is told — invalidate this page, forget that plugin — reaches every other.
|
|
12
|
+
* Nothing answers a broadcast, so what is sent must be safe to apply twice.
|
|
13
|
+
*/
|
|
14
|
+
export type FleetCall = {
|
|
15
|
+
sdkFleet: 'call';
|
|
16
|
+
id: number;
|
|
17
|
+
store: string;
|
|
18
|
+
method: string;
|
|
19
|
+
args: unknown[];
|
|
20
|
+
};
|
|
21
|
+
export type FleetReply = {
|
|
22
|
+
sdkFleet: 'reply';
|
|
23
|
+
id: number;
|
|
24
|
+
ok: true;
|
|
25
|
+
value: unknown;
|
|
26
|
+
} | {
|
|
27
|
+
sdkFleet: 'reply';
|
|
28
|
+
id: number;
|
|
29
|
+
ok: false;
|
|
30
|
+
error: string;
|
|
31
|
+
};
|
|
32
|
+
export type FleetBroadcast = {
|
|
33
|
+
sdkFleet: 'broadcast';
|
|
34
|
+
channel: string;
|
|
35
|
+
payload: unknown;
|
|
36
|
+
};
|
|
37
|
+
export type FleetMessage = FleetCall | FleetReply | FleetBroadcast;
|
|
38
|
+
/** The channel is shared with `node:cluster` and anything else the deployment sends: only these are ours. */
|
|
39
|
+
export declare const isFleetMessage: (value: unknown) => value is FleetMessage;
|
|
40
|
+
/** A store as a worker sees it: every method answers later, since the answer comes from another process. */
|
|
41
|
+
export type Remote<T> = {
|
|
42
|
+
[K in keyof T]: T[K] extends (...args: infer A) => infer R ? (...args: A) => Promise<Awaited<R>> : never;
|
|
43
|
+
};
|
|
44
|
+
/** Every method of a store, named: the key set is checked, so a method added to the store is not left unreachable. */
|
|
45
|
+
export type StoreMethods<T> = {
|
|
46
|
+
[K in keyof T]-?: true;
|
|
47
|
+
};
|
|
48
|
+
/** How the primary makes a store the first time a worker asks for it, and the methods a worker may call on it. */
|
|
49
|
+
export type HostedStore = {
|
|
50
|
+
create: () => object;
|
|
51
|
+
methods: ReadonlySet<string>;
|
|
52
|
+
};
|
|
53
|
+
export declare const hostable: <T extends object>(create: () => T, methods: StoreMethods<T>) => HostedStore;
|
|
54
|
+
/**
|
|
55
|
+
* The primary's side: the stores it keeps for its workers, answering their calls.
|
|
56
|
+
*
|
|
57
|
+
* A worker names a store `<kind>#<n>` — the n-th of that kind its code built, the same in every worker since they
|
|
58
|
+
* all run the same code — and the primary makes it from the catalogue the first time it is asked. Nothing is made
|
|
59
|
+
* that no worker uses. A call names a method the kind was registered with and nothing else: the channel is not a way
|
|
60
|
+
* to reach whatever the object happens to carry.
|
|
61
|
+
*/
|
|
62
|
+
export declare const createStoreHost: (catalogue: Readonly<Record<string, HostedStore>>) => {
|
|
63
|
+
answer: (call: FleetCall) => Promise<FleetReply>;
|
|
64
|
+
};
|
|
65
|
+
export type StoreHost = ReturnType<typeof createStoreHost>;
|
|
66
|
+
/** Who in this process hears a broadcast, by channel. A listener that throws is the caller's to report. */
|
|
67
|
+
export declare const createListeners: (onError: (channel: string, error: unknown) => void) => {
|
|
68
|
+
listen: (channel: string, listener: (payload: unknown) => void) => (() => void);
|
|
69
|
+
deliver: (channel: string, payload: unknown) => void;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* A worker's side: calls to the primary's stores, and broadcasts both ways.
|
|
73
|
+
*
|
|
74
|
+
* `send` may throw — a value that cannot cross the channel, a primary already gone — and the call then fails
|
|
75
|
+
* rather than waiting for an answer that will not come. The same when the channel closes with calls in flight.
|
|
76
|
+
*/
|
|
77
|
+
export declare const createFleetClient: (send: (message: FleetMessage) => void, deliver: (channel: string, payload: unknown) => void) => {
|
|
78
|
+
call: (store: string, method: string, args: unknown[]) => Promise<unknown>;
|
|
79
|
+
remote: <T extends object>(store: string, methods: StoreMethods<T>) => Remote<T>;
|
|
80
|
+
broadcast: (channel: string, payload: unknown) => void;
|
|
81
|
+
receive: (message: FleetMessage) => void;
|
|
82
|
+
close: () => void;
|
|
83
|
+
};
|
|
84
|
+
export type FleetClient = ReturnType<typeof createFleetClient>;
|
|
85
|
+
export type FleetPeer = {
|
|
86
|
+
id: number;
|
|
87
|
+
send: (message: FleetMessage) => void;
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* The primary's side of the channel: it answers its workers' calls from the stores it holds, and passes each
|
|
91
|
+
* broadcast on to every process that did not send it — itself included, so a server in the primary hears it too.
|
|
92
|
+
*
|
|
93
|
+
* A peer that went away between a call and its answer is simply not answered: it is not waiting any more.
|
|
94
|
+
*/
|
|
95
|
+
export declare const createFleetHub: ({ host, deliver, peers }: {
|
|
96
|
+
host: StoreHost;
|
|
97
|
+
deliver: (channel: string, payload: unknown) => void;
|
|
98
|
+
peers: () => FleetPeer[];
|
|
99
|
+
}) => {
|
|
100
|
+
receive: (from: number, message: FleetMessage) => Promise<void>;
|
|
101
|
+
broadcast: (channel: string, payload: unknown, except?: number) => void;
|
|
102
|
+
};
|
|
103
|
+
export type FleetHub = ReturnType<typeof createFleetHub>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { HostedStore, Remote, StoreMethods } from './channel';
|
|
2
|
+
/**
|
|
3
|
+
* This process's end of the fleet channel (`channel.ts`), over `node:cluster` — for a `primary` or a `worker`
|
|
4
|
+
* (`role.ts`). A single server never reaches past `fleetStore`, which answers it nothing.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* A store a single process keeps in memory by default, which the workers of a fleet share: named by the module that
|
|
8
|
+
* keeps it (`actions.kv`, `ssr.drafts`), so the fleet knows no store of its own.
|
|
9
|
+
*/
|
|
10
|
+
export type FleetStoreName = string;
|
|
11
|
+
/** The stores the primary keeps for its workers, by name: handed in by whoever composes the server. */
|
|
12
|
+
export type FleetStores = Readonly<Record<FleetStoreName, HostedStore>>;
|
|
13
|
+
/**
|
|
14
|
+
* The primary's hub: it answers its workers from the stores in `catalogue`, made when first asked for, and passes
|
|
15
|
+
* broadcasts on. Started before the first fork, so no worker can ask before anyone is answering.
|
|
16
|
+
*/
|
|
17
|
+
export declare const startHub: (catalogue: FleetStores) => void;
|
|
18
|
+
/**
|
|
19
|
+
* In a worker, the primary's copy of a store a single server keeps in memory, reached over the channel. Anywhere
|
|
20
|
+
* else, nothing — so a call site reads `deployment's ?? fleetStore(…) ?? what a single server has always made`.
|
|
21
|
+
*/
|
|
22
|
+
export declare const fleetStore: <T extends object>(name: FleetStoreName, methods: StoreMethods<T>) => Remote<T> | undefined;
|
|
23
|
+
/** A name for one server's broadcasts, the same in the primary and in each of its workers. */
|
|
24
|
+
export declare const channelName: (label: string) => string;
|
|
25
|
+
/** Tells every other process of the fleet. */
|
|
26
|
+
export declare const broadcast: (channel: string, payload: unknown) => void;
|
|
27
|
+
/** Hears what another process of the fleet broadcast on `channel`. */
|
|
28
|
+
export declare const onBroadcast: (channel: string, listener: (payload: unknown) => void) => (() => void);
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where a server decides whether it runs as one process or as several — the one fork between the two modes.
|
|
3
|
+
*
|
|
4
|
+
* - `single`: workers off, one asked for, or one core to run on. Everything is what it always was: the stores are
|
|
5
|
+
* this process's own, `server.cache` is its own, nothing listens on a channel and nothing is forked.
|
|
6
|
+
* - `primary`: the process that was started, asked for more than one. It serves nothing: it forks the workers,
|
|
7
|
+
* restarts the ones that die (`supervisor.ts`) and keeps, for all of them, the stores a single process keeps
|
|
8
|
+
* in memory (`stores.ts`).
|
|
9
|
+
* - `worker`: forked by a primary. It serves, and reaches those stores — and tells the other workers what they must
|
|
10
|
+
* hear — over the channel to its primary (`link.ts`).
|
|
11
|
+
*
|
|
12
|
+
* Every other file in this folder serves the last two; the rest of the server asks only `fleetRole`,
|
|
13
|
+
* `runsFleetJobs` and, for a store, `fleetStore` (which answers nothing outside a worker).
|
|
14
|
+
*/
|
|
15
|
+
export type WorkersOption = boolean | number | 'auto';
|
|
16
|
+
export type WorkersPlan = {
|
|
17
|
+
/** The processes that will serve. */
|
|
18
|
+
count: number;
|
|
19
|
+
/** What was asked for, when it was more than the cores there are — and so was lowered to them. */
|
|
20
|
+
requested?: number;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* How many processes serve the port.
|
|
24
|
+
*
|
|
25
|
+
* On by default in production — one per core the process may use, which `availableParallelism` reads from the
|
|
26
|
+
* container's CPU quota too, so a quarter-core container gets one. Off by default anywhere else: a development server
|
|
27
|
+
* under `--watch` or a debugger, and a test runner that starts servers in its own process, must stay one process.
|
|
28
|
+
* The config wins over `SDK_SERVER_WORKERS`, which wins over the default.
|
|
29
|
+
*
|
|
30
|
+
* A number is a ceiling, not a demand: more processes than cores only take turns on the same cores, each with its
|
|
31
|
+
* own memory, so it is lowered to the cores there are and the plan says it was.
|
|
32
|
+
*/
|
|
33
|
+
export declare const resolveWorkers: (option: WorkersOption | undefined, environment?: NodeJS.ProcessEnv, cores?: number) => WorkersPlan;
|
|
34
|
+
/** The environment the primary gives a worker it forks — and the one worker that carries the fleet's jobs. */
|
|
35
|
+
export declare const fleetWorkerEnv: (runsJobs: boolean) => Record<string, string>;
|
|
36
|
+
export declare const isFleetWorker: () => boolean;
|
|
37
|
+
export type FleetRole = 'single' | 'primary' | 'worker';
|
|
38
|
+
export declare const fleetRole: (plan: WorkersPlan) => FleetRole;
|
|
39
|
+
/**
|
|
40
|
+
* Whether this process runs the scheduler and the job consumers.
|
|
41
|
+
*
|
|
42
|
+
* A single server, yes, as it always did. Of a fleet, one worker only: its workers are one replica, and a replica's
|
|
43
|
+
* `jobs` settings — how many run at once, whether it schedules at all — are for the replica, not for each of its
|
|
44
|
+
* processes. The primary hands the role to the replacement of the worker that carried it.
|
|
45
|
+
*/
|
|
46
|
+
export declare const runsFleetJobs: () => boolean;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { FleetStores } from './link';
|
|
2
|
+
export type Fleet = {
|
|
3
|
+
/** Resolved once a worker takes connections: the port answers from then on. */
|
|
4
|
+
listening: Promise<void>;
|
|
5
|
+
stop: () => Promise<void>;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* How long the replacement for a dead worker waits, given how many have died in the last minute. As many deaths as
|
|
9
|
+
* there are workers — each of them crashing once — are replaced at once; past that it doubles from half a second, up
|
|
10
|
+
* to thirty.
|
|
11
|
+
*/
|
|
12
|
+
export declare const restartDelay: (deathsInWindow: number, count: number) => number;
|
|
13
|
+
/**
|
|
14
|
+
* Starts `count` workers from this primary, each running the process's own entry point — so each builds and binds
|
|
15
|
+
* its own server on the shared port, and the connections are spread between them.
|
|
16
|
+
*
|
|
17
|
+
* A worker that dies is replaced, crash or kill alike, and the replacement takes over whatever the dead one carried
|
|
18
|
+
* (the jobs). Past one death per worker a minute the replacements wait, longer each time (`restartDelay`), so a
|
|
19
|
+
* request that crashes whichever worker takes it cannot turn the primary into a fork loop.
|
|
20
|
+
*
|
|
21
|
+
* Until the fleet has served at all, a death is not retried: a worker that dies before any has listened would die
|
|
22
|
+
* the same way again — a port in use, a broken build — so the fleet stops and the process exits non-zero for
|
|
23
|
+
* whatever supervises it. Once it has served, a replacement that fails to start is retried like any other death:
|
|
24
|
+
* the workers still serving keep serving through a passing failure (a database that is briefly down).
|
|
25
|
+
*
|
|
26
|
+
* `stop` asks every worker to finish with SIGTERM (what `closeOnSignals` answers) and waits for all of them. A
|
|
27
|
+
* primary that dies without stopping them takes them with it: a worker exits when its channel to the primary closes.
|
|
28
|
+
*/
|
|
29
|
+
export declare const startFleet: (count: number, label: string, stores: FleetStores, exit?: (code: number) => void) => Fleet;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** Whether something already answers at `port` — the one test that sees a listener on every address, not just `host`. */
|
|
2
|
+
export declare const portAnswers: (port: number, host: string) => Promise<boolean>;
|
|
3
|
+
/** Whether this process could listen at `port` on `host`. */
|
|
4
|
+
export declare const portBindable: (port: number, host: string) => Promise<boolean>;
|
|
5
|
+
/**
|
|
6
|
+
* The first port from `preferred` up that nothing uses — for a development server, which should start beside
|
|
7
|
+
* whatever else is running rather than refuse to.
|
|
8
|
+
*
|
|
9
|
+
* Free means both that nothing answers there and that this process may listen there: a server bound to every
|
|
10
|
+
* address leaves `127.0.0.1` bindable on some systems, and a page server started beside it would never be reached —
|
|
11
|
+
* the other one would answer, with a `200` that looks like success. A deployment that sets its port does not need
|
|
12
|
+
* this: a fixed port that is taken is an error worth stopping for.
|
|
13
|
+
*/
|
|
14
|
+
export declare const freePort: (preferred: number, host?: string, attempts?: number) => Promise<number>;
|
|
15
|
+
/**
|
|
16
|
+
* A free port as {@link freePort} finds it, held from the other servers starting on this machine until `release`: two
|
|
17
|
+
* development servers started at once both found 8080 free and both bound it — one failed (a run's copies, started by
|
|
18
|
+
* their agents together). Each port taken is a file created only if absent (`wx`), in the system's temporary folder;
|
|
19
|
+
* one left by a process that died is taken again once it is older than a minute.
|
|
20
|
+
*/
|
|
21
|
+
export declare const reservePort: (preferred: number, host?: string, attempts?: number) => Promise<{
|
|
22
|
+
port: number;
|
|
23
|
+
release: () => void;
|
|
24
|
+
}>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type HealthCheckApp = {
|
|
2
|
+
get: (path: string, handler: (...args: any[]) => void) => void;
|
|
3
|
+
};
|
|
4
|
+
export interface HealthIdentity {
|
|
5
|
+
role: string;
|
|
6
|
+
name?: string;
|
|
7
|
+
version?: string;
|
|
8
|
+
instance?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare const buildHealthPayload: (identity?: Partial<HealthIdentity>) => Record<string, unknown>;
|
|
11
|
+
/**
|
|
12
|
+
* Attach the generic /health endpoint to an Express-style app — a deployment whose roles are not all on the sdk-server
|
|
13
|
+
* http pipeline. Servers built on the pipeline get the same endpoint from `healthStage`.
|
|
14
|
+
*
|
|
15
|
+
* `check` is what makes it a readiness probe rather than a liveness one, and it is here for the same reason it is on
|
|
16
|
+
* `healthStage`: a role reports the stores it depends on, and `healthy: false` answers 503 so an orchestrator stops
|
|
17
|
+
* routing to a replica that can serve nothing. Without it the two halves of one deployment answered different
|
|
18
|
+
* questions at the same path — and the Express half's real check ended up as a second, password-guarded endpoint the
|
|
19
|
+
* probes were never pointed at.
|
|
20
|
+
*/
|
|
21
|
+
export declare const registerHealthCheck: (app: HealthCheckApp, identity: HealthIdentity, check?: () => Record<string, unknown> | Promise<Record<string, unknown>>) => void;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export { buildResponseHelpers } from './buildResponseHelpers';
|
|
2
|
+
export { closeOnSignals } from './closeOnSignals';
|
|
3
|
+
export { DEFAULT_COMPRESSION, resolveCompression, selectEncoding, compressBody } from './compress';
|
|
4
|
+
export { makeHandler } from './dispatcher';
|
|
5
|
+
export { SHUTDOWN_GRACE_MS, watchConnections } from './drain';
|
|
6
|
+
export { SHUTDOWN_ANNOUNCE_MS, isStopping, markStopping, shutdownOf } from './stopping';
|
|
7
|
+
export { isFleetMessage, hostable, createStoreHost, createListeners, createFleetClient, createFleetHub } from './fleet/channel';
|
|
8
|
+
export { startHub, fleetStore, channelName, broadcast, onBroadcast } from './fleet/link';
|
|
9
|
+
export { resolveWorkers, fleetWorkerEnv, isFleetWorker, fleetRole, runsFleetJobs } from './fleet/role';
|
|
10
|
+
export { portAnswers, portBindable, freePort, reservePort } from './freePort';
|
|
11
|
+
export { buildHealthPayload, registerHealthCheck } from './health';
|
|
12
|
+
export { authMiddleware } from './middlewares/auth';
|
|
13
|
+
export { basicAuthMiddleware } from './middlewares/basicAuth';
|
|
14
|
+
export { MIME_TYPES, IMMUTABLE_EXTS, getMimeType, getCacheControl } from './mimeTypes';
|
|
15
|
+
export { isNavigation, safeRedirectTarget } from './navigation';
|
|
16
|
+
export { onAbort } from './onAbort';
|
|
17
|
+
export { parseRequest, requestAuthority, requestOrigin, clientIp, forwardedIp, readRawBytes, readRawBody } from './requestParser';
|
|
18
|
+
export { runMiddlewares } from './runMiddlewares';
|
|
19
|
+
export { hstsFor, frameAncestorsOf, applySecurityHeaders } from './securityHeaders';
|
|
20
|
+
export { createHttpServer } from './server';
|
|
21
|
+
export { socketResponse } from './socketResponse';
|
|
22
|
+
export { openEventStream } from './sse';
|
|
23
|
+
export { refusedCrossSite, crossSiteWritesStage } from './stages/crossSiteWrites';
|
|
24
|
+
export { healthStage } from './stages/health';
|
|
25
|
+
export { createMiddlewaresStage } from './stages/middlewares';
|
|
26
|
+
export { publicDirStage, wellKnownStage, configStaticStage } from './stages/static';
|
|
27
|
+
export { serveStatic } from './staticFiles';
|
|
28
|
+
export { tlsOptions, protoLabel, buildTransport } from './transports';
|
|
29
|
+
export { unusedPort } from './unusedPort';
|
|
30
|
+
export { webRequestOf, writeWebResponse } from './webExchange';
|
|
31
|
+
export { frameText } from './wsFrame';
|
|
32
|
+
export type { RawResponse } from './buildResponseHelpers';
|
|
33
|
+
export type { Closable, CloseOnSignalsOptions } from './closeOnSignals';
|
|
34
|
+
export type { ContentEncoding, ResolvedCompression } from './compress';
|
|
35
|
+
export type { BuildContext, HandlerOptions } from './dispatcher';
|
|
36
|
+
export type { FleetCall, FleetReply, FleetBroadcast, FleetMessage, Remote, StoreMethods, HostedStore, StoreHost, FleetClient, FleetPeer, FleetHub } from './fleet/channel';
|
|
37
|
+
export type { FleetStoreName, FleetStores } from './fleet/link';
|
|
38
|
+
export type { WorkersOption, WorkersPlan, FleetRole } from './fleet/role';
|
|
39
|
+
export type { HealthCheckApp, HealthIdentity } from './health';
|
|
40
|
+
export type { BasicAuthOptions } from './middlewares/basicAuth';
|
|
41
|
+
export type { StaticCachePolicy } from './mimeTypes';
|
|
42
|
+
export type { HttpServerParts, HttpServer } from './server';
|
|
43
|
+
export type { UpgradeRequest } from './socketResponse';
|
|
44
|
+
export type { EventStream, EventStreamOptions } from './sse';
|
|
45
|
+
export type { CloseableServer, PrimaryServer, UpgradeHandler, Handler } from './transports';
|
|
46
|
+
export type { BaseContext, Stage } from './types';
|
|
47
|
+
export type { WebResponseSink } from './webExchange';
|
|
48
|
+
export { bearerMatches } from './bearer';
|