@lokalise/background-jobs-common
Advanced tools
Comparing version 2.0.6 to 3.0.0
@@ -13,3 +13,3 @@ import type { CommonLogger } from '@lokalise/node-core'; | ||
private readonly redis; | ||
private readonly newRelicBackgroundTransactionManager; | ||
private readonly transactionObservabilityManager; | ||
private readonly errorReporter; | ||
@@ -16,0 +16,0 @@ private readonly config; |
@@ -40,3 +40,3 @@ "use strict"; | ||
redis; | ||
newRelicBackgroundTransactionManager; | ||
transactionObservabilityManager; | ||
errorReporter; | ||
@@ -52,3 +52,3 @@ config; | ||
this.redis = dependencies.redis; | ||
this.newRelicBackgroundTransactionManager = dependencies.transactionObservabilityManager; | ||
this.transactionObservabilityManager = dependencies.transactionObservabilityManager; | ||
this.logger = dependencies.logger; | ||
@@ -116,2 +116,3 @@ this.errorReporter = dependencies.errorReporter; | ||
catch { | ||
/* v8 ignore next 3 */ | ||
// do nothing | ||
@@ -132,7 +133,7 @@ } | ||
queueId: this.config.queueId, | ||
}, 'Processor ${this.constructor.name} is not started, starting with lazy loading'); | ||
}, `Processor ${this.constructor.name} is not started, starting with lazy loading`); | ||
await this.start(); | ||
} | ||
const jobs = await this.queue?.addBulk(jobData.map((data) => ({ | ||
name: this.constructor.name, | ||
name: this.config.queueId, | ||
data, | ||
@@ -142,2 +143,3 @@ opts: this.prepareJobOptions(options ?? {}), | ||
const jobIds = jobs?.map((job) => job.id) ?? []; | ||
/* v8 ignore next 3 */ | ||
if (jobIds.length === 0 || !jobIds.every((id) => !!id)) { | ||
@@ -156,2 +158,3 @@ // Practically unreachable, but we want to simplify the signature of the method and avoid | ||
}; | ||
/* v8 ignore next 7 */ | ||
if (this.config.isTest && typeof preparedOptions.backoff === 'object') { | ||
@@ -177,3 +180,4 @@ preparedOptions.backoff.delay = 1; | ||
try { | ||
this.newRelicBackgroundTransactionManager.start(job.name); | ||
const transactionName = `bg_job:${this.config.ownerName}:${this.config.queueId}`; | ||
this.transactionObservabilityManager.start(transactionName, jobId); | ||
job.requestContext.logger.info({ | ||
@@ -190,3 +194,3 @@ origin: this.constructor.name, | ||
job.requestContext.logger.info({ isSuccess, jobId }, `Finished job ${job.name}`); | ||
this.newRelicBackgroundTransactionManager.stop(job.name); | ||
this.transactionObservabilityManager.stop(jobId); | ||
} | ||
@@ -193,0 +197,0 @@ } |
@@ -11,3 +11,7 @@ "use strict"; | ||
redis: dependencies.redis, | ||
transactionObservabilityManager: { start: () => { }, stop: () => { } }, | ||
transactionObservabilityManager: { | ||
start: () => { }, | ||
startWithGroup: () => { }, | ||
stop: () => { }, | ||
}, | ||
logger: dependencies.logger, | ||
@@ -18,2 +22,3 @@ errorReporter: dependencies.errorReporter, | ||
queueId: queueName, | ||
ownerName: 'testOwner', | ||
isTest, | ||
@@ -20,0 +25,0 @@ workerOptions: { concurrency: 1 }, |
@@ -1,2 +0,2 @@ | ||
import type { CommonLogger, ErrorReporter } from '@lokalise/node-core'; | ||
import type { CommonLogger, ErrorReporter, TransactionObservabilityManager } from '@lokalise/node-core'; | ||
import type { Job, FinishedStatus, Queue, QueueOptions, Worker, WorkerOptions, JobsOptions } from 'bullmq'; | ||
@@ -10,9 +10,7 @@ import type Redis from 'ioredis'; | ||
isTest: boolean; | ||
ownerName: string; | ||
queueOptions?: Partial<QueueOptionsType>; | ||
workerOptions: Partial<WorkerOptionsType>; | ||
}; | ||
export type TransactionObservabilityManager = { | ||
start: (transactionSpanId: string) => unknown; | ||
stop: (transactionSpanId: string) => unknown; | ||
}; | ||
export { TransactionObservabilityManager }; | ||
export type SafeJob<T = any, R = any, N extends string = string> = Omit<Job<T, R, N>, 'scripts'> & { | ||
@@ -19,0 +17,0 @@ requestContext?: RequestContext; |
{ | ||
"name": "@lokalise/background-jobs-common", | ||
"version": "2.0.6", | ||
"version": "3.0.0", | ||
"files": [ | ||
@@ -38,4 +38,4 @@ "dist", | ||
"@lokalise/id-utils": "1.0.0", | ||
"@lokalise/node-core": "^9.16.0", | ||
"pino": "^8.21.0", | ||
"@lokalise/node-core": "^9.17.0", | ||
"pino": "^9.0.0", | ||
"ts-deepmerge": "^7.0.0" | ||
@@ -49,3 +49,3 @@ }, | ||
"@lokalise/eslint-config": "latest", | ||
"@lokalise/fastify-extras": "^17.0.3", | ||
"@lokalise/fastify-extras": "^20.0.0", | ||
"@lokalise/prettier-config": "latest", | ||
@@ -59,5 +59,5 @@ "@lokalise/package-vite-config": "latest", | ||
"typescript": "5.4.5", | ||
"vitest": "^1.5.0" | ||
"vitest": "^1.5.2" | ||
}, | ||
"prettier": "@lokalise/prettier-config" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
48255
736
- Removedabort-controller@3.0.0(transitive)
- Removedbase64-js@1.5.1(transitive)
- Removedbuffer@6.0.3(transitive)
- Removedevent-target-shim@5.0.1(transitive)
- Removedevents@3.3.0(transitive)
- Removedieee754@1.2.1(transitive)
- Removedpino@8.21.0(transitive)
- Removedpino-abstract-transport@1.2.0(transitive)
- Removedpino-std-serializers@6.2.2(transitive)
- Removedprocess@0.11.10(transitive)
- Removedprocess-warning@3.0.0(transitive)
- Removedreadable-stream@4.5.2(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedsonic-boom@3.8.1(transitive)
- Removedstring_decoder@1.3.0(transitive)
- Removedthread-stream@2.7.0(transitive)
Updated@lokalise/node-core@^9.17.0
Updatedpino@^9.0.0