-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,20 +29,12 @@ public static void UseDurableTaskScheduler( | |
TokenCredential credential, | ||
Action<DurableTaskSchedulerClientOptions>? configure = null) | ||
{ | ||
builder.Services.AddOptions<DurableTaskSchedulerClientOptions>(builder.Name) | ||
.Configure(options => | ||
{ | ||
options.EndpointAddress = endpointAddress; | ||
options.TaskHubName = taskHubName; | ||
options.Credential = credential; | ||
}) | ||
.Configure(configure ?? (_ => { })) | ||
.ValidateDataAnnotations() | ||
.ValidateOnStart(); | ||
|
||
builder.Services.TryAddEnumerable( | ||
ServiceDescriptor.Singleton<IConfigureOptions<GrpcDurableTaskClientOptions>, ConfigureGrpcChannel>()); | ||
builder.UseGrpc(_ => { }); | ||
ConfigureSchedulerOptions(builder, options => | ||
{ | ||
options.EndpointAddress = endpointAddress; | ||
options.TaskHubName = taskHubName; | ||
options.Credential = credential; | ||
}, configure); | ||
Check warning on line 37 in src/Client/AzureManaged/DurableTaskSchedulerClientExtensions.cs GitHub Actions / Analyze (csharp)
|
||
} | ||
|
||
/// <summary> | ||
|
@@ -57,15 +49,34 @@ public static void UseDurableTaskScheduler( | |
Action<DurableTaskSchedulerClientOptions>? configure = null) | ||
{ | ||
var connectionOptions = DurableTaskSchedulerClientOptions.FromConnectionString(connectionString); | ||
ConfigureSchedulerOptions(builder, options => | ||
{ | ||
options.EndpointAddress = connectionOptions.EndpointAddress; | ||
options.TaskHubName = connectionOptions.TaskHubName; | ||
options.Credential = connectionOptions.Credential; | ||
}, configure); | ||
Check warning on line 57 in src/Client/AzureManaged/DurableTaskSchedulerClientExtensions.cs GitHub Actions / Analyze (csharp)
|
||
} | ||
|
||
/// <summary> | ||
/// Configures Durable Task client to use the Azure Durable Task Scheduler service using configuration options. | ||
/// </summary> | ||
/// <param name="builder">The Durable Task client builder to configure.</param> | ||
/// <param name="configure">Callback to configure DurableTaskSchedulerClientOptions.</param> | ||
public static void UseDurableTaskScheduler( | ||
this IDurableTaskClientBuilder builder, | ||
Action<DurableTaskSchedulerClientOptions>? configure = null) | ||
{ | ||
ConfigureSchedulerOptions(builder, _ => { }, configure); | ||
} | ||
|
||
private static void ConfigureSchedulerOptions( | ||
IDurableTaskClientBuilder builder, | ||
Action<DurableTaskSchedulerClientOptions> initialConfig, | ||
Action<DurableTaskSchedulerClientOptions>? additionalConfig) | ||
{ | ||
builder.Services.AddOptions<DurableTaskSchedulerClientOptions>(builder.Name) | ||
.Configure(options => | ||
{ | ||
options.EndpointAddress = connectionOptions.EndpointAddress; | ||
options.TaskHubName = connectionOptions.TaskHubName; | ||
options.Credential = connectionOptions.Credential; | ||
}) | ||
.Configure(configure ?? (_ => { })) | ||
.Configure(initialConfig) | ||
.Configure(additionalConfig ?? (_ => { })) | ||
.ValidateDataAnnotations() | ||
.ValidateOnStart(); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,20 +30,12 @@ public static void UseDurableTaskScheduler( | |
TokenCredential credential, | ||
Action<DurableTaskSchedulerWorkerOptions>? configure = null) | ||
{ | ||
builder.Services.AddOptions<DurableTaskSchedulerWorkerOptions>(builder.Name) | ||
.Configure(options => | ||
{ | ||
options.EndpointAddress = endpointAddress; | ||
options.TaskHubName = taskHubName; | ||
options.Credential = credential; | ||
}) | ||
.Configure(configure ?? (_ => { })) | ||
.ValidateDataAnnotations() | ||
.ValidateOnStart(); | ||
|
||
builder.Services.TryAddEnumerable( | ||
ServiceDescriptor.Singleton<IConfigureOptions<GrpcDurableTaskWorkerOptions>, ConfigureGrpcChannel>()); | ||
builder.UseGrpc(_ => { }); | ||
ConfigureSchedulerOptions(builder, options => | ||
{ | ||
options.EndpointAddress = endpointAddress; | ||
options.TaskHubName = taskHubName; | ||
options.Credential = credential; | ||
}, configure); | ||
Check warning on line 38 in src/Worker/AzureManaged/DurableTaskSchedulerWorkerExtensions.cs GitHub Actions / build
|
||
} | ||
|
||
/// <summary> | ||
|
@@ -58,15 +50,34 @@ public static void UseDurableTaskScheduler( | |
Action<DurableTaskSchedulerWorkerOptions>? configure = null) | ||
{ | ||
var connectionOptions = DurableTaskSchedulerWorkerOptions.FromConnectionString(connectionString); | ||
ConfigureSchedulerOptions(builder, options => | ||
{ | ||
options.EndpointAddress = connectionOptions.EndpointAddress; | ||
options.TaskHubName = connectionOptions.TaskHubName; | ||
options.Credential = connectionOptions.Credential; | ||
}, configure); | ||
Check warning on line 58 in src/Worker/AzureManaged/DurableTaskSchedulerWorkerExtensions.cs GitHub Actions / build
|
||
} | ||
|
||
/// <summary> | ||
/// Configures Durable Task worker to use the Azure Durable Task Scheduler service using configuration options. | ||
/// </summary> | ||
/// <param name="builder">The Durable Task worker builder to configure.</param> | ||
/// <param name="configure">Callback to configure DurableTaskSchedulerWorkerOptions.</param> | ||
public static void UseDurableTaskScheduler( | ||
this IDurableTaskWorkerBuilder builder, | ||
Action<DurableTaskSchedulerWorkerOptions>? configure = null) | ||
{ | ||
ConfigureSchedulerOptions(builder, _ => { }, configure); | ||
} | ||
|
||
private static void ConfigureSchedulerOptions( | ||
IDurableTaskWorkerBuilder builder, | ||
Action<DurableTaskSchedulerWorkerOptions> initialConfig, | ||
Action<DurableTaskSchedulerWorkerOptions>? additionalConfig) | ||
{ | ||
builder.Services.AddOptions<DurableTaskSchedulerWorkerOptions>(builder.Name) | ||
.Configure(options => | ||
{ | ||
options.EndpointAddress = connectionOptions.EndpointAddress; | ||
options.TaskHubName = connectionOptions.TaskHubName; | ||
options.Credential = connectionOptions.Credential; | ||
}) | ||
.Configure(configure ?? (_ => { })) | ||
.Configure(initialConfig) | ||
.Configure(additionalConfig ?? (_ => { })) | ||
.ValidateDataAnnotations() | ||
.ValidateOnStart(); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,8 +79,8 @@ internal static DurableTaskSchedulerWorkerOptions FromConnectionString( | |
/// <returns>A configured <see cref="GrpcChannel"/> instance that can be used to make gRPC calls.</returns> | ||
public GrpcChannel CreateChannel() | ||
Check warning on line 80 in src/Worker/AzureManaged/DurableTaskSchedulerWorkerOptions.cs GitHub Actions / build
|
||
{ | ||
Check.NotNullOrEmpty(this.EndpointAddress, nameof(this.EndpointAddress)); | ||
Check.NotNullOrEmpty(this.TaskHubName, nameof(this.TaskHubName)); | ||
Verify.NotNull(this.EndpointAddress, nameof(this.EndpointAddress)); | ||
Verify.NotNull(this.TaskHubName, nameof(this.TaskHubName)); | ||
string taskHubName = this.TaskHubName; | ||
string endpoint = !this.EndpointAddress.Contains("://") | ||
? $"https://{this.EndpointAddress}" | ||
|