Skip to content

Commit 9c07ea8

Browse files
committed
Merge branch 'main' of https://github.com/microsoft/durabletask-js into wangbill/entities
2 parents b0c1eb0 + f20505c commit 9c07ea8

84 files changed

Lines changed: 14086 additions & 1739 deletions

File tree

Some content is hidden

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

.eslintignore

Lines changed: 0 additions & 11 deletions
This file was deleted.

.eslintrc.json

Lines changed: 0 additions & 28 deletions
This file was deleted.

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Summary
2+
3+
## What changed?
4+
-
5+
6+
## Why is this change needed?
7+
-
8+
9+
## Issues / work items
10+
- Resolves #
11+
- Related #
12+
13+
---
14+
15+
# Project checklist
16+
- [ ] Release notes are not required for the next release
17+
- [ ] Otherwise: Notes added to `CHANGELOG.md`
18+
- [ ] Backport is not required
19+
- [ ] Otherwise: Backport tracked by issue/PR #issue_or_pr
20+
- [ ] All required tests have been added/updated (unit tests, E2E tests)
21+
- [ ] Breaking change?
22+
- [ ] If yes:
23+
- Impact:
24+
- Migration guidance:
25+
26+
---
27+
28+
# AI-assisted code disclosure (required)
29+
30+
## Was an AI tool used? (select one)
31+
- [ ] No
32+
- [ ] Yes, AI helped write parts of this PR (e.g., GitHub Copilot)
33+
- [ ] Yes, an AI agent generated most of this PR
34+
35+
If AI was used:
36+
- Tool(s):
37+
- AI-assisted areas/files:
38+
- What you changed after AI output:
39+
40+
AI verification (required if AI was used):
41+
- [ ] I understand the code and can explain it
42+
- [ ] I verified referenced APIs/types exist and are correct
43+
- [ ] I reviewed edge cases/failure paths (timeouts, retries, cancellation, exceptions)
44+
- [ ] I reviewed concurrency/async behavior
45+
- [ ] I checked for unintended breaking or behavior changes
46+
47+
---
48+
49+
# Testing
50+
51+
## Automated tests
52+
- Result: Passed / Failed (link logs if failed)
53+
54+
## Manual validation (only if runtime/behavior changed)
55+
- Environment (OS, Node.js version, components):
56+
- Steps + observed results:
57+
1.
58+
2.
59+
3.
60+
- Evidence (optional):
61+
62+
---
63+
64+
# Notes for reviewers
65+
- N/A

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
!.vscode/launch.json
66
!.vscode/extensions.json
77
*.code-workspace
8-
8+
.DS_Store
99
### DotnetCore ###
1010
# .NET Core build folders
1111
bin/

.husky/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
npx lint-staged

eslint.config.mjs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
import eslint from "@eslint/js";
5+
import tseslint from "typescript-eslint";
6+
import globals from "globals";
7+
8+
export default tseslint.config(
9+
eslint.configs.recommended,
10+
...tseslint.configs.recommended,
11+
{
12+
languageOptions: {
13+
ecmaVersion: 2020,
14+
sourceType: "module",
15+
globals: {
16+
...globals.browser,
17+
...globals.node,
18+
},
19+
},
20+
rules: {
21+
"@typescript-eslint/ban-ts-comment": "off",
22+
"@typescript-eslint/no-explicit-any": "off",
23+
"@typescript-eslint/no-inferrable-types": "off",
24+
"@typescript-eslint/no-empty-function": "off",
25+
"@typescript-eslint/no-require-imports": "off",
26+
"no-constant-condition": "off",
27+
"@typescript-eslint/no-unused-vars": [
28+
"error",
29+
{
30+
varsIgnorePattern: "^_",
31+
argsIgnorePattern: "^_",
32+
},
33+
],
34+
},
35+
},
36+
{
37+
ignores: [
38+
"**/dist/**",
39+
"**/node_modules/**",
40+
"**/src/version.ts",
41+
"**/jest.config.js",
42+
"**/src/proto/**",
43+
],
44+
}
45+
);

examples/azure-managed-dts.ts

Lines changed: 35 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ import { DefaultAzureCredential } from "@azure/identity";
1414
import {
1515
createAzureManagedClient,
1616
createAzureManagedWorkerBuilder,
17+
// Logger types are re-exported for convenience
18+
// ConsoleLogger is used by default
19+
// Use createAzureLogger to integrate with @azure/logger
20+
createAzureLogger,
1721
} from "../extensions/durabletask-js-azuremanaged/build";
1822
import { ActivityContext } from "../src/task/context/activity-context";
1923
import { OrchestrationContext } from "../src/task/context/orchestration-context";
@@ -23,6 +27,10 @@ import { Task } from "../src/task/task";
2327

