Skip to content

Commit 6004aa0

Browse files
committed
checkin
1 parent 7cb90dc commit 6004aa0

43 files changed

Lines changed: 241 additions & 210 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

DotNet/Account/Program.cs

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,27 @@ static void RegisterServices(WebApplicationBuilder builder)
6060
{
6161
// load external configuration source (if specified)
6262
builder.AddExternalConfiguration(AccountConstants.ServiceName);
63-
64-
//Initialize activity source
65-
var assemblyVersion = Assembly.GetExecutingAssembly().GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion ?? string.Empty;
63+
64+
var serviceInfo = builder.Configuration.GetRequiredSection(ServiceInformation.SectionName).Get<ServiceInformation>();
65+
66+
if (serviceInfo != null)
67+
{
68+
serviceInfo!.ServiceConfigName = AccountConstants.ServiceName;
69+
builder.Services.AddSingleton<ServiceInformation>(serviceInfo);
70+
71+
//Initialize activity source
72+
var assemblyVersion = Assembly.GetExecutingAssembly().GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion ?? string.Empty;
73+
ServiceActivitySource.Initialize(assemblyVersion, serviceInfo);
74+
Log.Information("ServiceActivitySource initialized with name: {ServiceName}, version: {Version}",
75+
ServiceActivitySource.ServiceName,
76+
serviceInfo.Version);
77+
}
78+
else
79+
{
80+
throw new NullReferenceException("Service Information was null.");
81+
}
82+
6683
var serviceInfoConfigSection = builder.Configuration.GetRequiredSection(ServiceInformation.SectionName);
67-
var serviceInfo = ServiceInformation.GetServiceInformation(Assembly.GetExecutingAssembly(), builder.Configuration);
68-
ServiceActivitySource.Initialize(assemblyVersion, serviceInfo);
6984

7085
//Add problem details
7186
builder.Services.AddProblemDetailsService(options =>

DotNet/Audit/Listeners/AuditEventListener.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,9 @@ public AuditEventListener(ILogger<AuditEventListener> logger, IServiceScopeFacto
3434
_transientExceptionHandler = transientExceptionHandler ?? throw new ArgumentNullException(nameof(transientExceptionHandler));
3535

3636
//configure deadletter exception handlers
37-
_deadLetterExceptionHandler.ServiceName = AuditConstants.ServiceName;
3837
_deadLetterExceptionHandler.Topic = nameof(KafkaTopic.AuditableEventOccurred) + "-Error";
3938

4039
//configure transient exception handler
41-
_transientExceptionHandler.ServiceName = AuditConstants.ServiceName;
4240
_transientExceptionHandler.Topic = nameof(KafkaTopic.AuditableEventOccurred) + "-Retry";
4341
}
4442

DotNet/Audit/Program.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,12 @@ static void RegisterServices(WebApplicationBuilder builder)
5858
// load external configuration source (if specified)
5959
builder.AddExternalConfiguration(AuditConstants.ServiceName);
6060

61-
var serviceInformation = builder.Configuration.GetRequiredSection(AuditConstants.AppSettingsSectionNames.ServiceInformation).Get<ServiceInformation>();
61+
var serviceInformation = builder.Configuration.GetRequiredSection(ServiceInformation.SectionName).Get<ServiceInformation>();
62+
6263
if (serviceInformation != null)
6364
{
65+
serviceInformation!.ServiceConfigName = AuditConstants.ServiceName;
66+
builder.Services.AddSingleton<ServiceInformation>(serviceInformation);
6467
ServiceActivitySource.Initialize(serviceInformation);
6568
}
6669
else
@@ -174,7 +177,7 @@ static void RegisterServices(WebApplicationBuilder builder)
174177
builder.Services.AddTransient<IJobFactory, QuartzJobFactory>();
175178
builder.Services.AddTransient<RetryJob>();
176179

177-
builder.Services.AddSingleton(new RetryListenerSettings(AuditConstants.ServiceName, [KafkaTopic.AuditableEventOccurredRetry.GetStringValue()]));
180+
builder.Services.AddSingleton(new RetryListenerSettings(serviceInformation.ServiceName, [KafkaTopic.AuditableEventOccurredRetry.GetStringValue()]));
178181
builder.Services.AddHostedService<RetryListener>();
179182
builder.Services.AddHostedService<RetryScheduleService>();
180183
}

DotNet/Census/Listeners/PatientListsAcquiredListener.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@ IEventProducerService<PatientEvent> eventProducerService
4242
_scopeFactory = scopeFactory ?? throw new ArgumentNullException(nameof(scopeFactory));
4343

4444

45-
_transientExceptionHandler.ServiceName = CensusConstants.ServiceName;
4645
_transientExceptionHandler.Topic = nameof(KafkaTopic.PatientListsAcquired) + "-Retry";
47-
_nonTransientExceptionHandler.ServiceName = CensusConstants.ServiceName;
4846
_nonTransientExceptionHandler.Topic = nameof(KafkaTopic.PatientListsAcquired) + "-Error";
4947
}
5048

