From 1c98930d3f41cb10682d5dbf1981fd2ec3f459cc Mon Sep 17 00:00:00 2001 From: peterstone2017 <12449837+YunchuWang@users.noreply.github.com> Date: Fri, 25 Apr 2025 14:40:42 -0700 Subject: [PATCH 1/6] Add User-Agent Header to gRPC Metadata --- azuremanaged/build.gradle | 23 ++++++++++++++++ .../DurableTaskSchedulerClientOptions.java | 5 ++++ .../DurableTaskSchedulerWorkerOptions.java | 5 ++++ .../DurableTaskUserAgentUtil.java | 27 +++++++++++++++++++ .../main/resources/VersionInfo.java.template | 19 +++++++++++++ .../PROTO_SOURCE_COMMIT_HASH | 2 +- .../protos/orchestrator_service.proto | 2 ++ 7 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 azuremanaged/src/main/java/com/microsoft/durabletask/azuremanaged/DurableTaskUserAgentUtil.java create mode 100644 azuremanaged/src/main/resources/VersionInfo.java.template diff --git a/azuremanaged/build.gradle b/azuremanaged/build.gradle index 5343b3bd..833621d3 100644 --- a/azuremanaged/build.gradle +++ b/azuremanaged/build.gradle @@ -152,3 +152,26 @@ spotbugsTest { } } +// Add this after the plugins block +def generatedSourcesDir = file("$buildDir/generated/sources/version/java/main") + +sourceSets { + main { + java { + srcDirs += generatedSourcesDir + } + } +} + +task generateVersionInfo(type: Copy) { + from 'src/main/resources/VersionInfo.java.template' + into generatedSourcesDir + expand(version: project.version) + rename { 'VersionInfo.java' } +} + +compileJava.dependsOn generateVersionInfo + +tasks.named('sourcesJar') { + dependsOn generateVersionInfo +} \ No newline at end of file diff --git a/azuremanaged/src/main/java/com/microsoft/durabletask/azuremanaged/DurableTaskSchedulerClientOptions.java b/azuremanaged/src/main/java/com/microsoft/durabletask/azuremanaged/DurableTaskSchedulerClientOptions.java index e2bca74c..be56be71 100644 --- a/azuremanaged/src/main/java/com/microsoft/durabletask/azuremanaged/DurableTaskSchedulerClientOptions.java +++ b/azuremanaged/src/main/java/com/microsoft/durabletask/azuremanaged/DurableTaskSchedulerClientOptions.java @@ -226,6 +226,11 @@ public void start(ClientCall.Listener responseListener, Metadata headers) taskHubName ); + headers.put( + Metadata.Key.of("user-agent", Metadata.ASCII_STRING_MARSHALLER), + DurableTaskUserAgentUtil.getUserAgent() + ); + // Add authorization token if credentials are configured if (finalTokenCache != null) { String token = finalTokenCache.getToken().getToken(); diff --git a/azuremanaged/src/main/java/com/microsoft/durabletask/azuremanaged/DurableTaskSchedulerWorkerOptions.java b/azuremanaged/src/main/java/com/microsoft/durabletask/azuremanaged/DurableTaskSchedulerWorkerOptions.java index 03f9d60a..bebf4f3a 100644 --- a/azuremanaged/src/main/java/com/microsoft/durabletask/azuremanaged/DurableTaskSchedulerWorkerOptions.java +++ b/azuremanaged/src/main/java/com/microsoft/durabletask/azuremanaged/DurableTaskSchedulerWorkerOptions.java @@ -235,6 +235,11 @@ public void start(ClientCall.Listener responseListener, Metadata headers) taskHubName ); + headers.put( + Metadata.Key.of("user-agent", Metadata.ASCII_STRING_MARSHALLER), + DurableTaskUserAgentUtil.getUserAgent() + ); + // Add authorization token if credentials are configured if (finalTokenCache != null) { String token = finalTokenCache.getToken().getToken(); diff --git a/azuremanaged/src/main/java/com/microsoft/durabletask/azuremanaged/DurableTaskUserAgentUtil.java b/azuremanaged/src/main/java/com/microsoft/durabletask/azuremanaged/DurableTaskUserAgentUtil.java new file mode 100644 index 00000000..cde2c104 --- /dev/null +++ b/azuremanaged/src/main/java/com/microsoft/durabletask/azuremanaged/DurableTaskUserAgentUtil.java @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +package com.microsoft.durabletask.azuremanaged; + +/** + * Utility class for generating the user agent string for the Durable Task SDK. + */ +public final class DurableTaskUserAgentUtil { + /** + * The name of the SDK used in the user agent string. + */ + private static final String SDK_NAME = "durabletask-java"; + + private DurableTaskUserAgentUtil() { + // Private constructor to prevent instantiation + } + + /** + * Generates the user agent string for the Durable Task SDK based on a fixed name and the package version. + * + * @return The user agent string. + */ + public static String getUserAgent() { + return String.format("%s/%s", SDK_NAME, VersionInfo.VERSION); + } +} \ No newline at end of file diff --git a/azuremanaged/src/main/resources/VersionInfo.java.template b/azuremanaged/src/main/resources/VersionInfo.java.template new file mode 100644 index 00000000..f4acb56d --- /dev/null +++ b/azuremanaged/src/main/resources/VersionInfo.java.template @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +package com.microsoft.durabletask.azuremanaged; + +/** + * Auto-generated version information for the Durable Task SDK. + * This file is generated during the build process. + */ +public final class VersionInfo { + /** + * The version of the SDK. + */ + public static final String VERSION = "${version}"; + + private VersionInfo() { + // Private constructor to prevent instantiation + } +} \ No newline at end of file diff --git a/internal/durabletask-protobuf/PROTO_SOURCE_COMMIT_HASH b/internal/durabletask-protobuf/PROTO_SOURCE_COMMIT_HASH index 5fe0edd4..3d3f9e98 100644 --- a/internal/durabletask-protobuf/PROTO_SOURCE_COMMIT_HASH +++ b/internal/durabletask-protobuf/PROTO_SOURCE_COMMIT_HASH @@ -1 +1 @@ -c85ef11430ff8e10e21105abb545b0803bb86c66 \ No newline at end of file +fbe5bb20835678099fc51a44993ed9b045dee5a6 \ No newline at end of file diff --git a/internal/durabletask-protobuf/protos/orchestrator_service.proto b/internal/durabletask-protobuf/protos/orchestrator_service.proto index 5dd39cfe..88928c3b 100644 --- a/internal/durabletask-protobuf/protos/orchestrator_service.proto +++ b/internal/durabletask-protobuf/protos/orchestrator_service.proto @@ -11,6 +11,7 @@ import "google/protobuf/timestamp.proto"; import "google/protobuf/duration.proto"; import "google/protobuf/wrappers.proto"; import "google/protobuf/empty.proto"; +import "google/protobuf/struct.proto"; message OrchestrationInstance { string instanceId = 1; @@ -318,6 +319,7 @@ message OrchestratorRequest { repeated HistoryEvent newEvents = 4; OrchestratorEntityParameters entityParameters = 5; bool requiresHistoryStreaming = 6; + map properties = 7; } message OrchestratorResponse { From dbf574b39f03a54b20f74d8c57bab1d66f3ed829 Mon Sep 17 00:00:00 2001 From: peterstone2017 <12449837+YunchuWang@users.noreply.github.com> Date: Fri, 25 Apr 2025 15:42:34 -0700 Subject: [PATCH 2/6] add rundts task --- samples/build.gradle | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/samples/build.gradle b/samples/build.gradle index e9f049e8..3a135c68 100644 --- a/samples/build.gradle +++ b/samples/build.gradle @@ -1,7 +1,6 @@ plugins { id 'org.springframework.boot' version '2.5.2' id 'java' - id 'application' } group 'io.durabletask' @@ -9,10 +8,12 @@ version = '0.1.0' def grpcVersion = '1.59.0' archivesBaseName = 'durabletask-samples' -application { +task runWebAppToDurableTaskSchedulerSample(type: JavaExec) { + classpath = sourceSets.main.runtimeClasspath mainClass = 'io.durabletask.samples.WebAppToDurableTaskSchedulerSample' } + dependencies { implementation project(':client') implementation project(':azuremanaged') From fccdd49655f9e5843b497508cff7b02ff2e50be0 Mon Sep 17 00:00:00 2001 From: peterstone2017 <12449837+YunchuWang@users.noreply.github.com> Date: Fri, 25 Apr 2025 15:47:55 -0700 Subject: [PATCH 3/6] Update CHANGELOG.md to include User-Agent Header addition and versioning for v1.5.1-preview --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b4ce7e4e..d47b4248 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,6 @@ ## placeholder +* Add User-Agent Header to gRPC Metadata ([#213](https://github.com/microsoft/durabletask-java/pull/213)) +## ## v1.5.1-preview * DTS Support ([#201](https://github.com/microsoft/durabletask-java/pull/201)) * Add automatic proto file download and commit hash tracking during build ([#207](https://github.com/microsoft/durabletask-java/pull/207)) * Fix infinite loop when use continueasnew after wait external event ([#183](https://github.com/microsoft/durabletask-java/pull/183)) From 4bd5d682e27275acfae6bf008c20622f9be6994f Mon Sep 17 00:00:00 2001 From: peterstone2017 <12449837+YunchuWang@users.noreply.github.com> Date: Fri, 25 Apr 2025 16:04:26 -0700 Subject: [PATCH 4/6] fix --- samples/build.gradle | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/samples/build.gradle b/samples/build.gradle index 3a135c68..5cb638df 100644 --- a/samples/build.gradle +++ b/samples/build.gradle @@ -8,12 +8,15 @@ version = '0.1.0' def grpcVersion = '1.59.0' archivesBaseName = 'durabletask-samples' +bootJar { + mainClass = 'io.durabletask.samples.WebApplication' +} + task runWebAppToDurableTaskSchedulerSample(type: JavaExec) { classpath = sourceSets.main.runtimeClasspath mainClass = 'io.durabletask.samples.WebAppToDurableTaskSchedulerSample' } - dependencies { implementation project(':client') implementation project(':azuremanaged') From 62bf0f4b388d5f3e7962a29267bd701654169a31 Mon Sep 17 00:00:00 2001 From: peterstone2017 <12449837+YunchuWang@users.noreply.github.com> Date: Fri, 25 Apr 2025 16:41:39 -0700 Subject: [PATCH 5/6] Update CHANGELOG.md to reflect the addition of User-Agent Header in gRPC Metadata and versioning for v1.5.0.preview.1 --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ca6b0d21..1da42feb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## placeholder +* Add User-Agent Header to gRPC Metadata ([#213](https://github.com/microsoft/durabletask-java/pull/213)) +## v1.5.0.preview.1 * Update protobuf definitions to include new properties in OrchestratorRequest and update source commit hash ([#214](https://github.com/microsoft/durabletask-java/pull/214)) -## v1.5.1.preview * DTS Support ([#201](https://github.com/microsoft/durabletask-java/pull/201)) * Add automatic proto file download and commit hash tracking during build ([#207](https://github.com/microsoft/durabletask-java/pull/207)) * Fix infinite loop when use continueasnew after wait external event ([#183](https://github.com/microsoft/durabletask-java/pull/183)) From 1f27398ae3f1669ed242011f1069ce5107dabc92 Mon Sep 17 00:00:00 2001 From: peterstone2017 <12449837+YunchuWang@users.noreply.github.com> Date: Fri, 25 Apr 2025 16:42:13 -0700 Subject: [PATCH 6/6] Update CHANGELOG.md to correct versioning format from v1.5.0.preview.1 to v1.5.0-preview.1 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1da42feb..c89bd94c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ ## placeholder * Add User-Agent Header to gRPC Metadata ([#213](https://github.com/microsoft/durabletask-java/pull/213)) -## v1.5.0.preview.1 +## v1.5.0-preview.1 * Update protobuf definitions to include new properties in OrchestratorRequest and update source commit hash ([#214](https://github.com/microsoft/durabletask-java/pull/214)) * DTS Support ([#201](https://github.com/microsoft/durabletask-java/pull/201)) * Add automatic proto file download and commit hash tracking during build ([#207](https://github.com/microsoft/durabletask-java/pull/207))