//#region src/cf-queues.ts
async function enqueue(queue, body) {
	await queue.send(body);
}
function resolveQueue(bindings, name) {
	const queue = bindings[name];
	if (!queue) throw new Error(`queue binding not found: ${name}`);
	return queue;
}
async function consume(registry, batch, env, opts) {
	for (const msg of batch.messages) try {
		await registry.dispatch(env, msg.body, opts);
		msg.ack();
	} catch {
		msg.retry();
	}
}
//#endregion
export { consume, enqueue, resolveQueue };
