@miniflare/queues
Advanced tools
Comparing version 2.13.0 to 2.14.0
@@ -67,2 +67,3 @@ import { Consumer } from '@miniflare/shared'; | ||
getOrCreateQueue(name: string): WorkerQueue; | ||
resetConsumers(): void; | ||
setConsumer(queue: WorkerQueue, consumer: Consumer): void; | ||
@@ -82,2 +83,3 @@ } | ||
export declare class QueuesPlugin extends Plugin<QueuesOptions> implements QueuesOptions { | ||
#private; | ||
queueBindings?: BindingOptions[]; | ||
@@ -87,2 +89,3 @@ queueConsumers?: (string | ConsumerOptions)[]; | ||
setup(_storageFactory: StorageFactory): Promise<SetupResult>; | ||
beforeReload(): void; | ||
} | ||
@@ -95,3 +98,3 @@ | ||
sendBatch(batch: Iterable<MessageSendRequest<Body>>): Promise<void>; | ||
[kSetConsumer](consumer: Consumer): void; | ||
[kSetConsumer](consumer?: Consumer): void; | ||
[kGetConsumer](): Consumer | null; | ||
@@ -98,0 +101,0 @@ [kSetFlushCallback](callback: () => void): void; |
@@ -56,2 +56,3 @@ var __create = Object.create; | ||
queueConsumers; | ||
#consumers; | ||
constructor(ctx, options) { | ||
@@ -63,5 +64,3 @@ super(ctx); | ||
} | ||
} | ||
async setup(_storageFactory) { | ||
for (const entry of this.queueConsumers ?? []) { | ||
this.#consumers = (this.queueConsumers ?? []).map((entry) => { | ||
let opts; | ||
@@ -75,3 +74,3 @@ if (typeof entry === "string") { | ||
} | ||
const consumer = { | ||
return { | ||
queueName: opts.queueName, | ||
@@ -84,5 +83,5 @@ maxBatchSize: opts.maxBatchSize ?? DEFAULT_BATCH_SIZE, | ||
}; | ||
const queue = this.ctx.queueBroker.getOrCreateQueue(opts.queueName); | ||
this.ctx.queueBroker.setConsumer(queue, consumer); | ||
} | ||
}); | ||
} | ||
async setup(_storageFactory) { | ||
const bindings = {}; | ||
@@ -92,4 +91,11 @@ for (const binding of this.queueBindings ?? []) { | ||
} | ||
return { bindings }; | ||
const requiresModuleExports = this.#consumers.length > 0; | ||
return { bindings, requiresModuleExports }; | ||
} | ||
beforeReload() { | ||
for (const consumer of this.#consumers) { | ||
const queue = this.ctx.queueBroker.getOrCreateQueue(consumer.queueName); | ||
this.ctx.queueBroker.setConsumer(queue, consumer); | ||
} | ||
} | ||
}; | ||
@@ -220,2 +226,8 @@ __decorateClass([ | ||
[import_shared2.kSetConsumer](consumer) { | ||
if (consumer === void 0) { | ||
clearTimeout(this.#timeout); | ||
this.#pendingFlush = 0; | ||
this.#consumer = void 0; | ||
return; | ||
} | ||
if (this.#consumer) { | ||
@@ -329,2 +341,6 @@ throw new QueueError("ERR_CONSUMER_ALREADY_SET"); | ||
} | ||
resetConsumers() { | ||
for (const queue of this.#queues.values()) | ||
queue[import_shared2.kSetConsumer](); | ||
} | ||
setConsumer(queue, consumer) { | ||
@@ -331,0 +347,0 @@ queue[import_shared2.kSetConsumer](consumer); |
{ | ||
"name": "@miniflare/queues", | ||
"version": "2.13.0", | ||
"version": "2.14.0", | ||
"description": "Workers Queues module for Miniflare: a fun, full-featured, fully-local simulator for Cloudflare Workers", | ||
@@ -38,7 +38,7 @@ "keywords": [ | ||
"dependencies": { | ||
"@miniflare/shared": "2.13.0" | ||
"@miniflare/shared": "2.14.0" | ||
}, | ||
"devDependencies": { | ||
"@miniflare/shared-test": "2.13.0" | ||
"@miniflare/shared-test": "2.14.0" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
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
20358
435
+ Added@miniflare/shared@2.14.0(transitive)
- Removed@miniflare/shared@2.13.0(transitive)
Updated@miniflare/shared@2.14.0