@remit/imap-worker 0.0.91 → 0.0.92
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/dist/scheduler/calendar-subscriptions.d.ts +1 -5
- package/dist/scheduler/config.d.ts +4 -2
- package/dist/scheduler/config.js +7 -7
- package/dist/scheduler/handler.js +3 -5
- package/dist/scheduler/run-tick.d.ts +5 -1
- package/dist/scheduler/runner.js +3 -5
- package/dist/scheduler/tick.d.ts +5 -0
- package/dist/scheduler/tick.js +5 -0
- package/package.json +5 -1
|
@@ -2,11 +2,7 @@ import type { RemitClient } from "@remit/backend/client";
|
|
|
2
2
|
import { type CalendarFeedFetcher } from "@remit/calendar-service";
|
|
3
3
|
import type { ICalendarCollectionRepository, ICalendarStore } from "@remit/data-ports";
|
|
4
4
|
import type { Logger } from "@remit/logger";
|
|
5
|
-
|
|
6
|
-
refreshed: number;
|
|
7
|
-
failed: number;
|
|
8
|
-
notDue: number;
|
|
9
|
-
}
|
|
5
|
+
import type { CalendarSubscriptionTally } from "./run-tick.js";
|
|
10
6
|
export interface CalendarSubscriptionRefreshDeps {
|
|
11
7
|
calendarCollection: Pick<ICalendarCollectionRepository, "listEnabledSubscriptions">;
|
|
12
8
|
calendarStore: ICalendarStore;
|
|
@@ -21,7 +21,9 @@
|
|
|
21
21
|
* accounts, and the checker's stall threshold is derived from those values —
|
|
22
22
|
* see deploy/vps/docker-compose.sqlite.yml's `scheduler` service.
|
|
23
23
|
*/
|
|
24
|
-
export declare const
|
|
25
|
-
export declare const
|
|
24
|
+
export declare const DEFAULT_TICK_INTERVAL_MS: number;
|
|
25
|
+
export declare const DEFAULT_OFFLINE_INTERVAL_MS: number;
|
|
26
|
+
export declare const getTickIntervalMs: (env: Readonly<Record<string, string | undefined>>) => number;
|
|
27
|
+
export declare const getOfflineIntervalMs: (env: Readonly<Record<string, string | undefined>>) => number;
|
|
26
28
|
export declare const SCHEDULER_PAGE_SIZE = 100;
|
|
27
29
|
export declare const SCHEDULER_ENQUEUE_CONCURRENCY = 10;
|
package/dist/scheduler/config.js
CHANGED
|
@@ -21,16 +21,16 @@
|
|
|
21
21
|
* accounts, and the checker's stall threshold is derived from those values —
|
|
22
22
|
* see deploy/vps/docker-compose.sqlite.yml's `scheduler` service.
|
|
23
23
|
*/
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
const
|
|
24
|
+
export const DEFAULT_TICK_INTERVAL_MS = 60 * 60 * 1000;
|
|
25
|
+
export const DEFAULT_OFFLINE_INTERVAL_MS = 12 * 60 * 60 * 1000;
|
|
26
|
+
const parsePositiveSecondsAsMs = (raw, fallbackMs) => {
|
|
27
27
|
if (!raw)
|
|
28
|
-
return
|
|
28
|
+
return fallbackMs;
|
|
29
29
|
const parsed = Number.parseInt(raw, 10);
|
|
30
|
-
return Number.isFinite(parsed) && parsed > 0 ? parsed :
|
|
30
|
+
return Number.isFinite(parsed) && parsed > 0 ? parsed * 1000 : fallbackMs;
|
|
31
31
|
};
|
|
32
|
-
export const getTickIntervalMs = (env
|
|
33
|
-
export const getOfflineIntervalMs = (env
|
|
32
|
+
export const getTickIntervalMs = (env) => parsePositiveSecondsAsMs(env.MAILBOX_SYNC_TICK_INTERVAL_SECONDS, DEFAULT_TICK_INTERVAL_MS);
|
|
33
|
+
export const getOfflineIntervalMs = (env) => parsePositiveSecondsAsMs(env.MAILBOX_SYNC_OFFLINE_INTERVAL_SECONDS, DEFAULT_OFFLINE_INTERVAL_MS);
|
|
34
34
|
// Page size + enqueue concurrency are implementation details of the tick
|
|
35
35
|
// itself, not stage config — unlike the two intervals above, nothing outside
|
|
36
36
|
// this worker needs to agree with them.
|
|
@@ -3,11 +3,9 @@ import { createLogger } from "@remit/logger";
|
|
|
3
3
|
import { installNodeLogger, withTelemetry } from "@remit/logger-lambda/node";
|
|
4
4
|
import { lambdaEmitEvent } from "../lambda-context.js";
|
|
5
5
|
import { sqsWorkerQueues, workerQueueUrlsFromEnv } from "../sqs-queues.js";
|
|
6
|
-
import { buildAttachmentSweep } from "./attachment-sweep.js";
|
|
7
6
|
import { buildCalendarSubscriptionRefresh } from "./calendar-subscriptions.js";
|
|
8
7
|
import { getOfflineIntervalMs, getTickIntervalMs } from "./config.js";
|
|
9
|
-
import { runSchedulerTick } from "./
|
|
10
|
-
import { redriveStrandedPlacements } from "./stranded-placement-redrive.js";
|
|
8
|
+
import { buildAttachmentSweep, redriveStrandedPlacements, runSchedulerTick, } from "./tick.js";
|
|
11
9
|
installNodeLogger();
|
|
12
10
|
const log = createLogger();
|
|
13
11
|
/**
|
|
@@ -34,8 +32,8 @@ export const buildScheduledHandler = (queues) => withTelemetry(async (event) =>
|
|
|
34
32
|
accountService: client.account,
|
|
35
33
|
queue: queues.mailboxes,
|
|
36
34
|
log,
|
|
37
|
-
tickIntervalMs: getTickIntervalMs(),
|
|
38
|
-
offlineIntervalMs: getOfflineIntervalMs(),
|
|
35
|
+
tickIntervalMs: getTickIntervalMs(process.env),
|
|
36
|
+
offlineIntervalMs: getOfflineIntervalMs(process.env),
|
|
39
37
|
now,
|
|
40
38
|
// The hosted side is the one that needs this: a browser PUTs straight
|
|
41
39
|
// to block storage, so nothing refuses an upload against a draft that is
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { type SyncMailboxesEvent } from "@remit/backend/trigger-sync";
|
|
2
2
|
import type { AccountItem, FifoQueueProducer, IAccountRepository } from "@remit/data-ports";
|
|
3
3
|
import type { Logger } from "@remit/logger";
|
|
4
|
-
|
|
4
|
+
export interface CalendarSubscriptionTally {
|
|
5
|
+
refreshed: number;
|
|
6
|
+
failed: number;
|
|
7
|
+
notDue: number;
|
|
8
|
+
}
|
|
5
9
|
export interface RunSchedulerTickDeps {
|
|
6
10
|
accountService: Pick<IAccountRepository, "listAllAccountsPage">;
|
|
7
11
|
queue: FifoQueueProducer<SyncMailboxesEvent>;
|
package/dist/scheduler/runner.js
CHANGED
|
@@ -8,12 +8,10 @@ import { backfillSearchText } from "@remit/mailbox-service";
|
|
|
8
8
|
import { clearHeartbeats, createHeartbeat } from "@remit/sqs-client/heartbeat";
|
|
9
9
|
import { lambdaEmitEvent } from "../lambda-context.js";
|
|
10
10
|
import { sqsWorkerQueues, workerQueueUrlsFromEnv } from "../sqs-queues.js";
|
|
11
|
-
import { buildAttachmentSweep } from "./attachment-sweep.js";
|
|
12
11
|
import { buildCalendarSubscriptionRefresh } from "./calendar-subscriptions.js";
|
|
13
12
|
import { getOfflineIntervalMs, getTickIntervalMs } from "./config.js";
|
|
14
13
|
import { runSchedulerLoop } from "./loop.js";
|
|
15
|
-
import { runSchedulerTick } from "./
|
|
16
|
-
import { redriveStrandedPlacements } from "./stranded-placement-redrive.js";
|
|
14
|
+
import { buildAttachmentSweep, redriveStrandedPlacements, runSchedulerTick, } from "./tick.js";
|
|
17
15
|
installNodeLogger();
|
|
18
16
|
/**
|
|
19
17
|
* The scheduled-sync runner for every deployment that has no EventBridge: the
|
|
@@ -36,8 +34,8 @@ installNodeLogger();
|
|
|
36
34
|
*/
|
|
37
35
|
const log = createLogger();
|
|
38
36
|
const queues = sqsWorkerQueues(workerQueueUrlsFromEnv());
|
|
39
|
-
const tickIntervalMs = getTickIntervalMs();
|
|
40
|
-
const offlineIntervalMs = getOfflineIntervalMs();
|
|
37
|
+
const tickIntervalMs = getTickIntervalMs(process.env);
|
|
38
|
+
const offlineIntervalMs = getOfflineIntervalMs(process.env);
|
|
41
39
|
// A persistent failure (e.g. Postgres not up yet at container boot) throws
|
|
42
40
|
// before the loop ever reaches its own `delay`, so `restart: unless-stopped`
|
|
43
41
|
// would otherwise respawn the process immediately — a tight, log-flooding
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { createEmitEvent, type EmitDeps, type EmitEvent } from "../emit.js";
|
|
2
|
+
export { buildAttachmentSweep } from "./attachment-sweep.js";
|
|
3
|
+
export { DEFAULT_OFFLINE_INTERVAL_MS, DEFAULT_TICK_INTERVAL_MS, } from "./config.js";
|
|
4
|
+
export { type CalendarSubscriptionTally, type RunSchedulerTickDeps, runSchedulerTick, type SchedulerTickResult, } from "./run-tick.js";
|
|
5
|
+
export { redriveStrandedPlacements, type StrandedPlacementEvent, type StrandedPlacementRedriveDeps, } from "./stranded-placement-redrive.js";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { createEmitEvent } from "../emit.js";
|
|
2
|
+
export { buildAttachmentSweep } from "./attachment-sweep.js";
|
|
3
|
+
export { DEFAULT_OFFLINE_INTERVAL_MS, DEFAULT_TICK_INTERVAL_MS, } from "./config.js";
|
|
4
|
+
export { runSchedulerTick, } from "./run-tick.js";
|
|
5
|
+
export { redriveStrandedPlacements, } from "./stranded-placement-redrive.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remit/imap-worker",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.92",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -16,6 +16,10 @@
|
|
|
16
16
|
"types": "./dist/scheduler/handler.d.ts",
|
|
17
17
|
"default": "./dist/scheduler/handler.js"
|
|
18
18
|
},
|
|
19
|
+
"./scheduler-tick": {
|
|
20
|
+
"types": "./dist/scheduler/tick.d.ts",
|
|
21
|
+
"default": "./dist/scheduler/tick.js"
|
|
22
|
+
},
|
|
19
23
|
"./mailbox-management": {
|
|
20
24
|
"types": "./dist/handlers/mailbox-management.d.ts",
|
|
21
25
|
"default": "./dist/handlers/mailbox-management.js"
|