@anchan828/nest-cloud-run-queue-worker 2.2.1 → 2.3.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.
@@ -51,6 +51,24 @@ export declare enum QueueWorkerProcessorStatus {
51
51
  export type QueueWorkerExtraConfig = {
52
52
  preProcessor?: (name: string, ...args: Parameters<QueueWorkerProcessor>) => (QueueWorkerProcessorStatus | undefined | void) | Promise<QueueWorkerProcessorStatus | undefined | void>;
53
53
  postProcessor?: (name: string, ...args: Parameters<QueueWorkerProcessor>) => void | Promise<void>;
54
+ /**
55
+ * Exceptions thrown in the processor do not reach the top level and are not detected by the application. If you want to do something with processor exceptions, use this property.
56
+ * @example
57
+ * ```ts
58
+ * catchProcessorException: (error: Error) => {
59
+ * captureException(error); // Sentry
60
+ * }
61
+ * ```
62
+ *
63
+ * @example
64
+ * ```ts
65
+ * catchProcessorException: async (error: Error) => {
66
+ * // You can throw errors and let them reach the top level. Use an ExceptionFilter or similar to handle them appropriately.
67
+ * throw error;
68
+ * }
69
+ * ```
70
+ */
71
+ catchProcessorException?: <T extends Error = Error>(error: T, raw: QueueWorkerRawMessage) => void | Promise<void>;
54
72
  };
55
73
  export interface QueueWorkerDecoratorArgs {
56
74
  names: QueueWorkerName[];
@@ -62,7 +80,7 @@ export interface QueueWorkerDecoratorArgs {
62
80
  */
63
81
  priority: number;
64
82
  /**
65
- * If you want to disable the worker, set it to false.
83
+ * If you want to disable the worker, set it to false. Defaults to true.
66
84
  */
67
85
  enabled?: boolean;
68
86
  }
@@ -75,7 +93,7 @@ export interface QueueWorkerProcessDecoratorArgs {
75
93
  */
76
94
  priority: number;
77
95
  /**
78
- * If you want to disable the process, set it to false.
96
+ * If you want to disable the process, set it to false. Defaults to true.
79
97
  */
80
98
  enabled?: boolean;
81
99
  }
@@ -113,7 +131,7 @@ export interface QueueWorkerOptions {
113
131
  */
114
132
  priority?: number;
115
133
  /**
116
- * If you want to disable the worker, set it to false.
134
+ * If you want to disable the worker, set it to false. Defaults to true.
117
135
  */
118
136
  enabled?: boolean;
119
137
  }
@@ -123,7 +141,7 @@ export interface QueueWorkerProcessOptions {
123
141
  */
124
142
  priority?: number;
125
143
  /**
126
- * If you want to disable the process, set it to false.
144
+ * If you want to disable the process, set it to false. Defaults to true.
127
145
  */
128
146
  enabled?: boolean;
129
147
  }
@@ -82,6 +82,7 @@ let QueueWorkerService = class QueueWorkerService {
82
82
  }
83
83
  catch (error) {
84
84
  this.logger.error(error.message);
85
+ await this.options.extraConfig?.catchProcessorException?.(error, raw);
85
86
  }
86
87
  }
87
88
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anchan828/nest-cloud-run-queue-worker",
3
- "version": "2.2.1",
3
+ "version": "2.3.0",
4
4
  "description": "> TODO: description",
5
5
  "homepage": "https://github.com/anchan828/nest-cloud-run-queue/tree/master/packages/worker#readme",
6
6
  "bugs": {
@@ -33,7 +33,7 @@
33
33
  "watch": "tsc -w"
34
34
  },
35
35
  "dependencies": {
36
- "@anchan828/nest-cloud-run-queue-common": "^2.2.1"
36
+ "@anchan828/nest-cloud-run-queue-common": "^2.3.0"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@nestjs/common": "10.3.10",
@@ -46,5 +46,5 @@
46
46
  "access": "public"
47
47
  },
48
48
  "packageManager": "npm@10.8.1",
49
- "gitHead": "882db718c2c146c2ec24b95462eccbad2cad2125"
49
+ "gitHead": "24cf62975961ff44cd62d00128a7510a771a4e8f"
50
50
  }