Skip to content

Commit 700a410

Browse files
Merge branch 'dev' into LNK-4651-AddHic-Type-for-AdhocReportGeneration
2 parents 0cf2dfb + 63aa79b commit 700a410

111 files changed

Lines changed: 3667 additions & 822 deletions

File tree

Some content is hidden

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

.env

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,8 @@ KAFKA_INTER_BROKER_PASSWORD=controller_password
88
AZURITE_CONNECTION_STRING=DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://azurite:10000/devstoreaccount1
99
INTERNAL_BLOB_CONTAINER_NAME=internal
1010
EXTERNAL_BLOB_CONTAINER_NAME=external
11-
ISSUER_URI=https://oauth.nhsnlink.org/realms/NHSNLink
11+
ISSUER_URI=https://oauth.nhsnlink.org/realms/NHSNLink
12+
13+
KafkaConnection__SaslUsername=${KAFKA_SASL_CLIENT_USER}
14+
KafkaConnection__SaslPassword=${KAFKA_SASL_CLIENT_PASSWORD}
15+
Redis__Password=${REDIS_PASS}

.github/dependabot.yml

Lines changed: 0 additions & 58 deletions
This file was deleted.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
title: "SNYK: {{ snyk_pull_request_type }} for {{ package_name }}"
2+
description: |
3+
{{ #is_upgrade_pr }}
4+
This PR has been opened by Snyk to make sure our repositories are kept up-to-date.
5+
It updates **{{ package_name }}** from version {{ package_from }} to version {{ package_to }}.
6+
Review relevant docs for possible breaking changes.
7+
{{ /is_upgrade_pr }}
8+
9+
{{ #is_fix_pr }}
10+
This PR applies a fix for a vulnerability in **{{ package_name }}**.
11+
{{ /is_fix_pr }}
12+
13+
**Issues Fixed:** {{ issue_count }}

.github/workflows/pr-title-check.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ jobs:
3030
} else {
3131
core.setFailed('Cannot determine PR title for validation.')
3232
}
33-
const prTitleExpectedPattern = /(^LNK-\d+:\s)|(^TECH_DEBT:\s)|(^DOCS:\s)/g
34-
const prTitleMismatchError = 'Invalid PR title "' + prTitle + '"! Must begin with LNK-nnnn:<space> or TECH_DEBT:<space> or DOCS:<space>, e.g. LNK-1234: My PR title, or TECH_DEBT: My PR title or DOCS: My PR title'
33+
const prTitleExpectedPattern = /(^LNK-\d+:\s)|(^TECH_DEBT:\s)|(^DOCS:\s)|(^SNYK:\s)|(^Bump\s)/g
34+
const prTitleMismatchError = 'Invalid PR title "' + prTitle + '"! Must begin with LNK-nnnn:<space> or TECH_DEBT:<space> or DOCS:<space> or SNYK:<space> or Bump<space>, e.g. LNK-1234: My PR title, or TECH_DEBT or DOCS or SNYK or Bump: My PR title or DOCS: My PR title or [Snyk] My PR title'
3535
if (!prTitleExpectedPattern.test(prTitle)) {
3636
// Fail the workflow
3737
console.log(prTitleMismatchError)

DotNet/Account/Account.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<TargetFramework>net8.0</TargetFramework>
5-
<Version>0.1.1-dev</Version>
5+
<Version>0.4.1</Version>
66
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
77
<Nullable>enable</Nullable>
88
<ImplicitUsings>enable</ImplicitUsings>

DotNet/Account/Program.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
using System.Text.Json.Serialization;
4444

4545
var builder = WebApplication.CreateBuilder(args);
46+
builder.Configuration.AddStandardEnvironmentConfiguration();
4647

4748
// Additional configuration is required to successfully run gRPC on macOS.
4849
// For instructions on how to configure Kestrel and gRPC clients on macOS, visit https://go.microsoft.com/fwlink/?linkid=2099682

DotNet/Account/appsettings.Docker.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
},
77
"KafkaConnection": {
88
"BootstrapServers": [
9-
"kafka_b:9094"
9+
"kafka_b:9092"
1010
],
1111
"SaslProtocolEnabled": true
1212
},

DotNet/Admin.BFF/Admin.BFF.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<TargetFramework>net8.0</TargetFramework>
5-
<Version>0.1.1-dev</Version>
5+
<Version>0.4.1</Version>
66
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
77
<Nullable>enable</Nullable>
88
<ImplicitUsings>enable</ImplicitUsings>
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
using LantanaGroup.Link.LinkAdmin.BFF.Application.Models.Health;
2+
using LantanaGroup.Link.LinkAdmin.BFF.Infrastructure.Logging;
3+
using LantanaGroup.Link.Shared.Application.Models.Configs;
4+
using Microsoft.Extensions.Diagnostics.HealthChecks;
5+
using Microsoft.Extensions.Options;
6+
using System.Net.Http.Headers;
7+
8+
namespace LantanaGroup.Link.LinkAdmin.BFF.Application.Clients
9+
{
10+
public class TerminologyService
11+
{
12+
private readonly ILogger<TerminologyService> _logger;
13+
private readonly HttpClient _client;
14+
private readonly IOptions<ServiceRegistry> _serviceRegistry;
15+
16+
public TerminologyService(ILogger<TerminologyService> logger, HttpClient client, IOptions<ServiceRegistry> serviceRegistry)
17+
{
18+
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
19+
_client = client ?? throw new ArgumentNullException(nameof(client));
20+
_serviceRegistry = serviceRegistry ?? throw new ArgumentNullException(nameof(serviceRegistry));
21+
22+
InitHttpClient();
23+
}
24+
25+
public async Task<HttpResponseMessage> ServiceHealthCheck(CancellationToken cancellationToken)
26+
{
27+
// HTTP GET
28+
HttpResponseMessage response = await _client.GetAsync($"health", cancellationToken);
29+
30+
return response;
31+
}
32+
33+
public async Task<LinkServiceHealthReport> LinkServiceHealthCheck(CancellationToken cancellationToken)
34+
{
35+
// HTTP GET
36+
try
37+
{
38+
var response = await _client.GetAsync($"health", cancellationToken);
39+
var healthResult = await response.Content.ReadFromJsonAsync<LinkServiceHealthReport>(cancellationToken: cancellationToken);
40+
41+
if (healthResult is null)
42+
{
43+
_logger.LogWarning("Terminology service health check returned null or invalid response");
44+
return new LinkServiceHealthReport() { Service = "Terminology", Status = HealthStatus.Unhealthy };
45+
}
46+
47+
healthResult.Service = "Terminology";
48+
return healthResult;
49+
}
50+
catch (Exception ex)
51+
{
52+
_logger.LogError(ex, "Terminology service health check failed");
53+
return new LinkServiceHealthReport { Service = "Terminology", Status = HealthStatus.Unhealthy };
54+
}
55+
}
56+
57+
private void InitHttpClient()
58+
{
59+
//check if the service uri is set
60+
if (string.IsNullOrEmpty(_serviceRegistry.Value.TerminologyServiceUrl))
61+
{
62+
_logger.LogGatewayServiceUriException("Terminology", "Terminology service uri is not set");
63+
throw new ArgumentNullException("Terminology Service URL is missing.");
64+
}
65+
66+
_client.BaseAddress = new Uri(_serviceRegistry.Value.TerminologyServiceUrl);
67+
_client.DefaultRequestHeaders.Accept.Clear();
68+
_client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
69+
}
70+
}
71+
}

DotNet/Admin.BFF/Application/Commands/Integration/KafkaConsumerService.cs

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -41,30 +41,21 @@ public void StartConsumer(string groupId, List<string> topics, string reportTrac
4141
string traceId = string.Empty;
4242
string errorMessage = null;
4343

44-
if (consumeResult.Message.Headers.TryGetLastBytes("X-Correlation-Id",
45-
out var correlationHeader))
44+
if (consumeResult.Message.Headers.TryGetLastBytes("X-Correlation-Id", out var correlationHeader))
4645
{
4746
correlationId = System.Text.Encoding.UTF8.GetString(correlationHeader);
4847

4948
// read the exceptions
50-
if (consumeResult.Message.Headers.TryGetLastBytes("X-Exception-Message",
51-
out var exceptionMessage))
52-
{
53-
errorMessage = System.Text.Encoding.UTF8.GetString(exceptionMessage);
54-
}
55-
56-
else if (consumeResult.Message.Headers.TryGetLastBytes("X-Retry-Exception-Message",
57-
out var retryExceptionMessage))
58-
{
59-
errorMessage = System.Text.Encoding.UTF8.GetString(retryExceptionMessage);
60-
}
61-
62-
else if (consumeResult.Message.Headers.TryGetLastBytes("kafka_exception-message",
63-
out var kafkaErrorBytes))
49+
50+
if (TryReadHeader(consumeResult.Message.Headers, out var errorBytes,
51+
"X-Exception-Message",
52+
"X-Retry-Exception-Message",
53+
"kafka_exception-message",
54+
"kafka_dlt-exception-message"))
6455
{
65-
errorMessage = System.Text.Encoding.UTF8.GetString(kafkaErrorBytes);
56+
errorMessage = System.Text.Encoding.UTF8.GetString(errorBytes);
6657
}
67-
58+
6859
// Extract traceId from traceparent header
6960
if (consumeResult.Message.Headers.TryGetLastBytes("traceparent", out var traceParentBytes))
7061
{
@@ -155,6 +146,23 @@ public void StartConsumer(string groupId, List<string> topics, string reportTrac
155146
}
156147
}
157148

149+
private static bool TryReadHeader(
150+
Headers headers,
151+
out byte[] value,
152+
params string[] keys)
153+
{
154+
foreach (var key in keys)
155+
{
156+
if (headers.TryGetLastBytes(key, out value))
157+
{
158+
return true;
159+
}
160+
}
161+
162+
value = null!;
163+
return false;
164+
}
165+
158166
private bool checkReportTrackingId(string input, string reportTrackingId)
159167
{
160168
if (string.IsNullOrEmpty(input)) return false;

0 commit comments

Comments
 (0)