@cronwatch/sdk 0.9.0 → 0.11.0
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 +4 -4
- package/dist/anthropic.d.cts +1 -1
- package/dist/anthropic.d.ts +1 -1
- package/dist/bugsnag.d.cts +1 -1
- package/dist/bugsnag.d.ts +1 -1
- package/dist/{client-D35cfnNV.d.cts → client-CRMfhylq.d.cts} +129 -37
- package/dist/{client-CQm-8-mR.d.ts → client-D2Xk2600.d.ts} +129 -37
- package/dist/d1.cjs +29 -11
- package/dist/d1.cjs.map +1 -1
- package/dist/d1.d.cts +1 -1
- package/dist/d1.d.ts +1 -1
- package/dist/d1.js +29 -11
- package/dist/d1.js.map +1 -1
- package/dist/datadog.d.cts +1 -1
- package/dist/datadog.d.ts +1 -1
- package/dist/discord.cjs +25 -4
- package/dist/discord.cjs.map +1 -1
- package/dist/discord.d.cts +20 -4
- package/dist/discord.d.ts +20 -4
- package/dist/discord.js +22 -3
- package/dist/discord.js.map +1 -1
- package/dist/{email-BxCp9RQV.d.ts → email-BWuUiCkw.d.ts} +1 -1
- package/dist/{email-D1d5niMy.d.cts → email-Dcqe3k8n.d.cts} +1 -1
- package/dist/honeybadger.d.cts +1 -1
- package/dist/honeybadger.d.ts +1 -1
- package/dist/index.cjs +380 -123
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +15 -9
- package/dist/index.d.ts +15 -9
- package/dist/index.js +379 -124
- package/dist/index.js.map +1 -1
- package/dist/mailgun.d.cts +2 -2
- package/dist/mailgun.d.ts +2 -2
- package/dist/newrelic.d.cts +1 -1
- package/dist/newrelic.d.ts +1 -1
- package/dist/pg-cron.cjs +19 -8
- package/dist/pg-cron.cjs.map +1 -1
- package/dist/pg-cron.d.cts +15 -12
- package/dist/pg-cron.d.ts +15 -12
- package/dist/pg-cron.js +16 -5
- package/dist/pg-cron.js.map +1 -1
- package/dist/postgres.cjs +28 -10
- package/dist/postgres.cjs.map +1 -1
- package/dist/postgres.d.cts +1 -1
- package/dist/postgres.d.ts +1 -1
- package/dist/postgres.js +28 -10
- package/dist/postgres.js.map +1 -1
- package/dist/postmark.d.cts +2 -2
- package/dist/postmark.d.ts +2 -2
- package/dist/resend.d.cts +2 -2
- package/dist/resend.d.ts +2 -2
- package/dist/rollbar.d.cts +1 -1
- package/dist/rollbar.d.ts +1 -1
- package/dist/sendgrid.d.cts +2 -2
- package/dist/sendgrid.d.ts +2 -2
- package/dist/sentry.cjs +4 -1
- package/dist/sentry.cjs.map +1 -1
- package/dist/sentry.d.cts +5 -2
- package/dist/sentry.d.ts +5 -2
- package/dist/sentry.js +4 -1
- package/dist/sentry.js.map +1 -1
- package/dist/ses.d.cts +2 -2
- package/dist/ses.d.ts +2 -2
- package/dist/slack.d.cts +1 -1
- package/dist/slack.d.ts +1 -1
- package/dist/sqlite.cjs +29 -11
- package/dist/sqlite.cjs.map +1 -1
- package/dist/sqlite.d.cts +1 -1
- package/dist/sqlite.d.ts +1 -1
- package/dist/sqlite.js +29 -11
- package/dist/sqlite.js.map +1 -1
- package/dist/twilio.cjs +10 -4
- package/dist/twilio.cjs.map +1 -1
- package/dist/twilio.d.cts +12 -7
- package/dist/twilio.d.ts +12 -7
- package/dist/twilio.js +7 -1
- package/dist/twilio.js.map +1 -1
- package/dist/{types-Cz47Boks.d.cts → types-DLnlUie8.d.cts} +18 -2
- package/dist/{types-Cz47Boks.d.ts → types-DLnlUie8.d.ts} +18 -2
- package/dist/webhook.cjs +10 -5
- package/dist/webhook.cjs.map +1 -1
- package/dist/webhook.d.cts +18 -7
- package/dist/webhook.d.ts +18 -7
- package/dist/webhook.js +10 -6
- package/dist/webhook.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -25,7 +25,7 @@ export const nightlyReport = cw.job("nightly-report", {
|
|
|
25
25
|
schedule: "0 2 * * *", // cron, "@hourly", or "every 15m"
|
|
26
26
|
timezone: "UTC",
|
|
27
27
|
grace: "15m", // how late a start may be before it is missed
|
|
28
|
-
timeout: "30m", // a run still going after this is stuck
|
|
28
|
+
timeout: "30m", // a run still going after this is stuck (maxDuration: a finished run longer than it is slow)
|
|
29
29
|
expect: "Report written", // output must contain this, or the run failed
|
|
30
30
|
budget: { cost: 2 }, // cost above 2 is over budget
|
|
31
31
|
});
|
|
@@ -57,7 +57,7 @@ export const { GET, POST, DELETE } = cw.routes();
|
|
|
57
57
|
await nightlyReport.run(async (job) => { /* ... */ });
|
|
58
58
|
|
|
59
59
|
// Missed and stuck runs are found by the check: on an interval, or a cron hitting /cronwatch/api/check
|
|
60
|
-
cw.
|
|
60
|
+
cw.startChecking();
|
|
61
61
|
```
|
|
62
62
|
|
|
63
63
|
## What it catches
|
|
@@ -77,13 +77,13 @@ An `expect` RegExp runs in your process on the runtime's own engine and, like an
|
|
|
77
77
|
|
|
78
78
|
| Import | |
|
|
79
79
|
|---|---|
|
|
80
|
-
| `@cronwatch/sdk` | `cronwatch`, `memory`, `custom`, `consoleChannel`, `
|
|
80
|
+
| `@cronwatch/sdk` | `cronwatch`, `Cronwatch`, `memory`, `custom`, `consoleChannel`, types; the dashboard is `cw.routes()` |
|
|
81
81
|
| `@cronwatch/sdk/sqlite` | `sqlite({ path })`, needs `better-sqlite3` (and `@types/better-sqlite3` in TypeScript) |
|
|
82
82
|
| `@cronwatch/sdk/postgres` | `postgres({ connectionString })`, needs `pg` (and `@types/pg` in TypeScript) |
|
|
83
83
|
| `@cronwatch/sdk/d1` | `d1(env.DB)`, the Cloudflare D1 store; needs nothing |
|
|
84
84
|
| `@cronwatch/sdk/pg-cron` | `pgCron(pool)`, a source that reads pg_cron jobs (Supabase Cron included) from Postgres on every check; pass it in `sources` |
|
|
85
85
|
| `@cronwatch/sdk/node` | `toNodeHandler`, `toKoaMiddleware`, `toRequest`, `writeResponse`: fetch handlers on `http.createServer`, Express, Connect, NestJS and Koa |
|
|
86
|
-
| `@cronwatch/sdk/slack`, `/discord`, `/webhook` | chat and signed webhook alert channels |
|
|
86
|
+
| `@cronwatch/sdk/slack`, `/discord`, `/webhook` | chat and signed webhook alert channels; `/webhook` also has `signature(secret, body)` for a receiver |
|
|
87
87
|
| `@cronwatch/sdk/resend`, `/postmark`, `/sendgrid`, `/mailgun`, `/ses` | email alert channels |
|
|
88
88
|
| `@cronwatch/sdk/twilio` | SMS alerts |
|
|
89
89
|
| `@cronwatch/sdk/sentry`, `/honeybadger`, `/datadog`, `/rollbar`, `/bugsnag`, `/newrelic` | alerts as events in an error tracker |
|
package/dist/anthropic.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Anthropic from '@anthropic-ai/sdk';
|
|
2
|
-
import {
|
|
2
|
+
import { o as TriageFn } from './types-DLnlUie8.cjs';
|
|
3
3
|
|
|
4
4
|
interface AnthropicTriageOptions {
|
|
5
5
|
/** Defaults to what the Anthropic SDK resolves: ANTHROPIC_API_KEY, or an `ant auth login` profile. */
|
package/dist/anthropic.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Anthropic from '@anthropic-ai/sdk';
|
|
2
|
-
import {
|
|
2
|
+
import { o as TriageFn } from './types-DLnlUie8.js';
|
|
3
3
|
|
|
4
4
|
interface AnthropicTriageOptions {
|
|
5
5
|
/** Defaults to what the Anthropic SDK resolves: ANTHROPIC_API_KEY, or an `ant auth login` profile. */
|
package/dist/bugsnag.d.cts
CHANGED
package/dist/bugsnag.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { J as JobOptions, R as Run, A as Alert, S as Store, a as AlertChannel, o as TriageFn, D as Duration, h as JobDefinition, f as CheckResult, k as JobSummary, j as JobState } from './types-DLnlUie8.cjs';
|
|
2
2
|
|
|
3
3
|
/** What a job function receives. */
|
|
4
4
|
interface JobContext {
|
|
@@ -19,10 +19,14 @@ interface RoutesOptions {
|
|
|
19
19
|
* Required to reach anything. Send it as `Authorization: Bearer <token>`,
|
|
20
20
|
* or open the dashboard once with `?token=<token>` and a cookie is set.
|
|
21
21
|
* Defaults to process.env.CRONWATCH_TOKEN (on Cloudflare Workers, which
|
|
22
|
-
* have no process, pass env.CRONWATCH_TOKEN); an empty string
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
22
|
+
* have no process, pass env.CRONWATCH_TOKEN); an empty string or one of
|
|
23
|
+
* only whitespace, given here or in the variable, counts as unset, and any
|
|
24
|
+
* other type (false, a number) throws.
|
|
25
|
+
* With no token in development (the first of CRONWATCH_ENV, APP_ENV and
|
|
26
|
+
* NODE_ENV that is set names "development", "dev", "local", "test" or
|
|
27
|
+
* "testing"), the routes make a random one and print a sign-in link to the
|
|
28
|
+
* server log on their first request; with no token otherwise they answer
|
|
29
|
+
* 503. Pass `null` to opt out
|
|
26
30
|
* and serve them open everywhere, for example behind your own auth.
|
|
27
31
|
*
|
|
28
32
|
* The check endpoint (/api/check) also accepts the client's cronSecret, so
|
|
@@ -62,12 +66,11 @@ interface Routes {
|
|
|
62
66
|
DELETE: FetchHandler;
|
|
63
67
|
}
|
|
64
68
|
/**
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
* export const { GET, POST, DELETE } = cw.routes();
|
|
69
|
+
* The dashboard and its JSON API for a client.
|
|
70
|
+
* @deprecated Use `cw.routes(options)`, the one way to mount the dashboard
|
|
71
|
+
* in every port. This name still works through 1.x and goes in 2.0.
|
|
69
72
|
*/
|
|
70
|
-
declare function createRoutes(cw:
|
|
73
|
+
declare function createRoutes(cw: Cronwatch, options?: RoutesOptions): Routes;
|
|
71
74
|
|
|
72
75
|
type JobFn<T> = (job: JobContext) => Promise<T> | T;
|
|
73
76
|
type HandlerFn<T> = (job: JobContext, request: Request) => Promise<T> | T;
|
|
@@ -75,9 +78,12 @@ interface HandlerOptions {
|
|
|
75
78
|
/**
|
|
76
79
|
* Callers must send `Authorization: Bearer <secret>`. Defaults to the
|
|
77
80
|
* client's cronSecret, which defaults to process.env.CRON_SECRET (what
|
|
78
|
-
* Vercel sends its cron requests with). An empty string
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
+
* Vercel sends its cron requests with). An empty string, or one of only
|
|
82
|
+
* whitespace, counts as unset; any other type (false, a number) throws.
|
|
83
|
+
* With no secret at all the handler answers 503 unless the app is in
|
|
84
|
+
* development (the first of CRONWATCH_ENV, APP_ENV and NODE_ENV that is
|
|
85
|
+
* set names "development", "dev", "local", "test" or "testing"). Pass
|
|
86
|
+
* null to allow anyone.
|
|
81
87
|
*/
|
|
82
88
|
secret?: string | null;
|
|
83
89
|
}
|
|
@@ -162,12 +168,21 @@ interface RunHandle {
|
|
|
162
168
|
}
|
|
163
169
|
/**
|
|
164
170
|
* What a Source may use of the client: declare jobs, read the store, and
|
|
165
|
-
* record runs it found elsewhere. A
|
|
171
|
+
* record runs it found elsewhere. A Cronwatch is one.
|
|
166
172
|
*/
|
|
167
173
|
interface SourceHost {
|
|
168
|
-
/** Declare a job, as
|
|
174
|
+
/** Declare a job, as Cronwatch.job(). Throws for an invalid name or option. */
|
|
169
175
|
job(name: string, options?: JobOptions): unknown;
|
|
170
|
-
/**
|
|
176
|
+
/**
|
|
177
|
+
* The definitions declared now, as Cronwatch.definedJobs(): a source reads
|
|
178
|
+
* it to declare again a job forgotten since (the dashboard's forget), whose
|
|
179
|
+
* definition has not changed. A host without it is taken to keep every
|
|
180
|
+
* job the source declared.
|
|
181
|
+
*/
|
|
182
|
+
definedJobs?(): {
|
|
183
|
+
name: string;
|
|
184
|
+
}[];
|
|
185
|
+
/** See Cronwatch.recordRun(). */
|
|
171
186
|
recordRun(run: Run, options?: RecordRunOptions): Promise<Alert[]>;
|
|
172
187
|
readonly store: Store;
|
|
173
188
|
readonly now: () => number;
|
|
@@ -187,7 +202,7 @@ interface RecordRunOptions {
|
|
|
187
202
|
/** False stores the run without evaluating it, for history imported on first sight. Default true. */
|
|
188
203
|
evaluate?: boolean;
|
|
189
204
|
}
|
|
190
|
-
interface
|
|
205
|
+
interface CronwatchOptions {
|
|
191
206
|
/** Where jobs, runs and state live. Defaults to an in-memory store that forgets on restart. */
|
|
192
207
|
store?: Store;
|
|
193
208
|
/**
|
|
@@ -203,8 +218,9 @@ interface CronWatchOptions {
|
|
|
203
218
|
/**
|
|
204
219
|
* Shared secret that handler() requests must carry. Defaults to
|
|
205
220
|
* process.env.CRON_SECRET (on Cloudflare Workers, which have no process,
|
|
206
|
-
* pass env.CRON_SECRET); an empty string
|
|
207
|
-
* let handlers run
|
|
221
|
+
* pass env.CRON_SECRET); an empty string or one of only whitespace, given
|
|
222
|
+
* here or in the variable, counts as unset. Pass null to let handlers run
|
|
223
|
+
* without one. Any other type (false, a number) throws.
|
|
208
224
|
*/
|
|
209
225
|
cronSecret?: string | null;
|
|
210
226
|
/** How long finished runs are kept. Default "30d". */
|
|
@@ -234,7 +250,7 @@ interface CronWatchOptions {
|
|
|
234
250
|
/** The clock. Tests use this. */
|
|
235
251
|
now?: () => number;
|
|
236
252
|
}
|
|
237
|
-
declare class
|
|
253
|
+
declare class Cronwatch {
|
|
238
254
|
readonly store: Store;
|
|
239
255
|
readonly alerts: AlertChannel[];
|
|
240
256
|
readonly triage: TriageFn | undefined;
|
|
@@ -247,7 +263,7 @@ declare class CronWatch {
|
|
|
247
263
|
/** cronSecret was passed as null: handlers may run without a secret. */
|
|
248
264
|
private readonly secretOptOut;
|
|
249
265
|
private readonly redact;
|
|
250
|
-
/** "check": queue alerts for another process's check instead of sending them. See
|
|
266
|
+
/** "check": queue alerts for another process's check instead of sending them. See CronwatchOptions.deliver. */
|
|
251
267
|
private readonly deferDelivery;
|
|
252
268
|
private readonly defaults;
|
|
253
269
|
private readonly definitions;
|
|
@@ -266,7 +282,9 @@ declare class CronWatch {
|
|
|
266
282
|
private usingDefaultStore;
|
|
267
283
|
private warnedNoSecret;
|
|
268
284
|
private warnedDeferredStart;
|
|
269
|
-
|
|
285
|
+
/** Stored jobs read with a definition that was not a JSON object (see readJob). */
|
|
286
|
+
private readonly unreadable;
|
|
287
|
+
constructor(options?: CronwatchOptions);
|
|
270
288
|
/** Declare a job. Call it once, at module level, and keep the handle. */
|
|
271
289
|
job(name: string, options?: JobOptions): JobHandle;
|
|
272
290
|
/** Run a job by name without keeping a handle. Defines it on first use. */
|
|
@@ -287,9 +305,27 @@ declare class CronWatch {
|
|
|
287
305
|
* that replaced it, never its own over it, and one forgotten since writes
|
|
288
306
|
* its own. The writes of one name take turns, in the order they were asked
|
|
289
307
|
* for, so one still under way cannot land after a later one; and a name
|
|
290
|
-
* declared again while its write was under way is still to be written.
|
|
308
|
+
* declared again while its write was under way is still to be written. A
|
|
309
|
+
* name is marked as written only while that same declaration stands, so a
|
|
310
|
+
* forget that lands during the write (deleting the row after it) leaves
|
|
311
|
+
* the name to be written again, as does one forgotten before it.
|
|
312
|
+
*
|
|
313
|
+
* With `confirm`, as a run starts, a name already written is read back:
|
|
314
|
+
* another process may have forgotten the job since, and a job still
|
|
315
|
+
* declared here comes back on its next run.
|
|
291
316
|
*/
|
|
292
317
|
private sync;
|
|
318
|
+
/**
|
|
319
|
+
* Every stored job, once each declaration has been written. A job declared
|
|
320
|
+
* here that the store no longer has was forgotten by another process after
|
|
321
|
+
* this one wrote it: it is written again, as its next run would, so it is
|
|
322
|
+
* checked and shown while any process still declares it.
|
|
323
|
+
*/
|
|
324
|
+
private storedJobs;
|
|
325
|
+
/** A stored job read leniently (readStoredJob); one whose definition is unreadable is remembered, so that evaluating it throws. */
|
|
326
|
+
private readJob;
|
|
327
|
+
/** Throws for a job whose stored definition was not a JSON object: reported, and shown as failing, while the others carry on. */
|
|
328
|
+
private evaluable;
|
|
293
329
|
/**
|
|
294
330
|
* Runs `fn` after every earlier state update for the same job has settled,
|
|
295
331
|
* so two runs (or a run and a check) in this process never read and write
|
|
@@ -321,7 +357,8 @@ declare class CronWatch {
|
|
|
321
357
|
private execute;
|
|
322
358
|
/**
|
|
323
359
|
* Sets a finished run's status and error from how it ended, then redacts
|
|
324
|
-
* its output and error. Shared by execute()
|
|
360
|
+
* its output and error and caps them, in that order. Shared by execute()
|
|
361
|
+
* and RunHandle.finish().
|
|
325
362
|
*/
|
|
326
363
|
private conclude;
|
|
327
364
|
/**
|
|
@@ -374,17 +411,28 @@ declare class CronWatch {
|
|
|
374
411
|
* alone and reported. A finished run is judged as if it had been wrapped
|
|
375
412
|
* here (expect, failures, duration, budgets) and its output and error are
|
|
376
413
|
* redacted the same way; one finishing after a check marked it timeout is
|
|
377
|
-
* judged only when it succeeded, as RunHandle.finish() does.
|
|
378
|
-
*
|
|
414
|
+
* judged only when it succeeded, as RunHandle.finish() does. A metric that
|
|
415
|
+
* is not a finite number throws before anything is written, as
|
|
416
|
+
* job.metric() does. Returns the alerts it sent.
|
|
379
417
|
*/
|
|
380
418
|
recordRun(input: Run, options?: RecordRunOptions): Promise<Alert[]>;
|
|
381
419
|
/** recordRun() for a run already stored. */
|
|
382
420
|
private recordOver;
|
|
383
421
|
/**
|
|
384
422
|
* Evaluate a finished run (ok, failed, or timed out by a check), already
|
|
385
|
-
* written, against the job's state and send what that produces.
|
|
423
|
+
* written, against the job's state and send what that produces. The
|
|
424
|
+
* alerts are written with that state (see outbox()). Never throws.
|
|
386
425
|
*/
|
|
387
426
|
private finishRun;
|
|
427
|
+
/**
|
|
428
|
+
* An evaluation as it is written: its drafts composed into alerts and held
|
|
429
|
+
* in the same state (holdAlerts), so the write that opens a condition also
|
|
430
|
+
* keeps its alerts, and a process that stops before sending them does not
|
|
431
|
+
* lose them. Called inside updateState(), so it only computes.
|
|
432
|
+
*/
|
|
433
|
+
private outbox;
|
|
434
|
+
/** Reports alerts let go because a job's queue was full. */
|
|
435
|
+
private reportDropped;
|
|
388
436
|
/**
|
|
389
437
|
* The runs before `run`, newest first, with up to BASELINE_WINDOW
|
|
390
438
|
* successful ones when the store has them. One small read normally; a
|
|
@@ -410,31 +458,62 @@ declare class CronWatch {
|
|
|
410
458
|
job: JobSummary;
|
|
411
459
|
runs: Run[];
|
|
412
460
|
}[]>;
|
|
461
|
+
/** A job's summary, or null for one the store does not have. One declared here and forgotten elsewhere is written again, as storedJobs() does. */
|
|
413
462
|
jobSummary(name: string): Promise<JobSummary | null>;
|
|
414
463
|
/** A job's runs, newest first. `limit` is a whole number from 1 to 500. */
|
|
415
464
|
runs(name: string, limit?: number): Promise<Run[]>;
|
|
416
465
|
getRun(id: string): Promise<Run | null>;
|
|
417
|
-
/**
|
|
466
|
+
/**
|
|
467
|
+
* Stop alerts for a job for a while. State keeps updating underneath. The
|
|
468
|
+
* end is a whole millisecond, held at 2^53 - 1 (see silenceEnd).
|
|
469
|
+
*/
|
|
418
470
|
silence(name: string, duration: Duration): Promise<JobState>;
|
|
419
471
|
unsilence(name: string): Promise<JobState>;
|
|
420
472
|
/** Read, change and write one job's state, in turn with every other update to it. */
|
|
421
473
|
private patchState;
|
|
422
|
-
/**
|
|
474
|
+
/**
|
|
475
|
+
* Remove a job and its runs from the store. A job still declared in code
|
|
476
|
+
* comes back: here on its next run, and in any other process that declares
|
|
477
|
+
* it on its next run there, or at that process's next check or dashboard read.
|
|
478
|
+
*/
|
|
423
479
|
forget(name: string): Promise<void>;
|
|
424
|
-
/**
|
|
480
|
+
/**
|
|
481
|
+
* The dashboard and JSON API as fetch-style handlers: the one way to mount
|
|
482
|
+
* them. A Next.js app exports them from app/cronwatch/[[...path]]/route.ts:
|
|
483
|
+
*
|
|
484
|
+
* export const { GET, POST, DELETE } = cw.routes();
|
|
485
|
+
*/
|
|
425
486
|
routes(options?: RoutesOptions): Routes;
|
|
426
487
|
/**
|
|
427
488
|
* Check on an interval, for long-running servers. Default every minute.
|
|
428
489
|
* Not for serverless functions or Cloudflare Workers, where nothing runs
|
|
429
|
-
* between requests: call check() from a cron there instead.
|
|
490
|
+
* between requests: call check() from a cron there instead. (A job's
|
|
491
|
+
* start() opens a run; this starts the checks.)
|
|
492
|
+
*/
|
|
493
|
+
startChecking(every?: Duration): void;
|
|
494
|
+
/**
|
|
495
|
+
* startChecking(), under its former name.
|
|
496
|
+
* @deprecated Renamed `startChecking`, since a job's `start()` opens a run.
|
|
497
|
+
* This name still works through 1.x and goes in 2.0.
|
|
430
498
|
*/
|
|
431
499
|
start(every?: Duration): void;
|
|
500
|
+
/** Stop the checks startChecking() began. */
|
|
432
501
|
stop(): void;
|
|
502
|
+
/**
|
|
503
|
+
* Stop the interval, wait for a check already under way (bounded by its
|
|
504
|
+
* own channel, triage and retry timeouts; what it throws was reported to
|
|
505
|
+
* whoever started it), then close the store, so that check neither writes
|
|
506
|
+
* after the store is closed nor loses the alerts it would queue.
|
|
507
|
+
*/
|
|
433
508
|
close(): Promise<void>;
|
|
434
509
|
/**
|
|
435
|
-
*
|
|
436
|
-
*
|
|
437
|
-
* the delivery fields are written back, onto
|
|
510
|
+
* Triage and send each alert the outbox holds (see outbox()). The state,
|
|
511
|
+
* with the alerts in it, was saved before this, so a slow channel holds up
|
|
512
|
+
* nothing else; afterwards only the delivery fields are written back, onto
|
|
513
|
+
* a fresh read of the state, and the alerts leave `sending`. Triage is made
|
|
514
|
+
* here, never stored with the held alert: the write that opens a condition
|
|
515
|
+
* cannot wait for it, and a retry triages an alert that has none. With
|
|
516
|
+
* deliver: "check" the alerts were queued for a check elsewhere instead.
|
|
438
517
|
*/
|
|
439
518
|
private dispatch;
|
|
440
519
|
/**
|
|
@@ -447,8 +526,10 @@ declare class CronWatch {
|
|
|
447
526
|
private retryUndelivered;
|
|
448
527
|
/**
|
|
449
528
|
* Mark delivered alerts done, drop stale ones, and keep failed ones for the
|
|
450
|
-
* next check
|
|
451
|
-
*
|
|
529
|
+
* next check, taking them all out of `sending` (recordSent). A failed alert
|
|
530
|
+
* replaces its stored copy, so a triage made on this attempt is kept.
|
|
531
|
+
* lastAlertAt moves only on a delivery. When this write fails, alerts
|
|
532
|
+
* still in `sending` are retried once their lease runs out.
|
|
452
533
|
*/
|
|
453
534
|
private recordDelivery;
|
|
454
535
|
/** Send to every channel at once. True when at least one accepted it, or there are none. */
|
|
@@ -461,4 +542,15 @@ declare function consoleChannel(): AlertChannel;
|
|
|
461
542
|
/** Wrap any function as an alert channel. */
|
|
462
543
|
declare function custom(name: string, send: (alert: Alert) => Promise<void> | void): AlertChannel;
|
|
463
544
|
|
|
464
|
-
|
|
545
|
+
/**
|
|
546
|
+
* The client's former name.
|
|
547
|
+
* @deprecated Renamed `Cronwatch`, the spelling every port uses. This name
|
|
548
|
+
* still works through 1.x and goes in 2.0.
|
|
549
|
+
*/
|
|
550
|
+
declare const CronWatch: typeof Cronwatch;
|
|
551
|
+
/** @deprecated Renamed `Cronwatch`; this name goes in 2.0. */
|
|
552
|
+
type CronWatch = Cronwatch;
|
|
553
|
+
/** @deprecated Renamed `CronwatchOptions`; this name goes in 2.0. */
|
|
554
|
+
type CronWatchOptions = CronwatchOptions;
|
|
555
|
+
|
|
556
|
+
export { type CronwatchOptions as C, type FetchHandler as F, type HandlerFn as H, type JobContext as J, type RecordRunOptions as R, type Source as S, Cronwatch as a, CronWatch as b, type CronWatchOptions as c, type HandlerOptions as d, type JobFn as e, type JobHandle as f, type Routes as g, type RoutesOptions as h, type RunHandle as i, type RunOutcome as j, type SourceHost as k, type StartOptions as l, consoleChannel as m, createRoutes as n, custom as o };
|