DotNet/Census/Program.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,12 @@ static void RegisterServices(WebApplicationBuilder builder)
6262
// load external configuration source (if specified)
6363
builder.AddExternalConfiguration(CensusConstants.ServiceName);
6464

65-
var serviceInformation = builder.Configuration.GetRequiredSection(CensusConstants.AppSettings.ServiceInformation).Get<ServiceInformation>();
65+
var serviceInformation = builder.Configuration.GetRequiredSection(ServiceInformation.SectionName).Get<ServiceInformation>();
66+
6667
if (serviceInformation != null)
6768
{
69+
serviceInformation!.ServiceConfigName = CensusConstants.ServiceName;
70+
builder.Services.AddSingleton<ServiceInformation>(serviceInformation);
6871
ServiceActivitySource.Initialize(serviceInformation);
6972
}
7073
else
@@ -205,7 +208,7 @@ static void RegisterServices(WebApplicationBuilder builder)
205208
if (consumerSettings == null || !consumerSettings.DisableRetryConsumer)
206209
{
207210
builder.Services.AddHostedService<ScheduleService>();
208-
builder.Services.AddSingleton(new RetryListenerSettings(CensusConstants.ServiceName, [KafkaTopic.PatientListsAcquiredRetry.GetStringValue()]));
211+
builder.Services.AddSingleton(new RetryListenerSettings(serviceInformation.ServiceName, [KafkaTopic.PatientListsAcquiredRetry.GetStringValue()]));
209212
builder.Services.AddHostedService<RetryListener>();
210213
}
211214

@@ -293,7 +296,7 @@ static void RegisterServices(WebApplicationBuilder builder)
293296
if (consumerSettings == null || !consumerSettings.DisableRetryConsumer)
294297
{
295298
builder.Services.AddHostedService<ScheduleService>();
296-
builder.Services.AddSingleton(new RetryListenerSettings(CensusConstants.ServiceName, [KafkaTopic.PatientListsAcquiredRetry.GetStringValue()]));
299+
builder.Services.AddSingleton(new RetryListenerSettings(serviceInformation.ServiceName, [KafkaTopic.PatientListsAcquiredRetry.GetStringValue()]));
297300
builder.Services.AddHostedService<RetryListener>();
298301
}
299302

DotNet/DataAcquisition.AcquisitionWorker/Program.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,6 @@
4949
builder.Services.AddHostedService<ReadyToAcquireListener>();
5050
}
5151

