@mark1russell7/service 0.5.11 → 0.5.12
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/README.md +18 -1
- package/build/{builder-Dn0cby6Q.d.ts → builder-DawJhq4p.d.ts} +2 -2
- package/build/core-C2wnF4mg.d.ts +183 -0
- package/build/http.d.ts +1 -1
- package/build/index.d.ts +6 -3
- package/build/index.js +155 -11
- package/build/index.js.map +1 -1
- package/build/{lifecycle-CGEegMI0.d.ts → lifecycle-fgYfxrHK.d.ts} +17 -2
- package/build/machine-Czfb6fV4.js +372 -0
- package/build/machine-Czfb6fV4.js.map +1 -0
- package/build/pg.d.ts +230 -0
- package/build/pg.js +534 -0
- package/build/pg.js.map +1 -0
- package/build/redis.d.ts +24 -137
- package/build/redis.js +72 -279
- package/build/redis.js.map +1 -1
- package/build/testing.d.ts +2 -2
- package/package.json +9 -1
package/build/redis.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { t as Backoff } from "./backoff-B-jGWVDm.js";
|
|
2
2
|
import { n as Clock } from "./clock-mVqhXD0b.js";
|
|
3
|
-
import {
|
|
4
|
-
import { n as ServiceBuilder } from "./builder-Dn0cby6Q.js";
|
|
3
|
+
import { tt as heartbeatDetection, wt as Operation } from "./lifecycle-fgYfxrHK.js";
|
|
5
4
|
import { n as LimiterStore } from "./store-D5HLgBnW.js";
|
|
5
|
+
import { _ as Manifestation, a as ClientKnobs, b as firstDetector, c as ClientSpec, d as Factory, g as MANIFESTATIONS, h as Detector, i as ClientJoin, l as ClientStep, m as Sent, n as CheckOptions, o as ClientOptions, p as SendOptions, r as Client, s as ClientSocket, t as Attempt, u as DialFn, v as Meeting, x as unwatched, y as Situation } from "./core-C2wnF4mg.js";
|
|
6
6
|
import { Extent, Quantity } from "@mark1russell7/quantity";
|
|
7
7
|
import { Machine } from "@mark1russell7/algebra";
|
|
8
8
|
//#region src/redis/connection.d.ts
|
|
@@ -24,15 +24,8 @@ interface RedisConnection {
|
|
|
24
24
|
on(event: string, listener: (...args: unknown[]) => void): unknown;
|
|
25
25
|
off(event: string, listener: (...args: unknown[]) => void): unknown;
|
|
26
26
|
}
|
|
27
|
-
/** A Redis socket is the
|
|
28
|
-
|
|
29
|
-
readonly localAddress?: string | undefined;
|
|
30
|
-
readonly localPort?: number | undefined;
|
|
31
|
-
readonly remoteAddress?: string | undefined;
|
|
32
|
-
readonly remotePort?: number | undefined;
|
|
33
|
-
/** This method closes the socket at once. A disconnect only half-closes it, and a silent peer does not answer that. */
|
|
34
|
-
destroy?(): void;
|
|
35
|
-
}
|
|
27
|
+
/** A Redis socket is the socket of a client in the core: the join of the prober and the bounded close read it. */
|
|
28
|
+
type RedisSocket = ClientSocket;
|
|
36
29
|
/**
|
|
37
30
|
* These are the options that the wrapper gives ioredis. Each one comes from the declaration. The
|
|
38
31
|
* wrapper sets each option that has an effect on a timer or on a send again, thus no default of
|
|
@@ -63,67 +56,26 @@ interface RedisConnectionOptions {
|
|
|
63
56
|
readonly retryStrategy: (times: number) => number | null;
|
|
64
57
|
}
|
|
65
58
|
/** A connection factory makes the connection of the client from its options. */
|
|
66
|
-
type ConnectionFactory =
|
|
59
|
+
type ConnectionFactory = Factory<RedisConnectionOptions, RedisConnection>;
|
|
67
60
|
/**
|
|
68
61
|
* This factory makes an ioredis client. It loads ioredis only when a client connects, thus a
|
|
69
62
|
* service that does not use Redis does not need ioredis.
|
|
70
63
|
*/
|
|
71
64
|
export declare const ioredis: ConnectionFactory;
|
|
72
65
|
//#endregion
|
|
73
|
-
//#region src/redis/meets.d.ts
|
|
74
|
-
/** A situation is what the connection did when the failure started: a command in flight, or idle. */
|
|
75
|
-
type Situation = "in flight" | "idle";
|
|
76
|
-
/** A detector is a mechanism that finds a failure, and the most time that it takes. */
|
|
77
|
-
interface Detector {
|
|
78
|
-
/** This name identifies the mechanism: a knob of the declaration, or the kernel. */
|
|
79
|
-
readonly by: string;
|
|
80
|
-
/** This time is the most that the detector takes, after the failure starts. "infinite" tells that it does not find the failure. */
|
|
81
|
-
readonly within: Extent;
|
|
82
|
-
readonly situation: Situation;
|
|
83
|
-
/** This text tells what the detector does, for example that it fails a command without a change of state. */
|
|
84
|
-
readonly effect: string;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* A meeting is a manifestation that the client can meet, and its detectors (E9). The names of the
|
|
88
|
-
* manifestations are the names of the vocabulary of the harness and the corpus. `app-stall` is a
|
|
89
|
-
* server whose process is alive and does not answer, a proposal of the vocabulary.
|
|
90
|
-
*/
|
|
91
|
-
interface Meeting {
|
|
92
|
-
readonly manifestation: string;
|
|
93
|
-
/** This text tells the failure in words. */
|
|
94
|
-
readonly what: string;
|
|
95
|
-
readonly detectors: readonly Detector[];
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* This function gives the manifestations that a Redis client can meet, and the detectors of each, from
|
|
99
|
-
* its knobs. A reset or a FIN arrives on the next segment. A black hole and a host that is gone give
|
|
100
|
-
* no answer at all. A frozen process and a stalled server keep a kernel that acknowledges each
|
|
101
|
-
* segment. Thus TCP keepalive does not fire on them, and only the client's own timers find them.
|
|
102
|
-
*/
|
|
103
|
-
export declare const meetings: (name: string, knobs: RedisKnobs, heartbeat: Extent) => Meeting[];
|
|
104
|
-
/** This function gives the first detector of a manifestation in a situation, or null when no detector has an end (C3). */
|
|
105
|
-
export declare const firstDetector: (meeting: Meeting, situation: Situation) => Detector | null;
|
|
106
|
-
/** This function gives each manifestation and situation that no detector of the client finds: the standing rule, as a query (C3, E9). */
|
|
107
|
-
export declare const unwatched: (meets: readonly Meeting[]) => Array<{
|
|
108
|
-
readonly manifestation: string;
|
|
109
|
-
readonly situation: Situation;
|
|
110
|
-
}>;
|
|
111
|
-
//#endregion
|
|
112
66
|
//#region src/redis/client.d.ts
|
|
113
67
|
/**
|
|
114
68
|
* These are the knobs of the client, each a time, by the names of the ordering law where the law
|
|
115
69
|
* has them. The runtime has no defaults, thus each knob is necessary, and a bound that nobody gives
|
|
116
|
-
* is "infinite", not zero.
|
|
70
|
+
* is "infinite", not zero. The knobs that each client has come from the core.
|
|
117
71
|
*/
|
|
118
|
-
interface RedisKnobs {
|
|
72
|
+
interface RedisKnobs extends ClientKnobs {
|
|
119
73
|
/** This time bounds a try to connect, until the TCP connection exists (`connectTimeout`). */
|
|
120
74
|
readonly connect_bound: Quantity;
|
|
121
75
|
/** This time bounds each command, the handshake commands too (`commandTimeout`). */
|
|
122
76
|
readonly request_timeout: Quantity;
|
|
123
77
|
/** This time destroys a socket that gives no data while a command waits (`socketTimeout`). */
|
|
124
78
|
readonly driver_writeoff_time: Extent;
|
|
125
|
-
/** This time is the idle time of TCP keepalive. Node then sends 10 probes 1 s apart. */
|
|
126
|
-
readonly keepalive_idle: Extent;
|
|
127
79
|
/** This time is the interval of the in-band watchdog: a PING on the connection of the application. */
|
|
128
80
|
readonly heartbeat_interval: Extent;
|
|
129
81
|
/** This time bounds each PING of the watchdog. */
|
|
@@ -138,37 +90,17 @@ interface RedisKnobs {
|
|
|
138
90
|
readonly close_bound: Quantity;
|
|
139
91
|
/** This time is the age at which the client replaces its connection. The client supports only "infinite". */
|
|
140
92
|
readonly max_connection_age: Extent;
|
|
141
|
-
/**
|
|
142
|
-
* This time is when the kernel gives up a segment that it retransmits. Node cannot set it, thus
|
|
143
|
-
* the declaration states it for the ordering law (O17), from the platform.
|
|
144
|
-
*/
|
|
145
|
-
readonly retrans_giveup_time: Extent;
|
|
146
93
|
}
|
|
147
94
|
/** A Redis client spec is the declaration of one Redis client: where it connects, and its knobs. */
|
|
148
|
-
interface RedisClientSpec {
|
|
149
|
-
readonly host: string;
|
|
150
|
-
readonly port: number;
|
|
95
|
+
interface RedisClientSpec extends ClientSpec<RedisKnobs> {
|
|
151
96
|
readonly db?: number | undefined;
|
|
152
97
|
readonly username?: string | undefined;
|
|
153
|
-
readonly password?: string | undefined;
|
|
154
|
-
/** This identifier is the component in the corpus (`systems.component.redis`), or null. */
|
|
155
|
-
readonly system: string | null;
|
|
156
|
-
readonly knobs: RedisKnobs;
|
|
157
98
|
/** This count is the number of PINGs in sequence without an answer that make the watchdog connect again. */
|
|
158
99
|
readonly heartbeatMisses: number;
|
|
159
|
-
/** These operations add to the table of the client, or change it. */
|
|
160
|
-
readonly operations?: Readonly<Record<string, Operation>> | undefined;
|
|
161
100
|
}
|
|
162
|
-
/** A dial function opens a new TCP connection, sends one PING, and reads the reply. The `dial` check uses it. */
|
|
163
|
-
type DialFn = (host: string, port: number, signal: AbortSignal) => Promise<void>;
|
|
164
101
|
/** These options make a client. Without them, it uses ioredis, the real clock and `Math.random`. */
|
|
165
|
-
interface RedisClientOptions {
|
|
166
|
-
readonly create?: ConnectionFactory | undefined;
|
|
167
|
-
readonly clock?: Clock | undefined;
|
|
102
|
+
interface RedisClientOptions extends ClientOptions<ConnectionFactory> {
|
|
168
103
|
readonly random?: (() => number) | undefined;
|
|
169
|
-
/** This function receives each transition of the client, for the prober (D3). */
|
|
170
|
-
readonly record?: Recorder | undefined;
|
|
171
|
-
readonly dial?: DialFn | undefined;
|
|
172
104
|
/**
|
|
173
105
|
* This function waits one turn of the event loop. The watchdog waits it before it counts a miss,
|
|
174
106
|
* thus a reply that is in the socket is read first. Without it, the client uses `setImmediate`.
|
|
@@ -180,65 +112,14 @@ interface RedisClientOptions {
|
|
|
180
112
|
* records to the server's view of the connection through it. A join holds the server's id of the
|
|
181
113
|
* connection, and the local address and port of the socket.
|
|
182
114
|
*/
|
|
183
|
-
interface Join {
|
|
184
|
-
readonly generation: number;
|
|
185
|
-
/** This time is when the connection became ready, in milliseconds on the monotonic clock. */
|
|
186
|
-
readonly at: number;
|
|
115
|
+
interface Join extends ClientJoin {
|
|
187
116
|
/** This number is the reply of CLIENT ID, or null when the server gave none. */
|
|
188
117
|
readonly clientId: number | null;
|
|
189
|
-
readonly localAddress: string | null;
|
|
190
|
-
readonly localPort: number | null;
|
|
191
|
-
readonly remoteAddress: string | null;
|
|
192
|
-
readonly remotePort: number | null;
|
|
193
|
-
}
|
|
194
|
-
/**
|
|
195
|
-
* A sent result is the outcome of a command, in three values (C8):
|
|
196
|
-
* - `ok`: the server answered.
|
|
197
|
-
* - `error`: the command did not apply. The server answered with an error (`reply`), or the command
|
|
198
|
-
* did not leave the client.
|
|
199
|
-
* - `indeterminate`: the command can have reached the server, and nothing tells if it applied.
|
|
200
|
-
*/
|
|
201
|
-
type Sent<T> = {
|
|
202
|
-
readonly outcome: "ok";
|
|
203
|
-
readonly value: T;
|
|
204
|
-
readonly attempts: number;
|
|
205
|
-
} | {
|
|
206
|
-
readonly outcome: "error";
|
|
207
|
-
readonly error: string;
|
|
208
|
-
readonly reply: boolean;
|
|
209
|
-
readonly attempts: number;
|
|
210
|
-
} | {
|
|
211
|
-
readonly outcome: "indeterminate";
|
|
212
|
-
readonly error: string;
|
|
213
|
-
readonly attempts: number;
|
|
214
|
-
};
|
|
215
|
-
/** Send options tell how the client sends one command. */
|
|
216
|
-
interface SendOptions {
|
|
217
|
-
/** This signal abandons the command. A command that left the client is then indeterminate. */
|
|
218
|
-
readonly signal?: AbortSignal | undefined;
|
|
219
|
-
/** False stops the client: it does not send the command again. A check that must fail at once uses it. */
|
|
220
|
-
readonly reissue?: boolean | undefined;
|
|
221
|
-
}
|
|
222
|
-
/** The steps of a connection that the client gives a check for (B14). */
|
|
223
|
-
type ClientStep = Extract<Step, "dial" | "round-trip" | "local-state">;
|
|
224
|
-
/** Check options tell which checks the client gives the health runtime, and which policy each one controls. */
|
|
225
|
-
interface CheckOptions {
|
|
226
|
-
readonly poll: Poll;
|
|
227
|
-
/** For each step, the policy that its check controls, or null for a check that only reports. A step that is absent has no check. */
|
|
228
|
-
readonly steps: Partial<Record<ClientStep, Gate | null>>;
|
|
229
118
|
}
|
|
230
119
|
/** A Redis client is a dependency of a service: its declaration, its handle, its checks and its commands. */
|
|
231
|
-
interface RedisClient {
|
|
232
|
-
readonly name: string;
|
|
233
|
-
/** This declaration goes to `svc.dependency(name, declaration, handle)`. */
|
|
234
|
-
readonly declaration: Omit<Dependency, "name">;
|
|
235
|
-
readonly handle: DependencyHandle;
|
|
236
|
-
/** These are the manifestations that the client can meet, and the detector of each (E9). */
|
|
237
|
-
readonly meets: readonly Meeting[];
|
|
120
|
+
interface RedisClient extends Client<ClientStep, Join> {
|
|
238
121
|
/** This text is the state of the connection, as ioredis names it, or "none" before the connect. */
|
|
239
122
|
readonly status: string;
|
|
240
|
-
/** These are the generations of the connection, the latest last. */
|
|
241
|
-
readonly joins: readonly Join[];
|
|
242
123
|
/**
|
|
243
124
|
* This method sends a command, and gives its outcome in three values. The client sends again
|
|
244
125
|
* only an idempotent operation, one time at most, after an outcome that is not certain. The
|
|
@@ -246,12 +127,6 @@ interface RedisClient {
|
|
|
246
127
|
* the table does not name.
|
|
247
128
|
*/
|
|
248
129
|
send<T = unknown>(command: string, args?: ReadonlyArray<string | number>, options?: SendOptions): Promise<Sent<T>>;
|
|
249
|
-
/** This method gives the checks of the client and their functions, for `svc.check(check, run)`. */
|
|
250
|
-
checks(options: CheckOptions): ReadonlyArray<readonly [Check, CheckFn]>;
|
|
251
|
-
/** This method declares the client in a service: its dependency, its handle and its checks. */
|
|
252
|
-
attach(svc: ServiceBuilder, options: CheckOptions): ServiceBuilder;
|
|
253
|
-
/** This method gives the problems of the client in a description: a close that does not fit in its phase, for example. */
|
|
254
|
-
problems(description: ServiceDescription): string[];
|
|
255
130
|
}
|
|
256
131
|
/**
|
|
257
132
|
* This function gives the backoff of the tries to connect: from `retry_base`, doubling to
|
|
@@ -271,9 +146,21 @@ export declare const tcpDial: DialFn;
|
|
|
271
146
|
* - It records the server's id of each connection at `ready` (D1).
|
|
272
147
|
* - A watchdog sends a PING in the band of the connection, and it connects again after the misses
|
|
273
148
|
* of the declaration. It also starts a client that stopped (principle 19).
|
|
149
|
+
*
|
|
150
|
+
* The outcomes, the second try, the commands in flight, the bounded close and the checks come
|
|
151
|
+
* from the core of the clients. This entry gives what ioredis does in its own way.
|
|
274
152
|
*/
|
|
275
153
|
export declare const redisClient: (name: string, spec: RedisClientSpec, options?: RedisClientOptions) => RedisClient;
|
|
276
154
|
//#endregion
|
|
155
|
+
//#region src/redis/meets.d.ts
|
|
156
|
+
/**
|
|
157
|
+
* This function gives the manifestations that a Redis client can meet, and the detectors of each, from
|
|
158
|
+
* its knobs. A reset or a FIN arrives on the next segment. A black hole and a host that is gone give
|
|
159
|
+
* no answer at all. A frozen process and a stalled server keep a kernel that acknowledges each
|
|
160
|
+
* segment. Thus TCP keepalive does not fire on them, and only the client's own timers find them.
|
|
161
|
+
*/
|
|
162
|
+
export declare const meetings: (name: string, knobs: RedisKnobs, heartbeat: Extent) => Meeting[];
|
|
163
|
+
//#endregion
|
|
277
164
|
//#region src/redis/limiter.d.ts
|
|
278
165
|
/**
|
|
279
166
|
* This script decides one take in one atomic step of Redis. It does the arithmetic of `decide`, and
|
|
@@ -332,5 +219,5 @@ export declare const REDIS_OPERATIONS: Readonly<Record<string, Operation>>;
|
|
|
332
219
|
/** This function gives the name of a command as the table writes it: upper case, and CLIENT ID with its subcommand. */
|
|
333
220
|
export declare const commandName: (command: string, args: readonly unknown[]) => string;
|
|
334
221
|
//#endregion
|
|
335
|
-
export { type CheckOptions, type ClientStep, type ConnectionFactory, type Detector, type DialFn, type Join, type Meeting, type RedisClient, type RedisClientOptions, type RedisClientSpec, type RedisConnection, type RedisConnectionOptions, type RedisKnobs, type RedisLimiterOptions, type RedisSender, type RedisSocket, type Sent, type Situation, heartbeatDetection };
|
|
222
|
+
export { type Attempt, type CheckOptions, type Client, type ClientJoin, type ClientKnobs, type ClientOptions, type ClientSocket, type ClientSpec, type ClientStep, type ConnectionFactory, type Detector, type DialFn, type Factory, type Join, MANIFESTATIONS, type Manifestation, type Meeting, type RedisClient, type RedisClientOptions, type RedisClientSpec, type RedisConnection, type RedisConnectionOptions, type RedisKnobs, type RedisLimiterOptions, type RedisSender, type RedisSocket, type Sent, type Situation, firstDetector, heartbeatDetection, unwatched };
|
|
336
223
|
//# sourceMappingURL=redis.d.ts.map
|