@squiz/job-runner-lib 2.8.0 → 2.9.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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Change Log
2
2
 
3
+ ## 2.9.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 89bb566: Mark node:20 runtime image as deprecated
8
+
3
9
  ## 2.8.0
4
10
 
5
11
  ### Minor Changes
@@ -0,0 +1,11 @@
1
+ /*!
2
+ * @license
3
+ * Copyright Squiz Australia Pty Ltd. All Rights Reserved.
4
+ */
5
+ /**
6
+ * Backlog guard defaults. A job's `begin` is rejected with 422 once it has more than
7
+ * DEFAULT_MAX_QUEUED_EXECUTIONS queued AND its oldest queued execution is older than
8
+ * DEFAULT_MAX_QUEUED_AGE_HOURS. Both conditions are required (large AND stale).
9
+ */
10
+ export declare const DEFAULT_MAX_QUEUED_EXECUTIONS = 500;
11
+ export declare const DEFAULT_MAX_QUEUED_AGE_HOURS = 2;
@@ -2,6 +2,7 @@ export * from './core/dynamoClient.mock';
2
2
  export * from './core/pagination';
3
3
  export * from './constants/InjectTokens';
4
4
  export * from './constants/JobExecutionStatus.constants';
5
+ export * from './constants/QueueBacklog.constants';
5
6
  export * from './constants/Repository.constants';
6
7
  export * from './constants/RetryConfig.constants';
7
8
  export * from './constants/RuntimeImage.constants';
@@ -16,6 +16,21 @@ export declare class JobExecutionRepository extends Repository<JobExecution, Job
16
16
  * @memberof JobExecutionRepository
17
17
  */
18
18
  list(parameters?: ListJobExecutionParameters): Promise<Array<JobExecution>>;
19
+ /**
20
+ * Returns the single oldest queued execution for a job, or null if there are none.
21
+ *
22
+ * Queries the `lsi1` index (`lsi1sk = "<status>~<jobName>"`). All queued executions of one
23
+ * job share the same `lsi1sk`, so DynamoDB breaks ties by the base-table `sk`
24
+ * (`"<jobName>~<id>"`); `id` is prefixed with the ISO `timeQueued`, which sorts
25
+ * lexicographically, so ascending order is chronological and the first item is the oldest.
26
+ */
27
+ getOldestQueuedExecution(jobName: string): Promise<JobExecution | null>;
28
+ /**
29
+ * Counts queued executions for a job, evaluating at most `limit` items (`Select: COUNT` so no
30
+ * item data is returned). Pass a `limit` just above the threshold you care about — queued
31
+ * items are small, so a single page covers the bounded count.
32
+ */
33
+ countQueuedExecutions(jobName: string, limit?: number): Promise<number>;
19
34
  /**
20
35
  * Get list of records from database.
21
36
  * @abstract