52-
// TODO: Retry consumer services temporarily disabled for LNK-4038
53-
if (!consumerSettings?.DisableRetryConsumer ?? true)
54-
{
55-
56-
//builder.Services.AddSingleton(new RetryListenerSettings(DataAcquisitionWorkerConstants.ServiceName, [KafkaTopic.ReadyToAcquire.GetStringValue()]));
57-
//builder.Services.AddHostedService<RetryListener>();
58-
//builder.Services.AddHostedService<RetryScheduleService>();
59-
}
60-
6152
builder.Services.AddEndpointsApiExplorer();
6253
builder.Services.AddSwaggerGen(c =>
6354
{

DotNet/DataAcquisition.Domain/Extensions/GeneralStartupExtensions.cs

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,25 @@ public static void RegisterAll(
5454
string serviceName,
5555
bool? configureRedis = false)
5656
{
57+
var serviceInformation = builder.Configuration.GetRequiredSection(ServiceInformation.SectionName).Get<ServiceInformation>();
58+
59+
if (serviceInformation != null)
60+
{
61+
serviceInformation!.ServiceConfigName = serviceName;
62+
builder.Services.AddSingleton<ServiceInformation>(serviceInformation);
63+
64+
ServiceActivitySource.Initialize(serviceInformation);
65+
Log.Information("ServiceActivitySource initialized with name: {ServiceName}, version: {Version}",
66+
ServiceActivitySource.ServiceName,
67+
serviceInformation.Version);
68+
}
69+
else
70+
{
71+
throw new NullReferenceException("Service Information was null.");
72+
}
73+
5774
// load external configuration source (if specified)
58-
builder.AddExternalConfiguration(serviceName);
75+
builder.AddExternalConfiguration(serviceInformation.ServiceConfigName);
5976

6077
builder.Configuration.RegisterMonitoring(builder.Logging, builder.Services);
6178
builder.Services.RegisterConfigs(builder.Configuration);
@@ -74,7 +91,7 @@ public static void RegisterAll(
7491
builder.Services.RegisterManagers();
7592
builder.Services.RegisterServices();
7693
builder.Services.RegisterFactories(builder.Configuration);
77-
builder.Services.RegisterTelemetry(builder.Configuration, builder.Environment, serviceName);
94+
builder.Services.RegisterTelemetry(builder.Configuration, builder.Environment, serviceInformation.ServiceConfigName);
7895
builder.Services.RegisterProblemDetails((IHostingEnvironment)builder.Environment);
7996
}
8097

@@ -110,21 +127,6 @@ public static void RegisterMonitoring(this IConfigurationManager configuration,
110127
// Clear defaults and use Serilog everywhere
111128
logging.ClearProviders();
112129
logging.AddSerilog(Log.Logger, dispose: true);
113-
114-
var serviceInformation = configuration.GetSection(DataAcquisitionConstants.AppSettingsSectionNames.ServiceInformation).Get<ServiceInformation>();
115-
services.Configure<ServiceInformation>(configuration.GetSection(DataAcquisitionConstants.AppSettingsSectionNames.ServiceInformation));
116-
117-
if (serviceInformation != null)
118-
{
119-
ServiceActivitySource.Initialize(serviceInformation);
120-
Log.Information("ServiceActivitySource initialized with name: {ServiceName}, version: {Version}",
121-
ServiceActivitySource.ServiceName,
122-
serviceInformation.Version);
123-
}
124-
else
125-
{
126-
throw new NullReferenceException("Service Information was null.");
127-
}
128130
}
129131

130132
public static void RegisterConfigs(this IServiceCollection services, IConfigurationManager configuration)

DotNet/DataAcquisition/Program.cs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,21 @@
1212
using LantanaGroup.Link.Shared.Application.Extensions;
1313
using LantanaGroup.Link.Shared.Application.Extensions.Security;
1414
using LantanaGroup.Link.Shared.Application.Factories;
15+
using LantanaGroup.Link.Shared.Application.Factory;
1516
using LantanaGroup.Link.Shared.Application.Health;
1617
using LantanaGroup.Link.Shared.Application.Interfaces;
18+
using LantanaGroup.Link.Shared.Application.Listeners;
1719
using LantanaGroup.Link.Shared.Application.Middleware;
1820
using LantanaGroup.Link.Shared.Application.Models;
1921
using LantanaGroup.Link.Shared.Application.Models.Configs;
22+
using LantanaGroup.Link.Shared.Application.Services;
23+
using LantanaGroup.Link.Shared.Application.Utilities;
2024
using LantanaGroup.Link.Shared.Settings;
2125
using Microsoft.AspNetCore.Authentication.JwtBearer;
2226
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
2327
using Microsoft.EntityFrameworkCore;
2428
using Microsoft.OpenApi.Models;
29+
using Quartz;
2530
using System.Reflection;
2631
using System.Text.Json.Serialization;
2732

@@ -71,10 +76,15 @@ static void RegisterServices(WebApplicationBuilder builder)
7176

7277
if (!consumerSettings?.DisableRetryConsumer ?? true)
7378
{
74-
// TODO: Retry consumer services temporarily disabled for LNK-4038
75-
//builder.Services.AddSingleton(new RetryListenerSettings(DataAcquisitionConstants.ServiceName, [KafkaTopic.DataAcquisitionRequestedRetry.GetStringValue(), KafkaTopic.PatientCensusScheduledRetry.GetStringValue()]));
76-
//builder.Services.AddHostedService<RetryListener>();
77-
//builder.Services.AddHostedService<RetryScheduleService>();
79+
builder.Services.AddSingleton<ISchedulerFactory>(provider => provider.GetRequiredService<InMemorySchedulerFactory>());
80+
builder.Services.AddKeyedSingleton<ISchedulerFactory>(ConfigurationConstants.RunTimeConstants.RetrySchedulerKeyedSingleton, (provider, key) => provider.GetRequiredService<InMemorySchedulerFactory>());
81+
82+
83+
var serviceInformation = builder.Configuration.GetRequiredSection(nameof(ServiceInformation)).Get<ServiceInformation>();
84+
85+
builder.Services.AddSingleton(new RetryListenerSettings(serviceInformation!.ServiceName, [KafkaTopic.DataAcquisitionRequestedRetry.GetStringValue(), KafkaTopic.PatientCensusScheduledRetry.GetStringValue()]));
86+
builder.Services.AddHostedService<RetryListener>();
87+
builder.Services.AddHostedService<RetryScheduleService>();
7888
}
7989

8090
// Add Link Security

DotNet/Normalization/Listeners/ResourceAcquiredListener.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using Confluent.Kafka;
22
using Confluent.Kafka.Extensions.Diagnostics;
33
using Hl7.Fhir.Model;
4-
using Hl7.Fhir.Serialization;
54
using LantanaGroup.Link.Normalization.Application.Models.Exceptions;
65
using LantanaGroup.Link.Normalization.Application.Models.Messages;
76
using LantanaGroup.Link.Normalization.Application.Models.Operations;
@@ -18,7 +17,6 @@
1817
using LantanaGroup.Link.Shared.Application.Models.Telemetry;
1918
using LantanaGroup.Link.Shared.Application.SerDes;
2019
using LantanaGroup.Link.Shared.Application.Utilities;
21-
using Microsoft.Extensions.Options;
2220
using System.Text;
2321
using System.Text.Json;
2422
using Task = System.Threading.Tasks.Task;
@@ -36,6 +34,7 @@ public class ResourceAcquiredListener : BackgroundService
3634
private bool _cancelled = false;
3735
private readonly INormalizationServiceMetrics _metrics;
3836
private readonly IServiceScopeFactory _scopeFactory;
37+
private readonly ServiceInformation _serviceInformation;
3938

4039
private readonly CopyPropertyOperationService _copyPropertyOperationService;
4140
private readonly CodeMapOperationService _codeMapOperationService;
@@ -44,7 +43,7 @@ public class ResourceAcquiredListener : BackgroundService
4443

4544
public ResourceAcquiredListener(
4645
ILogger<ResourceAcquiredListener> logger,
47-
IOptions<ServiceInformation> serviceInformation,
46+
ServiceInformation serviceInformation,
4847
IServiceScopeFactory scopeFactory,
4948
IKafkaConsumerFactory<string, ResourceAcquiredMessage> consumerFactory,
5049
IDeadLetterExceptionHandler<string, string> consumeExceptionHandler,
@@ -60,19 +59,21 @@ public ResourceAcquiredListener(
6059
this._logger = logger ?? throw new ArgumentNullException(nameof(logger));
6160
_consumerFactory = consumerFactory ?? throw new ArgumentNullException(nameof(consumerFactory));
6261
_consumeExceptionHandler = consumeExceptionHandler ?? throw new ArgumentNullException(nameof(consumeExceptionHandler));
63-
_consumeExceptionHandler.ServiceName = serviceInformation.Value.ServiceName;
62+
6463
_consumeExceptionHandler.Topic = $"{nameof(KafkaTopic.ResourceAcquired)}-Error";
6564
_deadLetterExceptionHandler = deadLetterExceptionHandler ?? throw new ArgumentNullException(nameof(deadLetterExceptionHandler));
66-
_deadLetterExceptionHandler.ServiceName = serviceInformation.Value.ServiceName;
65+
6766
_deadLetterExceptionHandler.Topic = $"{nameof(KafkaTopic.ResourceAcquired)}-Error";
6867
_transientExceptionHandler = transientExceptionHandler;
69-
_transientExceptionHandler.ServiceName = serviceInformation.Value.ServiceName;
68+
7069
_transientExceptionHandler.Topic = KafkaTopic.ResourceAcquiredRetry.GetStringValue();
7170
_metrics = metrics ?? throw new ArgumentNullException(nameof(metrics));
7271

7372
_scopeFactory = scopeFactory;
7473
_producer = producer ?? throw new ArgumentNullException(nameof(producer));
7574

75+
_serviceInformation = serviceInformation ?? throw new ArgumentNullException(nameof(serviceInformation));
76+
7677
_copyPropertyOperationService = copyPropertyOperationService;
7778
_codeMapOperationService = codeMapOperationService ?? throw new ArgumentNullException(nameof(codeMapOperationService));
7879
_conditionalTransformOperationService = conditionalTransformOperationService ?? throw new ArgumentNullException(nameof(conditionalTransformOperationService));
@@ -88,7 +89,7 @@ private async Task StartConsumerLoop(CancellationToken cancellationToken)
8889
{
8990
using var kafkaConsumer = _consumerFactory.CreateConsumer(new ConsumerConfig
9091
{
91-
GroupId = NormalizationConstants.ServiceName,
92+
GroupId = _serviceInformation.ServiceConfigName,
9293
EnableAutoCommit = false
9394
});
9495

DotNet/Normalization/Program.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,13 @@ static void RegisterServices(WebApplicationBuilder builder)
5858
// load external configuration source (if specified)
5959
builder.AddExternalConfiguration(NormalizationConstants.ServiceName);
6060

61-
IConfigurationSection serviceInformationSection = builder.Configuration.GetRequiredSection(NormalizationConstants.AppSettingsSectionNames.ServiceInformation);
62-
builder.Services.Configure<ServiceInformation>(serviceInformationSection);
63-
var serviceInformation = serviceInformationSection.Get<ServiceInformation>();
61+
var serviceInformation = builder.Configuration.GetRequiredSection(ServiceInformation.SectionName).Get<ServiceInformation>();
62+
6463
if (serviceInformation != null)
6564
{
66-
ServiceActivitySource.Initialize(serviceInformation);;
65+
serviceInformation!.ServiceConfigName = NormalizationConstants.ServiceName;
66+
builder.Services.AddSingleton<ServiceInformation>(serviceInformation);
67+
ServiceActivitySource.Initialize(serviceInformation);
6768
}
6869
else
6970
{
@@ -212,7 +213,7 @@ static void RegisterServices(WebApplicationBuilder builder)
212213

213214
if (consumerSettings != null && !consumerSettings.DisableRetryConsumer)
214215
{
215-
builder.Services.AddSingleton(new RetryListenerSettings(NormalizationConstants.ServiceName, [KafkaTopic.ResourceAcquiredRetry.GetStringValue()]));
216+
builder.Services.AddSingleton(new RetryListenerSettings(serviceInformation.ServiceName, [KafkaTopic.ResourceAcquiredRetry.GetStringValue()]));
216217
builder.Services.AddHostedService<RetryListener>();
217218
builder.Services.AddHostedService<RetryScheduleService>();
218219
}

0 commit comments

Comments
 (0)