-
Notifications
You must be signed in to change notification settings - Fork 6
/
worker.ts
31 lines (30 loc) · 1 KB
/
worker.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
31
// @@@SNIPSTART money-transfer-project-template-ts-worker-promises
import fs from "fs/promises";
// @@@SNIPEND
// @@@SNIPSTART money-transfer-project-template-ts-worker-nativeconnection
import { Worker, NativeConnection } from "@temporalio/worker";
// @@@SNIPEND
import * as activities from "./activities";
import { namespace, taskQueueName } from './shared';
async function run() {
// @@@SNIPSTART money-transfer-project-template-ts-worker-connect-to-cloud
const connection = await NativeConnection.connect({
address: process.env.TEMPORAL_ADDRESS!,
tls: {
clientCertPair: {
crt: await fs.readFile(process.env.TEMPORAL_MTLS_TLS_CERT!),
key: await fs.readFile(process.env.TEMPORAL_MTLS_TLS_KEY!),
},
},
});
// @@@SNIPEND
const worker = await Worker.create({
connection,
namespace: process.env.TEMPORAL_NAMESPACE!,
taskQueue: taskQueueName,,
workflowsPath: require.resolve("./workflows"),
activities,
});
await worker.run();
await connection.close();
}