Skip to content

Commit 1bec4e1

Browse files
committed
Getting the queues indexing to work by passing them to the create background worker request bodies
1 parent 7e411ac commit 1bec4e1

File tree

6 files changed

+27
-5
lines changed

6 files changed

+27
-5
lines changed

packages/cli-v3/src/dev/devSupervisor.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ class DevSupervisor implements WorkerRuntime {
113113

114114
async initializeWorker(manifest: BuildManifest, stop: () => void): Promise<void> {
115115
if (this.lastManifest && this.lastManifest.contentHash === manifest.contentHash) {
116+
logger.debug("worker skipped", { lastManifestContentHash: this.lastManifest?.contentHash });
116117
eventBus.emit("workerSkipped");
117118
stop();
118119
return;
@@ -126,6 +127,8 @@ class DevSupervisor implements WorkerRuntime {
126127
stop,
127128
});
128129

130+
logger.debug("initializing background worker", { manifest });
131+
129132
await backgroundWorker.initialize();
130133

131134
if (!backgroundWorker.manifest) {
@@ -153,6 +156,7 @@ class DevSupervisor implements WorkerRuntime {
153156
packageVersion: manifest.packageVersion,
154157
cliPackageVersion: manifest.cliPackageVersion,
155158
tasks: backgroundWorker.manifest.tasks,
159+
queues: backgroundWorker.manifest.queues,
156160
contentHash: manifest.contentHash,
157161
sourceFiles,
158162
},

packages/cli-v3/src/entryPoints/managed-index-controller.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ async function indexDeployment({
9595
packageVersion: buildManifest.packageVersion,
9696
cliPackageVersion: buildManifest.cliPackageVersion,
9797
tasks: workerManifest.tasks,
98+
queues: workerManifest.queues,
9899
sourceFiles,
99100
},
100101
engine: "V2",

packages/core/src/v3/types/tasks.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,10 @@ type CommonTaskOptions<
193193
});
194194
* ```
195195
*/
196-
queue?: Queue;
196+
queue?: {
197+
name?: string;
198+
concurrencyLimit?: number;
199+
};
197200
/** Configure the spec of the [machine](https://trigger.dev/docs/machines) you want your task to run on.
198201
*
199202
* @example

packages/trigger-sdk/src/v3/shared.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,13 @@ export function createTask<
219219
},
220220
});
221221

222-
if (params.queue) {
223-
resourceCatalog.registerQueueMetadata(params.queue);
222+
const queue = params.queue;
223+
224+
if (queue && typeof queue.name === "string") {
225+
resourceCatalog.registerQueueMetadata({
226+
name: queue.name,
227+
concurrencyLimit: queue.concurrencyLimit,
228+
});
224229
}
225230

226231
// @ts-expect-error
@@ -363,6 +368,15 @@ export function createSchemaTask<
363368
},
364369
});
365370

371+
const queue = params.queue;
372+
373+
if (queue && typeof queue.name === "string") {
374+
resourceCatalog.registerQueueMetadata({
375+
name: queue.name,
376+
concurrencyLimit: queue.concurrencyLimit,
377+
});
378+
}
379+
366380
// @ts-expect-error
367381
task[Symbol.for("trigger.dev/task")] = true;
368382

references/hello-world/src/trigger/priority.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { logger, task } from "@trigger.dev/sdk/v3";
33
export const priorityParent = task({
44
id: "priority-parent",
55
run: async (payload: any, { ctx }) => {
6-
logger.log("Hello, world from the parent", { payload });
6+
logger.log("Hello, world from the parents", { payload });
77

88
const batch1 = await priorityChild.batchTriggerAndWait([
99
{

references/hello-world/src/trigger/queues.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const queuesTester = task({
1010
}
1111

1212
const retrievedFromId = await queues.retrieve(ctx.queue.id);
13-
logger.log("Retrieved from ID", { retrievedFromId });
13+
logger.log("Retrieved from IDs", { retrievedFromId });
1414

1515
const retrievedFromCtxName = await queues.retrieve({
1616
type: "task",

0 commit comments

Comments
 (0)