| 19 | } |
| 20 | |
| 21 | export class LocalQueueProvider implements QueueProvider { |
| 22 | readonly providerName = 'local' as const; |
| 23 | |
| 24 | constructor(private readonly store: JobStore = jobStore) {} |
| 25 | |
| 26 | async publish(message: QueueJobMessage, options: PublishOptions = {}): Promise<void> { |
| 27 | const job = await this.store.get(message.jobId); |
| 28 | if (!job) { |
| 29 | throw new Error(`Cannot publish unknown job: ${message.jobId}`); |
| 30 | } |
| 31 | if (options.delaySeconds && options.delaySeconds > 0) { |
| 32 | await this.store.transition(message.jobId, 'retry_wait', { |
| 33 | queuedAt: new Date(Date.now() + options.delaySeconds * 1000).toISOString(), |
| 34 | }); |
| 35 | return; |
| 36 | } |
| 37 | if (job.status === 'queued') return; |
| 38 | await this.store.transition(message.jobId, 'queued', { |
| 39 | queuedAt: new Date().toISOString(), |
| 40 | }); |
| 41 | } |
| 42 | |
| 43 | async claimNext(input: ClaimJobInput): Promise<CloudJob | undefined> { |
| 44 | return this.store.claimNext(input); |
| 45 | } |
| 46 | |
| 47 | async complete(_job: CloudJob): Promise<void> { |
| 48 | return Promise.resolve(); |
| 49 | } |
| 50 | |
| 51 | async release(_job: CloudJob, _options: PublishOptions = {}): Promise<void> { |
| 52 | return Promise.resolve(); |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | export class TencentCmqQueueProvider implements QueueProvider { |
| 57 | readonly providerName = 'tdmq-cmq' as const; |
nothing calls this directly
no outgoing calls
no test coverage detected