Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions activities-cancellation-heartbeating/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"dependencies": {
"@temporalio/activity": "^1.13.2",
"@temporalio/client": "^1.13.2",
"@temporalio/envconfig": "^1.13.2",
"@temporalio/worker": "^1.13.2",
"@temporalio/workflow": "^1.13.2"
},
Expand Down
4 changes: 3 additions & 1 deletion activities-cancellation-heartbeating/src/client.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { Connection, Client, WorkflowFailedError, CancelledFailure } from '@temporalio/client';
import { loadClientConnectConfig } from '@temporalio/envconfig';
import { runCancellableActivity } from './workflows';
import { setTimeout } from 'timers/promises';

async function run() {
const connection = await Connection.connect();
const config = loadClientConnectConfig();
const connection = await Connection.connect(config.connectionOptions);
const client = new Client({ connection });

const handle = await client.workflow.start(runCancellableActivity, {
Expand Down
1 change: 1 addition & 0 deletions activities-dependency-injection/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"dependencies": {
"@temporalio/activity": "^1.13.2",
"@temporalio/client": "^1.13.2",
"@temporalio/envconfig": "^1.13.2",
"@temporalio/worker": "^1.13.2",
"@temporalio/workflow": "^1.13.2"
},
Expand Down
7 changes: 5 additions & 2 deletions activities-dependency-injection/src/client.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { Client } from '@temporalio/client';
import { Client, Connection } from '@temporalio/client';
import { loadClientConnectConfig } from '@temporalio/envconfig';
import { dependencyWF } from './workflows';

async function run(): Promise<void> {
const client = new Client();
const config = loadClientConnectConfig();
const connection = await Connection.connect(config.connectionOptions);
const client = new Client({ connection });

const result = await client.workflow.execute(dependencyWF, {
taskQueue: 'dependency-injection',
Expand Down
1 change: 1 addition & 0 deletions activities-examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"@temporalio/activity": "^1.13.2",
"@temporalio/client": "^1.13.2",
"@temporalio/common": "^1.13.2",
"@temporalio/envconfig": "^1.13.2",
"@temporalio/worker": "^1.13.2",
"@temporalio/workflow": "^1.13.2",
"axios": "^0.28.0",
Expand Down
7 changes: 5 additions & 2 deletions activities-examples/src/client.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { Client } from '@temporalio/client';
import { Client, Connection } from '@temporalio/client';
import { loadClientConnectConfig } from '@temporalio/envconfig';
import { asyncActivityWorkflow, httpWorkflow } from './workflows';

async function run(): Promise<void> {
const client = new Client();
const config = loadClientConnectConfig();
const connection = await Connection.connect(config.connectionOptions);
const client = new Client({ connection });

let result = await client.workflow.execute(httpWorkflow, {
taskQueue: 'activities-examples',
Expand Down
1 change: 1 addition & 0 deletions child-workflows/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"dependencies": {
"@temporalio/activity": "^1.13.2",
"@temporalio/client": "^1.13.2",
"@temporalio/envconfig": "^1.13.2",
"@temporalio/worker": "^1.13.2",
"@temporalio/workflow": "^1.13.2"
},
Expand Down
7 changes: 5 additions & 2 deletions child-workflows/src/client.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { Client } from '@temporalio/client';
import { Client, Connection } from '@temporalio/client';
import { loadClientConnectConfig } from '@temporalio/envconfig';
import { parentWorkflow } from './workflows';

async function run() {
const client = new Client();
const config = loadClientConnectConfig();
const connection = await Connection.connect(config.connectionOptions);
const client = new Client({ connection });

const result = await client.workflow.execute(parentWorkflow, {
taskQueue: 'child-workflows',
Expand Down
1 change: 1 addition & 0 deletions continue-as-new/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"dependencies": {
"@temporalio/activity": "^1.13.2",
"@temporalio/client": "^1.13.2",
"@temporalio/envconfig": "^1.13.2",
"@temporalio/worker": "^1.13.2",
"@temporalio/workflow": "^1.13.2"
},
Expand Down
7 changes: 5 additions & 2 deletions continue-as-new/src/client.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { Client } from '@temporalio/client';
import { Client, Connection } from '@temporalio/client';
import { loadClientConnectConfig } from '@temporalio/envconfig';
import { loopingWorkflow } from './workflows';

async function run() {
const client = new Client();
const config = loadClientConnectConfig();
const connection = await Connection.connect(config.connectionOptions);
const client = new Client({ connection });

const result = await client.workflow.execute(loopingWorkflow, { taskQueue: 'continue-as-new', workflowId: 'loop-0' });
console.log(result); // Hello, Temporal!
Expand Down
1 change: 1 addition & 0 deletions cron-workflows/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"dependencies": {
"@temporalio/activity": "^1.13.2",
"@temporalio/client": "^1.13.2",
"@temporalio/envconfig": "^1.13.2",
"@temporalio/worker": "^1.13.2",
"@temporalio/workflow": "^1.13.2"
},
Expand Down
11 changes: 8 additions & 3 deletions cron-workflows/src/client.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import { Client } from '@temporalio/client';
import { Client, Connection } from '@temporalio/client';
import { loadClientConnectConfig } from '@temporalio/envconfig';
import { scheduledWorkflow } from './workflows';

// Save this to later terminate or cancel this schedule
const workflowId = 'my-schedule';

async function run() {
const client = new Client();
const config = loadClientConnectConfig();
const connection = await Connection.connect(config.connectionOptions);
const client = new Client({ connection });

const handle = await client.workflow.start(scheduledWorkflow, {
taskQueue: 'cron-workflows',
Expand All @@ -24,7 +27,9 @@ async function run() {

// just for this demo - cancel the workflow on Ctrl+C
process.on('SIGINT', async () => {
const client = new Client();
const config = loadClientConnectConfig();
const connection = await Connection.connect(config.connectionOptions);
const client = new Client({ connection });

const handle = client.workflow.getHandle(workflowId);
await handle.cancel();
Expand Down
1 change: 1 addition & 0 deletions custom-logger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"dependencies": {
"@temporalio/activity": "^1.13.2",
"@temporalio/client": "^1.13.2",
"@temporalio/envconfig": "^1.13.2",
"@temporalio/worker": "^1.13.2",
"@temporalio/workflow": "^1.13.2",
"nanoid": "3.x",
Expand Down
15 changes: 7 additions & 8 deletions custom-logger/src/client.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import { nanoid } from 'nanoid';
import { Connection, Client } from '@temporalio/client';
import { loadClientConnectConfig } from '@temporalio/envconfig';
import { logSampleWorkflow } from './workflows';

async function run() {
const connection = await Connection.connect(); // Connect to localhost with default ConnectionOptions.
// In production, pass options to the Connection constructor to configure TLS and other settings.
// This is optional but we leave this here to remind you there is a gRPC connection being established.
Comment on lines -7 to -8
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are the comments no longer helpful with envconfig?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a little comment, linking to docs


const client = new Client({
connection,
// In production you will likely specify `namespace` here; it is 'default' if omitted
});
// Load client configuration from config file.
// (see: https://docs.temporal.io/develop/environment-configuration)
// In production, you can configure TLS and other settings in your config file.
const config = loadClientConnectConfig();
const connection = await Connection.connect(config.connectionOptions);
const client = new Client({ connection });

// Invoke the `logSampleWorkflow` Workflow, only resolved when the workflow completes
await client.workflow.execute(logSampleWorkflow, {
Expand Down
1 change: 1 addition & 0 deletions dsl-interpreter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"dependencies": {
"@temporalio/activity": "^1.13.2",
"@temporalio/client": "^1.13.2",
"@temporalio/envconfig": "^1.13.2",
"@temporalio/worker": "^1.13.2",
"@temporalio/workflow": "^1.13.2",
"js-yaml": "^4.1.0"
Expand Down
7 changes: 5 additions & 2 deletions dsl-interpreter/src/client.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Client } from '@temporalio/client';
import { Client, Connection } from '@temporalio/client';
import { loadClientConnectConfig } from '@temporalio/envconfig';
import { DSLInterpreter, DSL } from './workflows';
import yaml from 'js-yaml';
import fs from 'fs';
Expand All @@ -23,7 +24,9 @@ async function run() {
if (path) {
dslInput = yaml.load((await fs.promises.readFile(path)).toString()) as DSL;
}
const client = new Client(); // remember to configure Connection for production
const config = loadClientConnectConfig();
const connection = await Connection.connect(config.connectionOptions);
const client = new Client({ connection });

// Invoke the `DSLInterpreter` Workflow, only resolved when the workflow completes
const result = await client.workflow.execute(DSLInterpreter, {
Expand Down
1 change: 1 addition & 0 deletions eager-workflow-start/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"dependencies": {
"@temporalio/activity": "^1.13.2",
"@temporalio/client": "^1.13.2",
"@temporalio/envconfig": "^1.13.2",
"@temporalio/worker": "^1.13.2",
"@temporalio/workflow": "^1.13.2",
"nanoid": "3.x"
Expand Down
4 changes: 3 additions & 1 deletion eager-workflow-start/src/run.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { Client } from '@temporalio/client';
import { loadClientConnectConfig } from '@temporalio/envconfig';
import { eagerWorkflow } from './workflows';
import { nanoid } from 'nanoid';
import { NativeConnection, Worker } from '@temporalio/worker';
import * as activities from './activities';

async function run() {
const config = loadClientConnectConfig();
// Note that the client and worker share the same native connection and run in the same process.
const sharedNativeConnection = await NativeConnection.connect({ address: 'localhost:7233' });
const sharedNativeConnection = await NativeConnection.connect(config.connectionOptions);

const client = new Client({
connection: sharedNativeConnection,
Expand Down
1 change: 1 addition & 0 deletions early-return/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"dependencies": {
"@temporalio/activity": "^1.13.2",
"@temporalio/client": "^1.13.2",
"@temporalio/envconfig": "^1.13.2",
"@temporalio/worker": "^1.13.2",
"@temporalio/workflow": "^1.13.2",
"nanoid": "3.x"
Expand Down
4 changes: 3 additions & 1 deletion early-return/src/run-workflow.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Connection, Client, WithStartWorkflowOperation } from '@temporalio/client';
import { loadClientConnectConfig } from '@temporalio/envconfig';
import { transactionWorkflow } from './workflows';
import { getTransactionConfirmation } from './shared';

Expand All @@ -21,7 +22,8 @@ async function runTransactionWorkflow(transactionID: string, client: Client) {
}

async function main() {
const connection = await Connection.connect();
const config = loadClientConnectConfig();
const connection = await Connection.connect(config.connectionOptions);
const client = new Client({ connection });
const transactionID = process.argv[2] || 'my-transaction-id';
await runTransactionWorkflow(transactionID, client);
Expand Down
1 change: 1 addition & 0 deletions ejson/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"dependencies": {
"@temporalio/activity": "^1.13.2",
"@temporalio/client": "^1.13.2",
"@temporalio/envconfig": "^1.13.2",
"@temporalio/common": "^1.13.2",
"@temporalio/worker": "^1.13.2",
"@temporalio/workflow": "^1.13.2",
Expand Down
6 changes: 5 additions & 1 deletion ejson/src/client.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import { Client } from '@temporalio/client';
import { Client, Connection } from '@temporalio/client';
import { loadClientConnectConfig } from '@temporalio/envconfig';
import { v4 as uuid } from 'uuid';
import type { Result, User } from './types';
import { example } from './workflows';

async function run() {
const config = loadClientConnectConfig();
const connection = await Connection.connect(config.connectionOptions);
// @@@SNIPSTART typescript-ejson-client-setup
const client = new Client({
connection,
dataConverter: { payloadConverterPath: require.resolve('./payload-converter') },
});
// @@@SNIPEND
Expand Down
1 change: 1 addition & 0 deletions empty/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"dependencies": {
"@temporalio/activity": "^1.13.2",
"@temporalio/client": "^1.13.2",
"@temporalio/envconfig": "^1.13.2",
"@temporalio/worker": "^1.13.2",
"@temporalio/workflow": "^1.13.2",
"nanoid": "3.x"
Expand Down
16 changes: 4 additions & 12 deletions empty/src/client.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,16 @@
// @@@SNIPSTART typescript-hello-client
import { Connection, Client } from '@temporalio/client';
import { loadClientConnectConfig } from '@temporalio/envconfig';
import { nanoid } from 'nanoid';
import { TASK_QUEUE_NAME } from './shared';

// import your workflow
import { YOUR_WORKFLOW } from './workflows';

async function run() {
// Connect to the default Server location
const connection = await Connection.connect({ address: 'localhost:7233' });
// In production, pass options to configure TLS and other settings:
// {
// address: 'foo.bar.tmprl.cloud',
// tls: {}
// }

const client = new Client({
connection,
// namespace: 'foo.bar', // connects to 'default' namespace if not specified
});
const config = loadClientConnectConfig();
const connection = await Connection.connect(config.connectionOptions);
const client = new Client({ connection });

const handle = await client.workflow.start(YOUR_WORKFLOW, {
taskQueue: TASK_QUEUE_NAME,
Expand Down
1 change: 1 addition & 0 deletions encryption/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"dependencies": {
"@temporalio/activity": "^1.13.2",
"@temporalio/client": "^1.13.2",
"@temporalio/envconfig": "^1.13.2",
"@temporalio/common": "^1.13.2",
"@temporalio/proto": "^1.13.2",
"@temporalio/worker": "^1.13.2",
Expand Down
6 changes: 5 additions & 1 deletion encryption/src/client.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import { Client } from '@temporalio/client';
import { Client, Connection } from '@temporalio/client';
import { loadClientConnectConfig } from '@temporalio/envconfig';
import { v4 as uuid } from 'uuid';
import { getDataConverter } from './data-converter';
import { example } from './workflows';

async function run() {
const config = loadClientConnectConfig();
const connection = await Connection.connect(config.connectionOptions);
// @@@SNIPSTART typescript-encryption-client
const client = new Client({
connection,
dataConverter: await getDataConverter(),
});

Expand Down
1 change: 1 addition & 0 deletions expense/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"dependencies": {
"@temporalio/activity": "^1.13.2",
"@temporalio/client": "^1.13.2",
"@temporalio/envconfig": "^1.13.2",
"@temporalio/worker": "^1.13.2",
"@temporalio/workflow": "^1.13.2",
"@temporalio/common": "^1.13.2",
Expand Down
7 changes: 5 additions & 2 deletions expense/src/clients/approve.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { Client } from '@temporalio/client';
import { Client, Connection } from '@temporalio/client';
import { loadClientConnectConfig } from '@temporalio/envconfig';
import { expense, approveSignal } from '../workflows';
import { setTimeout } from 'timers/promises';

async function run() {
const client = new Client();
const config = loadClientConnectConfig();
const connection = await Connection.connect(config.connectionOptions);
const client = new Client({ connection });

const expenseId = 'my-business-id';
const handle = await client.workflow.start(expense, {
Expand Down
7 changes: 5 additions & 2 deletions expense/src/clients/timeout.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { Client } from '@temporalio/client';
import { Client, Connection } from '@temporalio/client';
import { loadClientConnectConfig } from '@temporalio/envconfig';
import { expense } from '../workflows';

async function run() {
const client = new Client();
const config = loadClientConnectConfig();
const connection = await Connection.connect(config.connectionOptions);
const client = new Client({ connection });

const expenseId = 'my-business-id';
const result = await client.workflow.execute(expense, {
Expand Down
1 change: 1 addition & 0 deletions fetch-esm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"dependencies": {
"@temporalio/activity": "^1.13.2",
"@temporalio/client": "^1.13.2",
"@temporalio/envconfig": "^1.13.2",
"@temporalio/worker": "^1.13.2",
"@temporalio/workflow": "^1.13.2"
},
Expand Down
7 changes: 5 additions & 2 deletions fetch-esm/src/client.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
// @@@SNIPSTART typescript-esm-client
import { Client } from '@temporalio/client';
import { Client, Connection } from '@temporalio/client';
import { loadClientConnectConfig } from '@temporalio/envconfig';
import { example } from './workflows.js';

const client = new Client();
const config = loadClientConnectConfig();
const connection = await Connection.connect(config.connectionOptions);
const client = new Client({ connection });
const result = await client.workflow.execute(example, {
taskQueue: 'fetch-esm',
workflowId: 'my-business-id',
Expand Down
Loading