Skip to content

Commit

Permalink
fix: worker start pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
grutt committed Feb 2, 2024
1 parent 0daabf8 commit 31be848
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
4 changes: 3 additions & 1 deletion typescript-sdk/examples/concurrency-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,6 @@ const workflow: Workflow = {
],
};

hatchet.run(workflow);
const worker = hatchet.worker('example-worker');
worker.registerWorkflow(workflow);
worker.start();
4 changes: 3 additions & 1 deletion typescript-sdk/examples/dag-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,6 @@ const workflow: Workflow = {
],
};

hatchet.run(workflow);
const worker = hatchet.worker('example-worker');
worker.registerWorkflow(workflow);
worker.start();
4 changes: 3 additions & 1 deletion typescript-sdk/examples/simple-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,6 @@ const workflow: Workflow = {
],
};

hatchet.run(workflow);
const worker = hatchet.worker('example-worker');
worker.registerWorkflow(workflow);
worker.start();
4 changes: 2 additions & 2 deletions typescript-sdk/src/clients/hatchet-client/hatchet-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,14 @@ export class HatchetClient {
return worker;
}

async worker(workflow: string | Workflow): Promise<Worker> {
worker(workflow: string | Workflow): Worker {
const name = typeof workflow === 'string' ? workflow : workflow.id;
const worker = new Worker(this, {
name,
});

if (typeof workflow !== 'string') {
await worker.registerWorkflow(workflow);
worker.registerWorkflow(workflow);
return worker;
}

Expand Down

0 comments on commit 31be848

Please sign in to comment.