-
Notifications
You must be signed in to change notification settings - Fork 130
/
Copy pathclient.ts
30 lines (25 loc) · 870 Bytes
/
client.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// @@@SNIPSTART typescript-protobuf-client
import { Client } from '@temporalio/client';
import { v4 as uuid } from 'uuid';
import { foo, ProtoResult } from '../protos/root';
import { example } from './workflows';
async function run() {
const client = new Client({
dataConverter: { payloadConverterPath: require.resolve('./payload-converter') },
});
const handle = await client.workflow.start(example, {
args: [foo.bar.ProtoInput.create({ name: 'Proto', age: 2 })],
// can't do:
// args: [new foo.bar.ProtoInput({ name: 'Proto', age: 2 })],
taskQueue: 'protobufs',
workflowId: 'my-business-id-' + uuid(),
});
console.log(`Started workflow ${handle.workflowId}`);
const result: ProtoResult = await handle.result();
console.log(result.toJSON());
}
// @@@SNIPEND
run().catch((err) => {
console.error(err);
process.exit(1);
});