Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
YunchuWang committed Jan 10, 2025
1 parent 5e97555 commit 9c890c5
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/Extensions/Azure/DurableTaskSchedulerOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ namespace Microsoft.DurableTask.Extensions.Azure;
/// </summary>
public class DurableTaskSchedulerOptions
{
private readonly string defaultWorkerId;

/// <summary>
/// Initializes a new instance of the <see cref="DurableTaskSchedulerOptions"/> class.
/// </summary>
Expand All @@ -28,6 +30,9 @@ internal DurableTaskSchedulerOptions(string endpointAddress, string taskHubName,

this.TaskHubName = taskHubName;
this.Credential = credential;

// Generate the default worker ID once at construction time
this.defaultWorkerId = $"{Environment.MachineName},{Environment.ProcessId},{Guid.NewGuid():N}";
}

/// <summary>
Expand All @@ -54,7 +59,7 @@ internal DurableTaskSchedulerOptions(string endpointAddress, string taskHubName,

/// <summary>
/// Gets or sets the worker ID used to identify the worker instance.
/// The default value is a string containing the machine name and the process ID.
/// The default value is a string containing the machine name, process ID, and a unique identifier.
/// </summary>
public string? WorkerId { get; set; }

Expand All @@ -78,8 +83,7 @@ internal GrpcChannel GetGrpcChannel()
string endpoint = this.EndpointAddress;

string resourceId = this.ResourceId ?? "https://durabletask.io";
int processId = Environment.ProcessId;
string workerId = this.WorkerId ?? $"{Environment.MachineName},{processId},{Guid.NewGuid():N}";
string workerId = this.WorkerId ?? this.defaultWorkerId;

AccessTokenCache? cache =
this.Credential is not null
Expand Down

0 comments on commit 9c890c5

Please sign in to comment.