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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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))
Expand Down
23 changes: 23 additions & 0 deletions azuremanaged/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,11 @@ public void start(ClientCall.Listener<RespT> 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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,11 @@ public void start(ClientCall.Listener<RespT> 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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
}
19 changes: 19 additions & 0 deletions azuremanaged/src/main/resources/VersionInfo.java.template
Original file line number Diff line number Diff line change
@@ -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
}
}
8 changes: 6 additions & 2 deletions samples/build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
plugins {
id 'org.springframework.boot' version '2.5.2'
id 'java'
id 'application'
}

group 'io.durabletask'
version = '0.1.0'
def grpcVersion = '1.59.0'
archivesBaseName = 'durabletask-samples'

application {
bootJar {
mainClass = 'io.durabletask.samples.WebApplication'
}

task runWebAppToDurableTaskSchedulerSample(type: JavaExec) {
classpath = sourceSets.main.runtimeClasspath
mainClass = 'io.durabletask.samples.WebAppToDurableTaskSchedulerSample'
}

Expand Down
Loading