Skip to content

Commit

Permalink
Update client service bus options
Browse files Browse the repository at this point in the history
  • Loading branch information
ebbeknudsen committed Nov 19, 2024
1 parent aeb6d12 commit 898cded
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,26 +61,29 @@ public static IServiceCollection AddProcessManagerHttpClients(this IServiceColle

/// <summary>
/// Register Process Manager RequestCalculatedData client for use in applications.
/// <remarks>The application must register the <see cref="ServiceBusClient"/> by calling </remarks>
/// <remarks>The application must register the <see cref="ServiceBusClient"/> and contain configuration for <see cref="ProcessManagerServiceBusClientsOptions"/></remarks>
/// </summary>
public static IServiceCollection AddProcessManagerRequestCalculatedDataClient(this IServiceCollection services)
{
services.AddProcessManagerServiceBusOptions();
services
.AddOptions<ProcessManagerServiceBusClientsOptions>()
.BindConfiguration(ProcessManagerServiceBusClientsOptions.SectionName)
.ValidateDataAnnotations();

services.AddAzureClients(
builder =>
{
builder.AddClient<ServiceBusSender, ServiceBusClientOptions>(
(_, _, provider) =>
{
var serviceBusOptions = provider.GetRequiredProcessManagerServiceBusOptions();
var serviceBusOptions = provider.GetRequiredService<IOptions<ProcessManagerServiceBusClientsOptions>>().Value;
var serviceBusSender = provider
.GetRequiredService<ServiceBusClient>()
.CreateSender(serviceBusOptions.ProcessManagerTopic);

return serviceBusSender;
})
.WithName(nameof(ProcessManagerServiceBusOptions.ProcessManagerTopic));
.WithName(nameof(ProcessManagerServiceBusClientsOptions.ProcessManagerTopic));
});

services.AddScoped<IRequestCalculatedDataClientV1, RequestCalculatedDataClientV1>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ namespace Energinet.DataHub.ProcessManager.Client.Extensions.Options;
/// <summary>
/// Options for configuration of Process Manager Service Bus clients using the Process Manager.
/// </summary>
public class ProcessManagerServiceBusOptions
public class ProcessManagerServiceBusClientsOptions
{
public const string SectionName = "ProcessManagerServiceBus";
public const string SectionName = "ProcessManagerServiceBusClients";

/// <summary>
/// Name of the topic which the Process Manager receives service bus messages on
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace Energinet.DataHub.ProcessManager.Client.Processes.BRS_026_028.V1;
public class RequestCalculatedDataClientV1(
IAzureClientFactory<ServiceBusSender> serviceBusFactory) : IRequestCalculatedDataClientV1
{
private readonly ServiceBusSender _serviceBusSender = serviceBusFactory.CreateClient(nameof(ProcessManagerServiceBusOptions.ProcessManagerTopic));
private readonly ServiceBusSender _serviceBusSender = serviceBusFactory.CreateClient(nameof(ProcessManagerServiceBusClientsOptions.ProcessManagerTopic));

public async Task RequestCalculatedEnergyTimeSeriesAsync(RequestCalculatedDataInputV1<RequestCalculatedEnergyTimeSeriesInputV1> input, CancellationToken cancellationToken)
{
Expand Down

0 comments on commit 898cded

Please sign in to comment.