@nest-omni/core 4.1.3-1 → 4.1.3-11
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/audit/audit.module.d.ts +10 -0
- package/audit/audit.module.js +39 -1
- package/audit/controllers/audit.controller.d.ts +24 -0
- package/audit/controllers/audit.controller.js +24 -0
- package/audit/decorators/audit-controller.decorator.d.ts +9 -1
- package/audit/decorators/audit-controller.decorator.js +11 -2
- package/audit/decorators/audit-operation.decorator.d.ts +45 -0
- package/audit/decorators/audit-operation.decorator.js +49 -0
- package/audit/decorators/entity-audit.decorator.d.ts +76 -1
- package/audit/decorators/entity-audit.decorator.js +135 -3
- package/audit/decorators/index.d.ts +1 -0
- package/audit/decorators/index.js +1 -0
- package/audit/dto/audit-log-query.dto.d.ts +3 -0
- package/audit/dto/audit-log-query.dto.js +3 -0
- package/audit/dto/begin-transaction.dto.d.ts +3 -0
- package/audit/dto/begin-transaction.dto.js +3 -0
- package/audit/dto/compare-entities.dto.d.ts +3 -0
- package/audit/dto/compare-entities.dto.js +3 -0
- package/audit/dto/pre-check-restore.dto.d.ts +3 -0
- package/audit/dto/pre-check-restore.dto.js +3 -0
- package/audit/dto/restore-entity.dto.d.ts +3 -0
- package/audit/dto/restore-entity.dto.js +3 -0
- package/audit/entities/entity-audit-log.entity.d.ts +8 -0
- package/audit/entities/entity-audit-log.entity.js +33 -1
- package/audit/entities/entity-transaction.entity.d.ts +10 -0
- package/audit/entities/entity-transaction.entity.js +33 -1
- package/audit/entities/index.d.ts +2 -0
- package/audit/entities/index.js +2 -0
- package/audit/entities/manual-operation-log.entity.d.ts +4 -0
- package/audit/entities/manual-operation-log.entity.js +4 -0
- package/audit/entities/operation-template.entity.d.ts +4 -0
- package/audit/entities/operation-template.entity.js +4 -0
- package/audit/enums/audit.enums.d.ts +45 -5
- package/audit/enums/audit.enums.js +47 -4
- package/audit/index.d.ts +3 -1
- package/audit/index.js +30 -1
- package/audit/interceptors/audit.interceptor.d.ts +15 -0
- package/audit/interceptors/audit.interceptor.js +23 -1
- package/audit/interfaces/audit.interfaces.d.ts +182 -2
- package/audit/services/audit-context.service.d.ts +15 -0
- package/audit/services/audit-context.service.js +15 -0
- package/audit/services/audit-strategy.service.d.ts +6 -0
- package/audit/services/audit-strategy.service.js +13 -0
- package/audit/services/entity-audit.service.d.ts +129 -3
- package/audit/services/entity-audit.service.js +301 -6
- package/audit/services/index.d.ts +2 -0
- package/audit/services/index.js +2 -0
- package/audit/services/manual-audit-log.service.d.ts +124 -0
- package/audit/services/manual-audit-log.service.js +138 -0
- package/audit/services/multi-database.service.d.ts +12 -0
- package/audit/services/multi-database.service.js +12 -0
- package/audit/services/operation-description.service.d.ts +59 -0
- package/audit/services/operation-description.service.js +76 -2
- package/audit/services/transaction-audit.service.d.ts +30 -0
- package/audit/services/transaction-audit.service.js +47 -0
- package/audit/subscribers/entity-audit.subscriber.d.ts +15 -0
- package/audit/subscribers/entity-audit.subscriber.js +29 -1
- package/cache/cache-metrics.service.d.ts +67 -0
- package/cache/cache-metrics.service.js +68 -4
- package/cache/cache-serialization.service.d.ts +31 -0
- package/cache/cache-serialization.service.js +25 -0
- package/cache/cache.constants.d.ts +9 -0
- package/cache/cache.constants.js +9 -0
- package/cache/cache.health.d.ts +26 -0
- package/cache/cache.health.js +30 -0
- package/cache/cache.module.d.ts +86 -0
- package/cache/cache.module.js +71 -0
- package/cache/cache.service.d.ts +140 -0
- package/cache/cache.service.js +157 -0
- package/cache/cache.warmup.service.d.ts +39 -0
- package/cache/cache.warmup.service.js +32 -0
- package/cache/decorators/cache-evict.decorator.d.ts +47 -0
- package/cache/decorators/cache-evict.decorator.js +56 -0
- package/cache/decorators/cache-put.decorator.d.ts +34 -0
- package/cache/decorators/cache-put.decorator.js +39 -0
- package/cache/decorators/cacheable.decorator.d.ts +40 -0
- package/cache/decorators/cacheable.decorator.js +55 -0
- package/cache/dependencies/callback.dependency.d.ts +33 -0
- package/cache/dependencies/callback.dependency.js +39 -1
- package/cache/dependencies/chain.dependency.d.ts +28 -0
- package/cache/dependencies/chain.dependency.js +34 -0
- package/cache/dependencies/db.dependency.d.ts +45 -0
- package/cache/dependencies/db.dependency.js +48 -1
- package/cache/dependencies/file.dependency.d.ts +32 -0
- package/cache/dependencies/file.dependency.js +34 -0
- package/cache/dependencies/tag.dependency.d.ts +36 -0
- package/cache/dependencies/tag.dependency.js +36 -0
- package/cache/dependencies/time.dependency.d.ts +43 -0
- package/cache/dependencies/time.dependency.js +43 -0
- package/cache/examples/basic-usage.d.ts +15 -0
- package/cache/examples/basic-usage.js +62 -8
- package/cache/index.js +9 -0
- package/cache/interfaces/cache-dependency.interface.d.ts +53 -0
- package/cache/interfaces/cache-options.interface.d.ts +81 -0
- package/cache/interfaces/cache-options.interface.js +6 -0
- package/cache/interfaces/cache-provider.interface.d.ts +78 -0
- package/cache/providers/base-cache.provider.d.ts +14 -0
- package/cache/providers/base-cache.provider.js +16 -0
- package/cache/providers/cls-cache.provider.d.ts +20 -0
- package/cache/providers/cls-cache.provider.js +28 -0
- package/cache/providers/memory-cache.provider.d.ts +23 -0
- package/cache/providers/memory-cache.provider.js +26 -0
- package/cache/providers/redis-cache.provider.d.ts +26 -0
- package/cache/providers/redis-cache.provider.js +29 -0
- package/cache/utils/dependency-manager.util.d.ts +52 -0
- package/cache/utils/dependency-manager.util.js +59 -0
- package/cache/utils/key-generator.util.d.ts +42 -0
- package/cache/utils/key-generator.util.js +53 -1
- package/common/abstract.entity.d.ts +14 -0
- package/common/abstract.entity.js +14 -0
- package/common/boilerplate.polyfill.d.ts +142 -4
- package/common/boilerplate.polyfill.js +24 -100
- package/common/dto/dto-container.d.ts +16 -0
- package/common/dto/dto-container.js +20 -0
- package/common/dto/dto-decorators.d.ts +18 -0
- package/common/dto/dto-decorators.js +14 -0
- package/common/dto/dto-extensions.d.ts +11 -0
- package/common/dto/dto-extensions.js +9 -0
- package/common/dto/dto-service-accessor.d.ts +17 -0
- package/common/dto/dto-service-accessor.js +18 -0
- package/common/dto/dto-transformer.d.ts +12 -0
- package/common/dto/dto-transformer.js +9 -0
- package/common/dto/index.js +2 -0
- package/common/examples/paginate-and-map.example.d.ts +6 -0
- package/common/examples/paginate-and-map.example.js +26 -0
- package/common/utils.d.ts +15 -0
- package/common/utils.js +15 -0
- package/constants/language-code.js +1 -0
- package/decorators/field.decorators.js +8 -1
- package/decorators/property.decorators.js +1 -0
- package/decorators/public-route.decorator.js +1 -0
- package/decorators/transform.decorators.d.ts +27 -0
- package/decorators/transform.decorators.js +29 -0
- package/decorators/translate.decorator.js +1 -0
- package/decorators/user.decorator.js +1 -0
- package/decorators/validator.decorators.d.ts +8 -18
- package/decorators/validator.decorators.js +22 -190
- package/filters/constraint-errors.js +1 -0
- package/helpers/common.helper.d.ts +13 -0
- package/helpers/common.helper.js +13 -0
- package/http-client/config/http-client.config.d.ts +15 -0
- package/http-client/config/http-client.config.js +25 -9
- package/http-client/decorators/http-client.decorators.d.ts +63 -0
- package/http-client/decorators/http-client.decorators.js +71 -3
- package/http-client/entities/http-log.entity.d.ts +229 -0
- package/http-client/entities/http-log.entity.js +6 -1
- package/http-client/errors/http-client.errors.d.ts +57 -0
- package/http-client/errors/http-client.errors.js +58 -0
- package/http-client/examples/advanced-usage.example.d.ts +41 -0
- package/http-client/examples/advanced-usage.example.js +68 -24
- package/http-client/examples/auth-with-waiting-lock.example.d.ts +31 -0
- package/http-client/examples/auth-with-waiting-lock.example.js +52 -5
- package/http-client/examples/basic-usage.example.d.ts +60 -0
- package/http-client/examples/basic-usage.example.js +60 -0
- package/http-client/examples/multi-api-configuration.example.d.ts +60 -0
- package/http-client/examples/multi-api-configuration.example.js +76 -5
- package/http-client/http-client.module.d.ts +13 -0
- package/http-client/http-client.module.js +20 -5
- package/http-client/index.js +8 -0
- package/http-client/interfaces/api-client-config.interface.d.ts +125 -0
- package/http-client/interfaces/api-client-config.interface.js +3 -0
- package/http-client/interfaces/http-client-config.interface.d.ts +60 -0
- package/http-client/services/api-client-registry.service.d.ts +57 -0
- package/http-client/services/api-client-registry.service.js +84 -1
- package/http-client/services/cache.service.d.ts +52 -0
- package/http-client/services/cache.service.js +72 -3
- package/http-client/services/circuit-breaker.service.d.ts +46 -0
- package/http-client/services/circuit-breaker.service.js +52 -0
- package/http-client/services/http-client.service.d.ts +67 -0
- package/http-client/services/http-client.service.js +105 -4
- package/http-client/services/http-log-query.service.d.ts +83 -0
- package/http-client/services/http-log-query.service.js +122 -1
- package/http-client/services/http-replay.service.d.ts +101 -0
- package/http-client/services/http-replay.service.js +86 -0
- package/http-client/services/log-cleanup.service.d.ts +63 -0
- package/http-client/services/log-cleanup.service.js +54 -2
- package/http-client/services/logging.service.d.ts +40 -0
- package/http-client/services/logging.service.js +53 -0
- package/http-client/utils/call-stack-extractor.util.d.ts +37 -0
- package/http-client/utils/call-stack-extractor.util.js +48 -0
- package/http-client/utils/context-extractor.util.d.ts +49 -0
- package/http-client/utils/context-extractor.util.js +52 -0
- package/http-client/utils/curl-generator.util.d.ts +21 -0
- package/http-client/utils/curl-generator.util.js +44 -3
- package/http-client/utils/request-id.util.d.ts +18 -0
- package/http-client/utils/request-id.util.js +20 -0
- package/http-client/utils/retry-recorder.util.d.ts +42 -0
- package/http-client/utils/retry-recorder.util.js +44 -0
- package/i18n/en_US/validation.json +2 -1
- package/i18n/zh_CN/validation.json +2 -1
- package/index.js +8 -0
- package/interceptors/translation-interceptor.service.js +5 -0
- package/package.json +1 -1
- package/providers/context.provider.js +2 -0
- package/providers/generator.provider.d.ts +4 -0
- package/providers/generator.provider.js +4 -0
- package/redis-lock/comprehensive-lock-cleanup.service.d.ts +94 -0
- package/redis-lock/comprehensive-lock-cleanup.service.js +253 -0
- package/redis-lock/examples/lock-strategy.examples.d.ts +89 -0
- package/redis-lock/examples/lock-strategy.examples.js +130 -15
- package/redis-lock/index.d.ts +2 -0
- package/redis-lock/index.js +8 -1
- package/redis-lock/lock-heartbeat.service.d.ts +78 -0
- package/redis-lock/lock-heartbeat.service.js +222 -0
- package/redis-lock/redis-lock.decorator.d.ts +101 -0
- package/redis-lock/redis-lock.decorator.js +120 -0
- package/redis-lock/redis-lock.module.d.ts +66 -0
- package/redis-lock/redis-lock.module.js +175 -70
- package/redis-lock/redis-lock.service.d.ts +278 -0
- package/redis-lock/redis-lock.service.js +282 -12
- package/setup/bootstrap.setup.js +20 -0
- package/setup/mode.setup.d.ts +44 -0
- package/setup/mode.setup.js +44 -0
- package/setup/schedule.decorator.d.ts +227 -0
- package/setup/schedule.decorator.js +235 -12
- package/setup/worker.decorator.d.ts +86 -0
- package/setup/worker.decorator.js +88 -0
- package/shared/serviceRegistryModule.js +27 -14
- package/shared/services/api-config.service.d.ts +3 -0
- package/shared/services/api-config.service.js +20 -9
- package/validator-json/decorators.d.ts +17 -0
- package/validator-json/decorators.js +17 -2
- package/validator-json/default.d.ts +6 -0
- package/validator-json/default.js +30 -2
- package/validator-json/defaultConverters.js +1 -0
- package/validator-json/options.d.ts +23 -0
- package/validators/common-validators.d.ts +143 -0
- package/validators/common-validators.js +249 -0
- package/validators/custom-validate.examples.d.ts +96 -0
- package/validators/custom-validate.examples.js +400 -0
- package/validators/custom-validate.validator.d.ts +134 -0
- package/validators/custom-validate.validator.js +214 -0
- package/validators/index.d.ts +2 -0
- package/validators/index.js +2 -0
- package/validators/is-exists.validator.d.ts +18 -4
- package/validators/is-exists.validator.js +67 -6
- package/validators/is-unique.validator.d.ts +32 -5
- package/validators/is-unique.validator.js +99 -17
- package/validators/skip-empty.validator.d.ts +5 -0
- package/validators/skip-empty.validator.js +5 -0
- package/vault/interfaces/vault-options.interface.d.ts +9 -0
- package/vault/vault-config.loader.d.ts +30 -0
- package/vault/vault-config.loader.js +48 -1
- package/vault/vault-config.service.d.ts +53 -0
- package/vault/vault-config.service.js +57 -0
- package/vault/vault.module.d.ts +4 -0
- package/vault/vault.module.js +4 -0
- package/decorators/examples/validation-decorators.example.d.ts +0 -69
- package/decorators/examples/validation-decorators.example.js +0 -331
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Enhanced Schedule Decorators for Worker Mode
|
|
4
|
+
*
|
|
5
|
+
* This module provides decorators for scheduled tasks that:
|
|
6
|
+
* - Only run in Worker or Hybrid mode (not in HTTP-only mode)
|
|
7
|
+
* - Support distributed locking via Redis
|
|
8
|
+
* - Support retry logic for failed tasks
|
|
9
|
+
* - Provide automatic lock key generation
|
|
10
|
+
* - Support task execution logging and error handling
|
|
11
|
+
*/
|
|
2
12
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
13
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
14
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -21,10 +31,16 @@ exports.WorkerCronAdvanced = WorkerCronAdvanced;
|
|
|
21
31
|
const common_1 = require("@nestjs/common");
|
|
22
32
|
const schedule_1 = require("@nestjs/schedule");
|
|
23
33
|
const mode_setup_1 = require("./mode.setup");
|
|
24
|
-
const
|
|
34
|
+
const redis_lock_1 = require("../redis-lock");
|
|
35
|
+
/**
|
|
36
|
+
* Generate a lock key from class name and method name
|
|
37
|
+
*/
|
|
25
38
|
function generateLockKey(className, methodName) {
|
|
26
39
|
return `${className}.${methodName}`;
|
|
27
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* Execute a function with retry logic
|
|
43
|
+
*/
|
|
28
44
|
function executeWithRetry(fn, options) {
|
|
29
45
|
return __awaiter(this, void 0, void 0, function* () {
|
|
30
46
|
const { retryCount = 0, retryDelay = 1000, useExponentialBackoff = false, maxRetryDelay = 60000, logger, taskName, } = options;
|
|
@@ -51,43 +67,67 @@ function executeWithRetry(fn, options) {
|
|
|
51
67
|
throw lastError;
|
|
52
68
|
});
|
|
53
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* Base decorator creator for worker-mode tasks
|
|
72
|
+
*/
|
|
54
73
|
function createWorkerDecorator(baseDecorator, decoratorName) {
|
|
55
74
|
return function (target, propertyKey, descriptor) {
|
|
56
75
|
const originalMethod = descriptor.value;
|
|
57
76
|
descriptor.value = function (...args) {
|
|
58
77
|
return __awaiter(this, void 0, void 0, function* () {
|
|
78
|
+
// Only execute in worker or hybrid mode
|
|
59
79
|
if (!(0, mode_setup_1.shouldProcessQueues)()) {
|
|
60
80
|
return;
|
|
61
81
|
}
|
|
62
82
|
return originalMethod.apply(this, args);
|
|
63
83
|
});
|
|
64
84
|
};
|
|
85
|
+
// Apply the base decorator
|
|
65
86
|
baseDecorator(target, propertyKey, descriptor);
|
|
66
87
|
return descriptor;
|
|
67
88
|
};
|
|
68
89
|
}
|
|
90
|
+
/**
|
|
91
|
+
* Create a worker decorator with lock support
|
|
92
|
+
*/
|
|
69
93
|
function createWorkerDecoratorWithLock(baseDecorator, decoratorName, lockKey, options = {}) {
|
|
70
94
|
return function (target, propertyKey, descriptor) {
|
|
71
95
|
const originalMethod = descriptor.value;
|
|
72
96
|
const className = target.constructor.name;
|
|
73
97
|
const methodName = String(propertyKey);
|
|
74
98
|
const logger = new common_1.Logger(`${className}.${methodName}`);
|
|
99
|
+
// Resolve lock key
|
|
75
100
|
const resolvedLockKey = typeof lockKey === 'function' ? lockKey() : lockKey;
|
|
76
101
|
descriptor.value = function (...args) {
|
|
77
102
|
return __awaiter(this, void 0, void 0, function* () {
|
|
103
|
+
// Only execute in worker or hybrid mode
|
|
78
104
|
if (!(0, mode_setup_1.shouldProcessQueues)()) {
|
|
79
105
|
return;
|
|
80
106
|
}
|
|
81
|
-
|
|
82
|
-
const
|
|
107
|
+
// Get or create global instance - auto-configures from environment variables
|
|
108
|
+
const lockService = redis_lock_1.RedisLockService.getOrCreateGlobalInstance();
|
|
109
|
+
const { lockTtl = 600000, // 10 minutes default (reduced from 1 hour)
|
|
110
|
+
retryCount = 3, retryDelay = 500, useExponentialBackoff = true, maxRetryDelay = 30000, logExecution = true, lockKeyPrefix = 'schedule', autoExtendLock = 0, onSuccess, onError, skipIfLocked = true, } = options;
|
|
111
|
+
// Configuration validation and adjustment
|
|
112
|
+
const validatedLockTtl = lockTtl >= 3600000
|
|
113
|
+
? (logger.warn(`lockTtl (${lockTtl}ms) is quite long for a scheduled task, consider if this is appropriate for ${className}.${methodName}`), lockTtl)
|
|
114
|
+
: lockTtl;
|
|
115
|
+
const validatedRetryCount = retryCount > 10
|
|
116
|
+
? (logger.warn(`retryCount (${retryCount}) is too high, limiting to 10 for task ${className}.${methodName}`), 10)
|
|
117
|
+
: retryCount;
|
|
118
|
+
const validatedRetryDelay = retryDelay < 100
|
|
119
|
+
? (logger.warn(`retryDelay (${retryDelay}ms) is too low, setting to 100ms for task ${className}.${methodName}`), 100)
|
|
120
|
+
: retryDelay;
|
|
83
121
|
const fullLockKey = `${lockKeyPrefix}:${resolvedLockKey}`;
|
|
84
122
|
const startTime = Date.now();
|
|
123
|
+
// Log task start
|
|
85
124
|
if (logExecution) {
|
|
86
125
|
logger.log(`Task starting...`);
|
|
87
126
|
}
|
|
88
127
|
try {
|
|
128
|
+
// Acquire lock
|
|
89
129
|
const lockResult = yield lockService.acquireLock(resolvedLockKey, {
|
|
90
|
-
ttl:
|
|
130
|
+
ttl: validatedLockTtl,
|
|
91
131
|
keyPrefix: lockKeyPrefix,
|
|
92
132
|
autoExtend: autoExtendLock,
|
|
93
133
|
});
|
|
@@ -101,9 +141,10 @@ function createWorkerDecoratorWithLock(baseDecorator, decoratorName, lockKey, op
|
|
|
101
141
|
}
|
|
102
142
|
}
|
|
103
143
|
try {
|
|
144
|
+
// Execute with retry logic
|
|
104
145
|
const result = yield executeWithRetry(() => originalMethod.apply(this, args), {
|
|
105
|
-
retryCount,
|
|
106
|
-
retryDelay,
|
|
146
|
+
retryCount: validatedRetryCount,
|
|
147
|
+
retryDelay: validatedRetryDelay,
|
|
107
148
|
useExponentialBackoff,
|
|
108
149
|
maxRetryDelay,
|
|
109
150
|
logger,
|
|
@@ -113,15 +154,18 @@ function createWorkerDecoratorWithLock(baseDecorator, decoratorName, lockKey, op
|
|
|
113
154
|
if (logExecution) {
|
|
114
155
|
logger.log(`Task completed successfully in ${duration}ms`);
|
|
115
156
|
}
|
|
157
|
+
// Call success callback with proper this context
|
|
116
158
|
if (onSuccess) {
|
|
117
159
|
yield onSuccess.call(this, duration);
|
|
118
160
|
}
|
|
119
161
|
return result;
|
|
120
162
|
}
|
|
121
163
|
finally {
|
|
164
|
+
// Clear auto-extension timer if it exists
|
|
122
165
|
if (lockResult.autoExtendTimer) {
|
|
123
166
|
clearInterval(lockResult.autoExtendTimer);
|
|
124
167
|
}
|
|
168
|
+
// Always release the lock
|
|
125
169
|
yield lockService.releaseLock(resolvedLockKey, lockResult.lockValue, lockKeyPrefix);
|
|
126
170
|
if (logExecution) {
|
|
127
171
|
logger.debug(`Lock "${fullLockKey}" released`);
|
|
@@ -130,9 +174,9 @@ function createWorkerDecoratorWithLock(baseDecorator, decoratorName, lockKey, op
|
|
|
130
174
|
}
|
|
131
175
|
catch (error) {
|
|
132
176
|
const duration = Date.now() - startTime;
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
177
|
+
// Always log errors regardless of logExecution setting
|
|
178
|
+
logger.error(`Task failed after ${duration}ms: ${error.message}`, error.stack);
|
|
179
|
+
// Call error callback with proper this context
|
|
136
180
|
if (onError) {
|
|
137
181
|
yield onError.call(this, error);
|
|
138
182
|
}
|
|
@@ -140,25 +184,98 @@ function createWorkerDecoratorWithLock(baseDecorator, decoratorName, lockKey, op
|
|
|
140
184
|
}
|
|
141
185
|
});
|
|
142
186
|
};
|
|
187
|
+
// Apply the base decorator
|
|
143
188
|
baseDecorator(target, propertyKey, descriptor);
|
|
144
189
|
return descriptor;
|
|
145
190
|
};
|
|
146
191
|
}
|
|
192
|
+
// ============================================================================
|
|
193
|
+
// Basic Worker Decorators (without lock)
|
|
194
|
+
// ============================================================================
|
|
195
|
+
/**
|
|
196
|
+
* Cron decorator that only executes in Worker or Hybrid mode
|
|
197
|
+
*
|
|
198
|
+
* @param cronTime - Cron expression
|
|
199
|
+
* @param options - Cron options
|
|
200
|
+
*
|
|
201
|
+
* @example
|
|
202
|
+
* ```typescript
|
|
203
|
+
* @WorkerCron('0 0 * * *') // Run daily at midnight
|
|
204
|
+
* async dailyTask() {
|
|
205
|
+
* // Task logic
|
|
206
|
+
* }
|
|
207
|
+
* ```
|
|
208
|
+
*/
|
|
147
209
|
function WorkerCron(cronTime, options) {
|
|
148
210
|
return createWorkerDecorator((0, schedule_1.Cron)(cronTime, options), 'WorkerCron');
|
|
149
211
|
}
|
|
212
|
+
/**
|
|
213
|
+
* Interval decorator that only executes in Worker or Hybrid mode
|
|
214
|
+
*
|
|
215
|
+
* @param timeout - Interval in milliseconds
|
|
216
|
+
* @param name - Optional name for the interval
|
|
217
|
+
*
|
|
218
|
+
* @example
|
|
219
|
+
* ```typescript
|
|
220
|
+
* @WorkerInterval(60000) // Run every minute
|
|
221
|
+
* async minutelyTask() {
|
|
222
|
+
* // Task logic
|
|
223
|
+
* }
|
|
224
|
+
* ```
|
|
225
|
+
*/
|
|
150
226
|
function WorkerInterval(timeout, name) {
|
|
151
227
|
if (name) {
|
|
152
228
|
return createWorkerDecorator((0, schedule_1.Interval)(name, timeout), 'WorkerInterval');
|
|
153
229
|
}
|
|
154
230
|
return createWorkerDecorator((0, schedule_1.Interval)(timeout), 'WorkerInterval');
|
|
155
231
|
}
|
|
232
|
+
/**
|
|
233
|
+
* Timeout decorator that only executes in Worker or Hybrid mode
|
|
234
|
+
*
|
|
235
|
+
* @param timeout - Timeout in milliseconds
|
|
236
|
+
* @param name - Optional name for the timeout
|
|
237
|
+
*
|
|
238
|
+
* @example
|
|
239
|
+
* ```typescript
|
|
240
|
+
* @WorkerTimeout(5000) // Run once after 5 seconds
|
|
241
|
+
* async startupTask() {
|
|
242
|
+
* // Task logic
|
|
243
|
+
* }
|
|
244
|
+
* ```
|
|
245
|
+
*/
|
|
156
246
|
function WorkerTimeout(timeout, name) {
|
|
157
247
|
if (name) {
|
|
158
248
|
return createWorkerDecorator((0, schedule_1.Timeout)(name, timeout), 'WorkerTimeout');
|
|
159
249
|
}
|
|
160
250
|
return createWorkerDecorator((0, schedule_1.Timeout)(timeout), 'WorkerTimeout');
|
|
161
251
|
}
|
|
252
|
+
// ============================================================================
|
|
253
|
+
// Worker Decorators with Lock Support
|
|
254
|
+
// ============================================================================
|
|
255
|
+
/**
|
|
256
|
+
* Cron decorator with distributed lock support
|
|
257
|
+
* Automatically generates lock key from class and method name
|
|
258
|
+
*
|
|
259
|
+
* @param cronTime - Cron expression
|
|
260
|
+
* @param lockKeyOrOptions - Lock key (string) or options object
|
|
261
|
+
* @param lockTtl - Lock TTL in milliseconds (only if lockKeyOrOptions is a string)
|
|
262
|
+
*
|
|
263
|
+
* @param cronOptions
|
|
264
|
+
* @example
|
|
265
|
+
* ```typescript
|
|
266
|
+
* // Using string lock key
|
|
267
|
+
* @WorkerCronWithLock('0 * * * *', 'hourly-task', 3600000)
|
|
268
|
+
* async hourlyTask() {
|
|
269
|
+
* // Task logic
|
|
270
|
+
* }
|
|
271
|
+
*
|
|
272
|
+
* // Using options object (auto-generates lock key)
|
|
273
|
+
* @WorkerCronWithLock('0 * * * *', { lockTtl: 3600000, retryCount: 3 })
|
|
274
|
+
* async hourlyTask() {
|
|
275
|
+
* // Task logic
|
|
276
|
+
* }
|
|
277
|
+
* ```
|
|
278
|
+
*/
|
|
162
279
|
function WorkerCronWithLock(cronTime, lockKeyOrOptions, lockTtl, cronOptions) {
|
|
163
280
|
return function (target, propertyKey, descriptor) {
|
|
164
281
|
let lockKey;
|
|
@@ -174,21 +291,65 @@ function WorkerCronWithLock(cronTime, lockKeyOrOptions, lockTtl, cronOptions) {
|
|
|
174
291
|
return createWorkerDecoratorWithLock((0, schedule_1.Cron)(cronTime, cronOptions), 'WorkerCronWithLock', lockKey, options)(target, propertyKey, descriptor);
|
|
175
292
|
};
|
|
176
293
|
}
|
|
294
|
+
/**
|
|
295
|
+
* Interval decorator with distributed lock support
|
|
296
|
+
*
|
|
297
|
+
* @param timeout - Interval in milliseconds
|
|
298
|
+
* @param lockKeyOrOptions - Lock key (string) or options object
|
|
299
|
+
* @param lockTtl - Lock TTL in milliseconds (only if lockKeyOrOptions is a string)
|
|
300
|
+
*
|
|
301
|
+
* @example
|
|
302
|
+
* ```typescript
|
|
303
|
+
* // Using string lock key
|
|
304
|
+
* @WorkerIntervalWithLock(60000, 'status-check', 50000)
|
|
305
|
+
* async checkStatus() {
|
|
306
|
+
* // Task logic
|
|
307
|
+
* }
|
|
308
|
+
*
|
|
309
|
+
* // Using options object (auto-generates lock key)
|
|
310
|
+
* @WorkerIntervalWithLock(60000, { retryCount: 2 })
|
|
311
|
+
* async checkStatus() {
|
|
312
|
+
* // Task logic
|
|
313
|
+
* }
|
|
314
|
+
* ```
|
|
315
|
+
*/
|
|
177
316
|
function WorkerIntervalWithLock(timeout, lockKeyOrOptions, lockTtl) {
|
|
178
317
|
return function (target, propertyKey, descriptor) {
|
|
179
318
|
let lockKey;
|
|
180
319
|
let options;
|
|
181
320
|
if (typeof lockKeyOrOptions === 'string') {
|
|
182
321
|
lockKey = lockKeyOrOptions;
|
|
183
|
-
options = { lockTtl: lockTtl || Math.floor(timeout * 0.8) };
|
|
322
|
+
options = { lockTtl: lockTtl || Math.max(Math.floor(timeout * 0.8), 10000) };
|
|
184
323
|
}
|
|
185
324
|
else {
|
|
186
325
|
lockKey = generateLockKey(target.constructor.name, String(propertyKey));
|
|
187
|
-
options = Object.assign({ lockTtl: Math.floor(timeout * 0.8) }, lockKeyOrOptions);
|
|
326
|
+
options = Object.assign({ lockTtl: Math.max(Math.floor(timeout * 0.8), 10000) }, lockKeyOrOptions);
|
|
188
327
|
}
|
|
189
328
|
return createWorkerDecoratorWithLock((0, schedule_1.Interval)(timeout), 'WorkerIntervalWithLock', lockKey, options)(target, propertyKey, descriptor);
|
|
190
329
|
};
|
|
191
330
|
}
|
|
331
|
+
/**
|
|
332
|
+
* Timeout decorator with distributed lock support
|
|
333
|
+
*
|
|
334
|
+
* @param timeout - Timeout in milliseconds
|
|
335
|
+
* @param lockKeyOrOptions - Lock key (string) or options object
|
|
336
|
+
* @param lockTtl - Lock TTL in milliseconds (only if lockKeyOrOptions is a string)
|
|
337
|
+
*
|
|
338
|
+
* @example
|
|
339
|
+
* ```typescript
|
|
340
|
+
* // Using string lock key
|
|
341
|
+
* @WorkerTimeoutWithLock(5000, 'init-task', 10000)
|
|
342
|
+
* async initializeSystem() {
|
|
343
|
+
* // Task logic
|
|
344
|
+
* }
|
|
345
|
+
*
|
|
346
|
+
* // Using options object (auto-generates lock key)
|
|
347
|
+
* @WorkerTimeoutWithLock(5000, { lockTtl: 10000 })
|
|
348
|
+
* async initializeSystem() {
|
|
349
|
+
* // Task logic
|
|
350
|
+
* }
|
|
351
|
+
* ```
|
|
352
|
+
*/
|
|
192
353
|
function WorkerTimeoutWithLock(timeout, lockKeyOrOptions, lockTtl) {
|
|
193
354
|
return function (target, propertyKey, descriptor) {
|
|
194
355
|
let lockKey;
|
|
@@ -204,18 +365,80 @@ function WorkerTimeoutWithLock(timeout, lockKeyOrOptions, lockTtl) {
|
|
|
204
365
|
return createWorkerDecoratorWithLock((0, schedule_1.Timeout)(timeout), 'WorkerTimeoutWithLock', lockKey, options)(target, propertyKey, descriptor);
|
|
205
366
|
};
|
|
206
367
|
}
|
|
368
|
+
// ============================================================================
|
|
369
|
+
// Smart Decorators (Recommended)
|
|
370
|
+
// ============================================================================
|
|
371
|
+
/**
|
|
372
|
+
* Smart Cron decorator with auto-generated lock key and intelligent defaults
|
|
373
|
+
* Recommended for most use cases
|
|
374
|
+
*
|
|
375
|
+
* @param cronTime - Cron expression
|
|
376
|
+
* @param options - Schedule options
|
|
377
|
+
*
|
|
378
|
+
* @example
|
|
379
|
+
* ```typescript
|
|
380
|
+
* @WorkerCronSmart('0 * * * *') // Run hourly with auto-generated lock key
|
|
381
|
+
* async hourlyTask() {
|
|
382
|
+
* // Task logic
|
|
383
|
+
* }
|
|
384
|
+
*
|
|
385
|
+
* @WorkerCronSmart('0 0 * * *', {
|
|
386
|
+
* lockTtl: 7200000, // 2 hours
|
|
387
|
+
* retryCount: 3,
|
|
388
|
+
* onError: (error) => console.error('Task failed:', error),
|
|
389
|
+
* })
|
|
390
|
+
* async dailyTask() {
|
|
391
|
+
* // Task logic
|
|
392
|
+
* }
|
|
393
|
+
* ```
|
|
394
|
+
*/
|
|
207
395
|
function WorkerCronSmart(cronTime, options = {}, cronOptions) {
|
|
208
396
|
return function (target, propertyKey, descriptor) {
|
|
209
397
|
const lockKey = generateLockKey(target.constructor.name, String(propertyKey));
|
|
210
398
|
return createWorkerDecoratorWithLock((0, schedule_1.Cron)(cronTime, cronOptions), 'WorkerCronSmart', lockKey, Object.assign({ lockTtl: 3600000, logExecution: true }, options))(target, propertyKey, descriptor);
|
|
211
399
|
};
|
|
212
400
|
}
|
|
401
|
+
/**
|
|
402
|
+
* Smart Interval decorator with auto-generated lock key and intelligent defaults
|
|
403
|
+
* Lock TTL is automatically set to 80% of interval duration
|
|
404
|
+
*
|
|
405
|
+
* @param timeout - Interval in milliseconds
|
|
406
|
+
* @param options - Schedule options
|
|
407
|
+
*
|
|
408
|
+
* @example
|
|
409
|
+
* ```typescript
|
|
410
|
+
* @WorkerIntervalSmart(120000) // Run every 2 minutes, lock for ~1.6 minutes
|
|
411
|
+
* async checkStatus() {
|
|
412
|
+
* // Task logic
|
|
413
|
+
* }
|
|
414
|
+
* ```
|
|
415
|
+
*/
|
|
213
416
|
function WorkerIntervalSmart(timeout, options = {}) {
|
|
214
417
|
return function (target, propertyKey, descriptor) {
|
|
215
418
|
const lockKey = generateLockKey(target.constructor.name, String(propertyKey));
|
|
216
|
-
return createWorkerDecoratorWithLock((0, schedule_1.Interval)(timeout), 'WorkerIntervalSmart', lockKey, Object.assign({ lockTtl: Math.floor(timeout * 0.8), logExecution: true }, options))(target, propertyKey, descriptor);
|
|
419
|
+
return createWorkerDecoratorWithLock((0, schedule_1.Interval)(timeout), 'WorkerIntervalSmart', lockKey, Object.assign({ lockTtl: Math.max(Math.floor(timeout * 0.8), 10000), logExecution: true }, options))(target, propertyKey, descriptor);
|
|
217
420
|
};
|
|
218
421
|
}
|
|
422
|
+
/**
|
|
423
|
+
* Advanced Cron decorator with full control
|
|
424
|
+
* Alias for WorkerCronSmart with explicit lock key parameter
|
|
425
|
+
*
|
|
426
|
+
* @param cronTime - Cron expression
|
|
427
|
+
* @param lockKeyOrOptions - Lock key (string) or options object
|
|
428
|
+
* @param options - Schedule options (only if lockKeyOrOptions is a string)
|
|
429
|
+
*
|
|
430
|
+
* @example
|
|
431
|
+
* ```typescript
|
|
432
|
+
* @WorkerCronAdvanced('0 0 * * *', 'daily-report', {
|
|
433
|
+
* lockTtl: 7200000,
|
|
434
|
+
* retryCount: 5,
|
|
435
|
+
* useExponentialBackoff: true,
|
|
436
|
+
* })
|
|
437
|
+
* async generateDailyReport() {
|
|
438
|
+
* // Task logic
|
|
439
|
+
* }
|
|
440
|
+
* ```
|
|
441
|
+
*/
|
|
219
442
|
function WorkerCronAdvanced(cronTime, lockKeyOrOptions, options, cronOptions) {
|
|
220
443
|
return function (target, propertyKey, descriptor) {
|
|
221
444
|
let lockKey;
|
|
@@ -1,14 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Worker Decorators for Bull Queue Processors
|
|
3
|
+
*
|
|
4
|
+
* These decorators conditionally apply Bull decorators based on the application mode.
|
|
5
|
+
* They only register processors when running in Worker or Hybrid mode.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Conditionally applies Bull's @Processor decorator
|
|
9
|
+
* Only registers the processor class when running in Worker or Hybrid mode
|
|
10
|
+
*
|
|
11
|
+
* @param queueName - Name of the queue to process
|
|
12
|
+
* @param options - Processor options (optional)
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* @WorkerProcessor('email')
|
|
17
|
+
* export class EmailProcessor {
|
|
18
|
+
* @WorkerProcess('send')
|
|
19
|
+
* async sendEmail(job: Job) {
|
|
20
|
+
* // Process email sending
|
|
21
|
+
* }
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
1
25
|
export declare function WorkerProcessor(queueName?: string): ClassDecorator;
|
|
26
|
+
/**
|
|
27
|
+
* Conditionally applies Bull's @Process decorator
|
|
28
|
+
* Only registers the processor method when running in Worker or Hybrid mode
|
|
29
|
+
*
|
|
30
|
+
* @param name - Job name to process (optional)
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* @WorkerProcess('send-email')
|
|
35
|
+
* async sendEmail(job: Job<EmailData>) {
|
|
36
|
+
* // Process job
|
|
37
|
+
* }
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
2
40
|
export declare function WorkerProcess(name?: string): MethodDecorator;
|
|
41
|
+
/**
|
|
42
|
+
* Conditionally applies Bull's @OnQueueActive decorator
|
|
43
|
+
* Only registers when running in Worker or Hybrid mode
|
|
44
|
+
*/
|
|
3
45
|
export declare function WorkerOnQueueActive(): MethodDecorator;
|
|
46
|
+
/**
|
|
47
|
+
* Conditionally applies Bull's @OnQueueCompleted decorator
|
|
48
|
+
* Only registers when running in Worker or Hybrid mode
|
|
49
|
+
*/
|
|
4
50
|
export declare function WorkerOnQueueCompleted(): MethodDecorator;
|
|
51
|
+
/**
|
|
52
|
+
* Conditionally applies Bull's @OnQueueProgress decorator
|
|
53
|
+
* Only registers when running in Worker or Hybrid mode
|
|
54
|
+
*/
|
|
5
55
|
export declare function WorkerOnQueueProgress(): MethodDecorator;
|
|
56
|
+
/**
|
|
57
|
+
* Conditionally applies Bull's @OnQueueFailed decorator
|
|
58
|
+
* Only registers when running in Worker or Hybrid mode
|
|
59
|
+
*/
|
|
6
60
|
export declare function WorkerOnQueueFailed(): MethodDecorator;
|
|
61
|
+
/**
|
|
62
|
+
* Conditionally applies Bull's @OnQueueError decorator
|
|
63
|
+
* Only registers when running in Worker or Hybrid mode
|
|
64
|
+
*/
|
|
7
65
|
export declare function WorkerOnQueueError(): MethodDecorator;
|
|
66
|
+
/**
|
|
67
|
+
* Conditionally applies Bull's @OnQueueWaiting decorator
|
|
68
|
+
* Only registers when running in Worker or Hybrid mode
|
|
69
|
+
*/
|
|
8
70
|
export declare function WorkerOnQueueWaiting(): MethodDecorator;
|
|
71
|
+
/**
|
|
72
|
+
* Conditionally applies Bull's @OnQueueStalled decorator
|
|
73
|
+
* Only registers when running in Worker or Hybrid mode
|
|
74
|
+
*/
|
|
9
75
|
export declare function WorkerOnQueueStalled(): MethodDecorator;
|
|
76
|
+
/**
|
|
77
|
+
* Conditionally applies Bull's @OnQueueRemoved decorator
|
|
78
|
+
* Only registers when running in Worker or Hybrid mode
|
|
79
|
+
*/
|
|
10
80
|
export declare function WorkerOnQueueRemoved(): MethodDecorator;
|
|
81
|
+
/**
|
|
82
|
+
* Conditionally applies Bull's @OnQueueCleaned decorator
|
|
83
|
+
* Only registers when running in Worker or Hybrid mode
|
|
84
|
+
*/
|
|
11
85
|
export declare function WorkerOnQueueCleaned(): MethodDecorator;
|
|
86
|
+
/**
|
|
87
|
+
* Conditionally applies Bull's @OnQueueDrained decorator
|
|
88
|
+
* Only registers when running in Worker or Hybrid mode
|
|
89
|
+
*/
|
|
12
90
|
export declare function WorkerOnQueueDrained(): MethodDecorator;
|
|
91
|
+
/**
|
|
92
|
+
* Conditionally applies Bull's @OnQueuePaused decorator
|
|
93
|
+
* Only registers when running in Worker or Hybrid mode
|
|
94
|
+
*/
|
|
13
95
|
export declare function WorkerOnQueuePaused(): MethodDecorator;
|
|
96
|
+
/**
|
|
97
|
+
* Conditionally applies Bull's @OnQueueResumed decorator
|
|
98
|
+
* Only registers when running in Worker or Hybrid mode
|
|
99
|
+
*/
|
|
14
100
|
export declare function WorkerOnQueueResumed(): MethodDecorator;
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Worker Decorators for Bull Queue Processors
|
|
4
|
+
*
|
|
5
|
+
* These decorators conditionally apply Bull decorators based on the application mode.
|
|
6
|
+
* They only register processors when running in Worker or Hybrid mode.
|
|
7
|
+
*/
|
|
2
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
9
|
exports.WorkerProcessor = WorkerProcessor;
|
|
4
10
|
exports.WorkerProcess = WorkerProcess;
|
|
@@ -16,22 +22,60 @@ exports.WorkerOnQueuePaused = WorkerOnQueuePaused;
|
|
|
16
22
|
exports.WorkerOnQueueResumed = WorkerOnQueueResumed;
|
|
17
23
|
const bull_1 = require("@nestjs/bull");
|
|
18
24
|
const mode_setup_1 = require("./mode.setup");
|
|
25
|
+
/**
|
|
26
|
+
* Conditionally applies Bull's @Processor decorator
|
|
27
|
+
* Only registers the processor class when running in Worker or Hybrid mode
|
|
28
|
+
*
|
|
29
|
+
* @param queueName - Name of the queue to process
|
|
30
|
+
* @param options - Processor options (optional)
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* @WorkerProcessor('email')
|
|
35
|
+
* export class EmailProcessor {
|
|
36
|
+
* @WorkerProcess('send')
|
|
37
|
+
* async sendEmail(job: Job) {
|
|
38
|
+
* // Process email sending
|
|
39
|
+
* }
|
|
40
|
+
* }
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
19
43
|
function WorkerProcessor(queueName) {
|
|
20
44
|
if ((0, mode_setup_1.shouldProcessQueues)()) {
|
|
21
45
|
return (0, bull_1.Processor)(queueName);
|
|
22
46
|
}
|
|
47
|
+
// In HTTP-only mode, return a no-op decorator
|
|
23
48
|
return function (constructor) {
|
|
24
49
|
return constructor;
|
|
25
50
|
};
|
|
26
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* Conditionally applies Bull's @Process decorator
|
|
54
|
+
* Only registers the processor method when running in Worker or Hybrid mode
|
|
55
|
+
*
|
|
56
|
+
* @param name - Job name to process (optional)
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```typescript
|
|
60
|
+
* @WorkerProcess('send-email')
|
|
61
|
+
* async sendEmail(job: Job<EmailData>) {
|
|
62
|
+
* // Process job
|
|
63
|
+
* }
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
27
66
|
function WorkerProcess(name) {
|
|
28
67
|
if ((0, mode_setup_1.shouldProcessQueues)()) {
|
|
29
68
|
return (0, bull_1.Process)(name);
|
|
30
69
|
}
|
|
70
|
+
// In HTTP-only mode, return a no-op decorator
|
|
31
71
|
return function (target, propertyKey, descriptor) {
|
|
32
72
|
return descriptor;
|
|
33
73
|
};
|
|
34
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* Conditionally applies Bull's @OnQueueActive decorator
|
|
77
|
+
* Only registers when running in Worker or Hybrid mode
|
|
78
|
+
*/
|
|
35
79
|
function WorkerOnQueueActive() {
|
|
36
80
|
if ((0, mode_setup_1.shouldProcessQueues)()) {
|
|
37
81
|
return (0, bull_1.OnQueueActive)();
|
|
@@ -40,6 +84,10 @@ function WorkerOnQueueActive() {
|
|
|
40
84
|
return descriptor;
|
|
41
85
|
};
|
|
42
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* Conditionally applies Bull's @OnQueueCompleted decorator
|
|
89
|
+
* Only registers when running in Worker or Hybrid mode
|
|
90
|
+
*/
|
|
43
91
|
function WorkerOnQueueCompleted() {
|
|
44
92
|
if ((0, mode_setup_1.shouldProcessQueues)()) {
|
|
45
93
|
return (0, bull_1.OnQueueCompleted)();
|
|
@@ -48,6 +96,10 @@ function WorkerOnQueueCompleted() {
|
|
|
48
96
|
return descriptor;
|
|
49
97
|
};
|
|
50
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* Conditionally applies Bull's @OnQueueProgress decorator
|
|
101
|
+
* Only registers when running in Worker or Hybrid mode
|
|
102
|
+
*/
|
|
51
103
|
function WorkerOnQueueProgress() {
|
|
52
104
|
if ((0, mode_setup_1.shouldProcessQueues)()) {
|
|
53
105
|
return (0, bull_1.OnQueueProgress)();
|
|
@@ -56,6 +108,10 @@ function WorkerOnQueueProgress() {
|
|
|
56
108
|
return descriptor;
|
|
57
109
|
};
|
|
58
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* Conditionally applies Bull's @OnQueueFailed decorator
|
|
113
|
+
* Only registers when running in Worker or Hybrid mode
|
|
114
|
+
*/
|
|
59
115
|
function WorkerOnQueueFailed() {
|
|
60
116
|
if ((0, mode_setup_1.shouldProcessQueues)()) {
|
|
61
117
|
return (0, bull_1.OnQueueFailed)();
|
|
@@ -64,6 +120,10 @@ function WorkerOnQueueFailed() {
|
|
|
64
120
|
return descriptor;
|
|
65
121
|
};
|
|
66
122
|
}
|
|
123
|
+
/**
|
|
124
|
+
* Conditionally applies Bull's @OnQueueError decorator
|
|
125
|
+
* Only registers when running in Worker or Hybrid mode
|
|
126
|
+
*/
|
|
67
127
|
function WorkerOnQueueError() {
|
|
68
128
|
if ((0, mode_setup_1.shouldProcessQueues)()) {
|
|
69
129
|
return (0, bull_1.OnQueueError)();
|
|
@@ -72,6 +132,10 @@ function WorkerOnQueueError() {
|
|
|
72
132
|
return descriptor;
|
|
73
133
|
};
|
|
74
134
|
}
|
|
135
|
+
/**
|
|
136
|
+
* Conditionally applies Bull's @OnQueueWaiting decorator
|
|
137
|
+
* Only registers when running in Worker or Hybrid mode
|
|
138
|
+
*/
|
|
75
139
|
function WorkerOnQueueWaiting() {
|
|
76
140
|
if ((0, mode_setup_1.shouldProcessQueues)()) {
|
|
77
141
|
return (0, bull_1.OnQueueWaiting)();
|
|
@@ -80,6 +144,10 @@ function WorkerOnQueueWaiting() {
|
|
|
80
144
|
return descriptor;
|
|
81
145
|
};
|
|
82
146
|
}
|
|
147
|
+
/**
|
|
148
|
+
* Conditionally applies Bull's @OnQueueStalled decorator
|
|
149
|
+
* Only registers when running in Worker or Hybrid mode
|
|
150
|
+
*/
|
|
83
151
|
function WorkerOnQueueStalled() {
|
|
84
152
|
if ((0, mode_setup_1.shouldProcessQueues)()) {
|
|
85
153
|
return (0, bull_1.OnQueueStalled)();
|
|
@@ -88,6 +156,10 @@ function WorkerOnQueueStalled() {
|
|
|
88
156
|
return descriptor;
|
|
89
157
|
};
|
|
90
158
|
}
|
|
159
|
+
/**
|
|
160
|
+
* Conditionally applies Bull's @OnQueueRemoved decorator
|
|
161
|
+
* Only registers when running in Worker or Hybrid mode
|
|
162
|
+
*/
|
|
91
163
|
function WorkerOnQueueRemoved() {
|
|
92
164
|
if ((0, mode_setup_1.shouldProcessQueues)()) {
|
|
93
165
|
return (0, bull_1.OnQueueRemoved)();
|
|
@@ -96,6 +168,10 @@ function WorkerOnQueueRemoved() {
|
|
|
96
168
|
return descriptor;
|
|
97
169
|
};
|
|
98
170
|
}
|
|
171
|
+
/**
|
|
172
|
+
* Conditionally applies Bull's @OnQueueCleaned decorator
|
|
173
|
+
* Only registers when running in Worker or Hybrid mode
|
|
174
|
+
*/
|
|
99
175
|
function WorkerOnQueueCleaned() {
|
|
100
176
|
if ((0, mode_setup_1.shouldProcessQueues)()) {
|
|
101
177
|
return (0, bull_1.OnQueueCleaned)();
|
|
@@ -104,6 +180,10 @@ function WorkerOnQueueCleaned() {
|
|
|
104
180
|
return descriptor;
|
|
105
181
|
};
|
|
106
182
|
}
|
|
183
|
+
/**
|
|
184
|
+
* Conditionally applies Bull's @OnQueueDrained decorator
|
|
185
|
+
* Only registers when running in Worker or Hybrid mode
|
|
186
|
+
*/
|
|
107
187
|
function WorkerOnQueueDrained() {
|
|
108
188
|
if ((0, mode_setup_1.shouldProcessQueues)()) {
|
|
109
189
|
return (0, bull_1.OnQueueDrained)();
|
|
@@ -112,6 +192,10 @@ function WorkerOnQueueDrained() {
|
|
|
112
192
|
return descriptor;
|
|
113
193
|
};
|
|
114
194
|
}
|
|
195
|
+
/**
|
|
196
|
+
* Conditionally applies Bull's @OnQueuePaused decorator
|
|
197
|
+
* Only registers when running in Worker or Hybrid mode
|
|
198
|
+
*/
|
|
115
199
|
function WorkerOnQueuePaused() {
|
|
116
200
|
if ((0, mode_setup_1.shouldProcessQueues)()) {
|
|
117
201
|
return (0, bull_1.OnQueuePaused)();
|
|
@@ -120,6 +204,10 @@ function WorkerOnQueuePaused() {
|
|
|
120
204
|
return descriptor;
|
|
121
205
|
};
|
|
122
206
|
}
|
|
207
|
+
/**
|
|
208
|
+
* Conditionally applies Bull's @OnQueueResumed decorator
|
|
209
|
+
* Only registers when running in Worker or Hybrid mode
|
|
210
|
+
*/
|
|
123
211
|
function WorkerOnQueueResumed() {
|
|
124
212
|
if ((0, mode_setup_1.shouldProcessQueues)()) {
|
|
125
213
|
return (0, bull_1.OnQueueResumed)();
|