2428
// Wrap the entire code in an immediately-invoked async function
2529
(async () => {
30+
// Create a logger for this example
31+
// This uses Azure SDK's logging infrastructure - set AZURE_LOG_LEVEL=verbose to see all logs
32+
const logger = createAzureLogger("example");
33+
2634
// Configuration for Azure Managed DTS
2735
// These values should be set as environment variables
2836
const endpoint = process.env.AZURE_DTS_ENDPOINT;
@@ -31,31 +39,31 @@ import { Task } from "../src/task/task";
3139

3240
// Validate configuration
3341
if (!connectionString && (!endpoint || !taskHubName)) {
34-
console.error(
42+
logger.error(
3543
"Error: Either AZURE_DTS_CONNECTION_STRING or both AZURE_DTS_ENDPOINT and AZURE_DTS_TASKHUB must be set.",
3644
);
37-
console.log("\nUsage:");
38-
console.log(" Option 1: Create a .env file in the examples directory (recommended):");
39-
console.log(
45+
logger.info("\nUsage:");
46+
logger.info(" Option 1: Create a .env file in the examples directory (recommended):");
47+
logger.info(
4048
" AZURE_DTS_CONNECTION_STRING=Endpoint=https://myservice.durabletask.io;Authentication=DefaultAzure;TaskHub=myTaskHub",
4149
);
42-
console.log(" or");
43-
console.log(" AZURE_DTS_ENDPOINT=https://myservice.durabletask.io");
44-
console.log(" AZURE_DTS_TASKHUB=myTaskHub");
45-
console.log("\n Option 2: Set environment variables directly");
46-
console.log(" export AZURE_DTS_CONNECTION_STRING=...");
50+
logger.info(" or");
51+
logger.info(" AZURE_DTS_ENDPOINT=https://myservice.durabletask.io");
52+
logger.info(" AZURE_DTS_TASKHUB=myTaskHub");
53+
logger.info("\n Option 2: Set environment variables directly");
54+
logger.info(" export AZURE_DTS_CONNECTION_STRING=...");
4755
process.exit(1);
4856
}
4957

5058
// Define an activity function that greets a city
5159
const greetCity = async (_: ActivityContext, city: string): Promise<string> => {
52-
console.log(`Activity executing: greeting ${city}`);
60+
logger.info(`Activity executing: greeting ${city}`);
5361
return `Hello, ${city}!`;
5462
};
5563

5664
// Define an activity function that processes work items
5765
const processWorkItem = async (_: ActivityContext, item: string): Promise<number> => {
58-
console.log(`Activity executing: processing ${item}`);
66+
logger.info(`Activity executing: processing ${item}`);
5967
// Simulate some processing time
6068
await new Promise((resolve) => setTimeout(resolve, 500));
6169
return item.length;
@@ -98,7 +106,7 @@ import { Task } from "../src/task/task";
98106
try {
99107
// Create client and worker using connection string or explicit parameters
100108
if (connectionString) {
101-
console.log("Using connection string authentication...");
109+
logger.info("Using connection string authentication...");
102110
client = createAzureManagedClient(connectionString);
103111
worker = createAzureManagedWorkerBuilder(connectionString)
104112
.addOrchestrator(sequenceOrchestrator)
@@ -107,7 +115,7 @@ import { Task } from "../src/task/task";
107115
.addActivity(processWorkItem)
108116
.build();
109117
} else {
110-
console.log("Using DefaultAzureCredential authentication...");
118+
logger.info("Using DefaultAzureCredential authentication...");
111119
const credential = new DefaultAzureCredential();
112120
client = createAzureManagedClient(endpoint!, taskHubName!, credential);
113121
worker = createAzureManagedWorkerBuilder(endpoint!, taskHubName!, credential)
@@ -119,42 +127,42 @@ import { Task } from "../src/task/task";
119127
}
120128

121129
// Start the worker
122-
console.log("Starting worker...");
130+
logger.info("Starting worker...");
123131
await worker.start();
124-
console.log("Worker started successfully!");
132+
logger.info("Worker started successfully!");
125133

126134
// Run the sequence orchestrator
127-
console.log("\n--- Running Sequence Orchestrator ---");
135+
logger.info("\n--- Running Sequence Orchestrator ---");
128136
const sequenceId = await client.scheduleNewOrchestration(sequenceOrchestrator);
129-
console.log(`Orchestration scheduled with ID: ${sequenceId}`);
137+
logger.info(`Orchestration scheduled with ID: ${sequenceId}`);
130138

131139
const sequenceState = await client.waitForOrchestrationCompletion(sequenceId, undefined, 60);
132-
console.log(`Sequence orchestration completed!`);
133-
console.log(`Result: ${sequenceState?.serializedOutput}`);
140+
logger.info(`Sequence orchestration completed!`);
141+
logger.info(`Result: ${sequenceState?.serializedOutput}`);
134142

135143
// Run the fan-out/fan-in orchestrator
136-
console.log("\n--- Running Fan-Out/Fan-In Orchestrator ---");
144+
logger.info("\n--- Running Fan-Out/Fan-In Orchestrator ---");
137145
const fanOutId = await client.scheduleNewOrchestration(fanOutFanInOrchestrator);
138-
console.log(`Orchestration scheduled with ID: ${fanOutId}`);
146+
logger.info(`Orchestration scheduled with ID: ${fanOutId}`);
139147

140148
const fanOutState = await client.waitForOrchestrationCompletion(fanOutId, undefined, 60);
141-
console.log(`Fan-out/fan-in orchestration completed!`);
142-
console.log(`Result: ${fanOutState?.serializedOutput}`);
149+
logger.info(`Fan-out/fan-in orchestration completed!`);
150+
logger.info(`Result: ${fanOutState?.serializedOutput}`);
143151

144-
console.log("\n--- All orchestrations completed successfully! ---");
152+
logger.info("\n--- All orchestrations completed successfully! ---");
145153
} catch (error) {
146-
console.error("Error:", error);
154+
logger.error("Error:", error);
147155
process.exit(1);
148156
} finally {
149157
// Cleanup: stop worker and client
150-
console.log("\nStopping worker and client...");
158+
logger.info("\nStopping worker and client...");
151159
if (worker) {
152160
await worker.stop();
153161
}
154162
if (client) {
155163
await client.stop();
156164
}
157-
console.log("Cleanup complete.");
165+
logger.info("Cleanup complete.");
158166
process.exit(0);
159167
}
160168
})();

0 commit comments

Comments
 (0)