Skip to content

Commit 91d33f0

Browse files
committed
Added S3 support and healthcheck
1 parent 2ab34bc commit 91d33f0

18 files changed

Lines changed: 659 additions & 2 deletions

File tree

compose/start-localstack.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,23 @@ export AWS_SECRET_ACCESS_KEY=test
88

99
set -e
1010

11+
# S3 buckets
12+
echo "Bootstrapping S3 setup..."
13+
14+
## Create 'test-comparison-reports-bucket' Bucket
15+
existing_bucket=$(awslocal s3api list-buckets \
16+
--query "Buckets[?Name=='test-comparison-reports-bucket'].Name" \
17+
--output text)
18+
19+
if [ "$existing_bucket" == "test-comparison-reports-bucket" ]; then
20+
echo "S3 bucket already exists: test-comparison-reports-bucket"
21+
else
22+
awslocal s3api create-bucket --bucket test-comparison-reports-bucket --region eu-west-2 \
23+
--create-bucket-configuration LocationConstraint=eu-west-2 \
24+
--endpoint-url=http://localhost:4566
25+
echo "S3 bucket created: test-comparison-reports-bucket"
26+
fi
27+
1128
echo "Bootstrapping SQS setup..."
1229

1330
# Create SQS resources

docker-compose.override.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ services:
77
- ASPNETCORE_HTTP_PORTS=8080
88
- AWS__ServiceURL=http://localstack-emulator:4566
99
- Mongo__DatabaseUri=mongodb://mongodb:27017
10+
- StorageConfiguration__ComparisonReportsStorage__BucketName=test-comparison-reports-bucket
1011
- QueueConsumerOptions__IntakeEventQueueOptions__QueueUrl=http://sqs.eu-west-2.127.0.0.1:4566/000000000000/ls_keeper_data_intake_queue
1112
ports:
1213
- "8080"

src/KeeperData.Api/Program.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using KeeperData.Infrastructure.Telemetry.Logging;
44
using Serilog;
55
using System.Diagnostics.CodeAnalysis;
6-
using System.Text.Json.Serialization;
76

87
var app = CreateWebApplication(args);
98
await app.RunAsync();

src/KeeperData.Api/Setup/ServiceCollectionExtensions.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using KeeperData.Application.Setup;
33
using KeeperData.Infrastructure.Database.Setup;
44
using KeeperData.Infrastructure.Messaging.Setup;
5+
using KeeperData.Infrastructure.Storage.Setup;
56
using System.Text.Json.Serialization;
67

78
namespace KeeperData.Api.Setup;
@@ -39,7 +40,7 @@ public static void ConfigureApi(this IServiceCollection services, IConfiguration
3940

4041
services.AddMessagingDependencies(configuration);
4142

42-
// services.AddStorageDependencies(configuration);
43+
services.AddStorageDependencies(configuration);
4344
}
4445

4546
private static void ConfigureHealthChecks(this IServiceCollection services)

src/KeeperData.Api/appsettings.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@
1616
"Disabled": false
1717
}
1818
},
19+
"StorageConfiguration": {
20+
"ComparisonReportsStorage": {
21+
"HealthcheckEnabled": true,
22+
"BucketName": "Set in cdp-app-config (or for local development using docker-compose.override.yml)"
23+
}
24+
},
1925
"AllowedHosts": "*",
2026
"TraceHeader": "x-cdp-request-id",
2127
"Serilog": {
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace KeeperData.Core.Storage;
2+
3+
public interface IStorageClient
4+
{
5+
string ClientName { get; }
6+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
namespace KeeperData.Core.Storage;
2+
3+
public interface IStorageReader<T> where T : IStorageClient, new()
4+
{
5+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
using KeeperData.Core.Storage;
2+
3+
namespace KeeperData.Infrastructure.Storage.Clients;
4+
5+
public class ComparisonReportsStorageClient : IStorageClient
6+
{
7+
public string ClientName => GetType().Name;
8+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace KeeperData.Infrastructure.Storage.Configuration;
2+
3+
public record StorageConfiguration
4+
{
5+
public StorageConfigurationDetails ComparisonReportsStorage { get; init; } = new();
6+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace KeeperData.Infrastructure.Storage.Configuration;
2+
3+
public record StorageConfigurationDetails
4+
{
5+
public bool HealthcheckEnabled { get; init; }
6+
public string BucketName { get; init; } = string.Empty;
7+
}

0 commit comments

Comments
 (0)