Skip to content

Commit

Permalink
use nanoid for workflow ids (temporalio#131)
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 authored Apr 12, 2022
1 parent b601ce6 commit d72ab5b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions grpc-calls/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
]
},
"dependencies": {
"nanoid": "3.x",
"temporalio": "0.20.x"
},
"devDependencies": {
Expand Down
5 changes: 3 additions & 2 deletions grpc-calls/src/client.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Connection } from '@temporalio/client';
import { defaultPayloadConverter, toPayloads } from '@temporalio/common';
import { nanoid } from 'nanoid';

async function run() {
const workflowId = 'wf-id-' + Math.floor(Math.random() * 1000);
const requestId = 'request-id-' + Math.floor(Math.random() * 1000);
const workflowId = 'workflow-' + nanoid();
const requestId = 'request-' + nanoid();
// @@@SNIPSTART typescript-grpc-call-basic
const connection = new Connection();

Expand Down
1 change: 1 addition & 0 deletions hello-world/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
]
},
"dependencies": {
"nanoid": "3.x",
"temporalio": "0.20.x"
},
"devDependencies": {
Expand Down
3 changes: 2 additions & 1 deletion hello-world/src/client.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// @@@SNIPSTART typescript-hello-client
import { Connection, WorkflowClient } from '@temporalio/client';
import { example } from './workflows';
import { nanoid } from 'nanoid';

async function run() {
const connection = new Connection({
Expand All @@ -18,7 +19,7 @@ async function run() {
args: ['Temporal'], // type inference works! args: [name: string]
taskQueue: 'hello-world',
// in practice, use a meaningful business id, eg customerId or transactionId
workflowId: 'wf-id-' + Math.floor(Math.random() * 1000),
workflowId: 'workflow-' + nanoid(),
});
console.log(`Started workflow ${handle.workflowId}`);

Expand Down

0 comments on commit d72ab5b

Please sign in to comment.