Skip to content

Commit 9d287a2

Browse files
authored
update samples to use env config to configure clients (#440)
* update samples to use env config to configure clients * update pnpm lock file * add small comment
1 parent 16f826f commit 9d287a2

File tree

100 files changed

+415
-144
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+415
-144
lines changed

activities-cancellation-heartbeating/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"dependencies": {
2525
"@temporalio/activity": "^1.13.2",
2626
"@temporalio/client": "^1.13.2",
27+
"@temporalio/envconfig": "^1.13.2",
2728
"@temporalio/worker": "^1.13.2",
2829
"@temporalio/workflow": "^1.13.2"
2930
},

activities-cancellation-heartbeating/src/client.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import { Connection, Client, WorkflowFailedError, CancelledFailure } from '@temporalio/client';
2+
import { loadClientConnectConfig } from '@temporalio/envconfig';
23
import { runCancellableActivity } from './workflows';
34
import { setTimeout } from 'timers/promises';
45

56
async function run() {
6-
const connection = await Connection.connect();
7+
const config = loadClientConnectConfig();
8+
const connection = await Connection.connect(config.connectionOptions);
79
const client = new Client({ connection });
810

911
const handle = await client.workflow.start(runCancellableActivity, {

activities-dependency-injection/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"dependencies": {
2525
"@temporalio/activity": "^1.13.2",
2626
"@temporalio/client": "^1.13.2",
27+
"@temporalio/envconfig": "^1.13.2",
2728
"@temporalio/worker": "^1.13.2",
2829
"@temporalio/workflow": "^1.13.2"
2930
},

activities-dependency-injection/src/client.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
import { Client } from '@temporalio/client';
1+
import { Client, Connection } from '@temporalio/client';
2+
import { loadClientConnectConfig } from '@temporalio/envconfig';
23
import { dependencyWF } from './workflows';
34

45
async function run(): Promise<void> {
5-
const client = new Client();
6+
const config = loadClientConnectConfig();
7+
const connection = await Connection.connect(config.connectionOptions);
8+
const client = new Client({ connection });
69

710
const result = await client.workflow.execute(dependencyWF, {
811
taskQueue: 'dependency-injection',

activities-examples/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"@temporalio/activity": "^1.13.2",
3030
"@temporalio/client": "^1.13.2",
3131
"@temporalio/common": "^1.13.2",
32+
"@temporalio/envconfig": "^1.13.2",
3233
"@temporalio/worker": "^1.13.2",
3334
"@temporalio/workflow": "^1.13.2",
3435
"axios": "^0.28.0",

activities-examples/src/client.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
import { Client } from '@temporalio/client';
1+
import { Client, Connection } from '@temporalio/client';
2+
import { loadClientConnectConfig } from '@temporalio/envconfig';
23
import { asyncActivityWorkflow, httpWorkflow } from './workflows';
34

45
async function run(): Promise<void> {
5-
const client = new Client();
6+
const config = loadClientConnectConfig();
7+
const connection = await Connection.connect(config.connectionOptions);
8+
const client = new Client({ connection });
69

710
let result = await client.workflow.execute(httpWorkflow, {
811
taskQueue: 'activities-examples',

child-workflows/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"dependencies": {
2525
"@temporalio/activity": "^1.13.2",
2626
"@temporalio/client": "^1.13.2",
27+
"@temporalio/envconfig": "^1.13.2",
2728
"@temporalio/worker": "^1.13.2",
2829
"@temporalio/workflow": "^1.13.2"
2930
},

child-workflows/src/client.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
import { Client } from '@temporalio/client';
1+
import { Client, Connection } from '@temporalio/client';
2+
import { loadClientConnectConfig } from '@temporalio/envconfig';
23
import { parentWorkflow } from './workflows';
34

45
async function run() {
5-
const client = new Client();
6+
const config = loadClientConnectConfig();
7+
const connection = await Connection.connect(config.connectionOptions);
8+
const client = new Client({ connection });
69

710
const result = await client.workflow.execute(parentWorkflow, {
811
taskQueue: 'child-workflows',

continue-as-new/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"dependencies": {
2525
"@temporalio/activity": "^1.13.2",
2626
"@temporalio/client": "^1.13.2",
27+
"@temporalio/envconfig": "^1.13.2",
2728
"@temporalio/worker": "^1.13.2",
2829
"@temporalio/workflow": "^1.13.2"
2930
},

continue-as-new/src/client.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
import { Client } from '@temporalio/client';
1+
import { Client, Connection } from '@temporalio/client';
2+
import { loadClientConnectConfig } from '@temporalio/envconfig';
23
import { loopingWorkflow } from './workflows';
34

45
async function run() {
5-
const client = new Client();
6+
const config = loadClientConnectConfig();
7+
const connection = await Connection.connect(config.connectionOptions);
8+
const client = new Client({ connection });
69

710
const result = await client.workflow.execute(loopingWorkflow, { taskQueue: 'continue-as-new', workflowId: 'loop-0' });
811
console.log(result); // Hello, Temporal!

0 commit comments

Comments
 (0)