Skip to content
This repository was archived by the owner on Jul 28, 2025. It is now read-only.

Commit 939f9ee

Browse files
committed
renames
1 parent f5adb31 commit 939f9ee

6 files changed

Lines changed: 28 additions & 45 deletions

File tree

.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ MeshPassword=password
1313
BSSMailBox=X26ABC1
1414
MeshApiBaseUrl=http://localhost:8700/messageexchange
1515
ASPNETCORE_ENVIRONMENT=Development
16-
DiscoveryTimerExpression=*/5 * * * *
16+
FileDiscoveryTimerExpression=*/5 * * * *
1717
QueueUrl=http://127.0.0.1:10001
1818

1919
# API Configuration

src/ServiceLayer.Mesh/Functions/DiscoveryFunction.cs renamed to src/ServiceLayer.Mesh/Functions/FileDiscoveryFunction.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88

99
namespace ServiceLayer.Mesh.Functions
1010
{
11-
public class DiscoveryFunction(
12-
ILogger<DiscoveryFunction> logger,
11+
public class FileDiscoveryFunction(
12+
ILogger<FileDiscoveryFunction> logger,
1313
IMeshInboxService meshInboxService,
1414
ServiceLayerDbContext serviceLayerDbContext,
1515
IFileExtractQueueClient fileExtractQueueClient)
1616
{
17-
[Function("DiscoveryFunction")]
18-
public async Task Run([TimerTrigger("%DiscoveryTimerExpression%")] TimerInfo myTimer)
17+
[Function("FileDiscoveryFunction")]
18+
public async Task Run([TimerTrigger("%FileDiscoveryTimerExpression%")] TimerInfo myTimer)
1919
{
2020
logger.LogInformation($"DiscoveryFunction started at: {DateTime.Now}");
2121

src/ServiceLayer.Mesh/Functions/ExtractFunction.cs renamed to src/ServiceLayer.Mesh/Functions/FileExtractFunction.cs

Lines changed: 17 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using Azure.Storage.Blobs;
22
using Azure.Storage.Blobs.Models;
3-
using Azure.Storage.Queues;
43
using Microsoft.Azure.Functions.Worker;
54
using Microsoft.EntityFrameworkCore;
65
using Microsoft.Extensions.Logging;
@@ -11,36 +10,27 @@
1110

1211
namespace ServiceLayer.Mesh.Functions;
1312

14-
public class ExtractFunction
13+
public class FileExtractFunction(
14+
ILogger logger,
15+
IMeshInboxService meshInboxService,
16+
ServiceLayerDbContext serviceLayerDbContext,
17+
IFileTransformQueueClient fileTransformQueueClient,
18+
BlobContainerClient blobContainerClient)
1519
{
16-
private readonly ILogger _logger;
17-
private readonly IMeshInboxService _meshInboxService;
18-
private readonly ServiceLayerDbContext _serviceLayerDbContext;
19-
private readonly QueueClient _queueClient;
20-
private readonly BlobContainerClient _blobContainerClient;
21-
22-
public ExtractFunction(ILogger logger, IMeshInboxService meshInboxService, ServiceLayerDbContext serviceLayerDbContext, QueueClient queueClient, BlobContainerClient blobClient)
23-
{
24-
_logger = logger;
25-
_meshInboxService = meshInboxService;
26-
_serviceLayerDbContext = serviceLayerDbContext;
27-
_queueClient = queueClient;
28-
_blobContainerClient = blobClient;
29-
}
30-
31-
[Function("ExtractFunction")]
20+
[Function("FileExtractFunction")]
3221
public async Task Run([QueueTrigger("file-extract")] FileExtractQueueMessage message) // TODO: Queue name
3322
{
34-
_logger.LogInformation($"ExtractFunction started at: {DateTime.Now}");
23+
logger.LogInformation($"ExtractFunction started at: {DateTime.Now}");
3524

36-
await using var transaction = await _serviceLayerDbContext.Database.BeginTransactionAsync();
25+
await using var transaction = await serviceLayerDbContext.Database.BeginTransactionAsync();
3726

38-
var file = await _serviceLayerDbContext.MeshFiles
27+
var file = await serviceLayerDbContext.MeshFiles
3928
.FirstOrDefaultAsync(f => f.FileId == message.FileId);
4029

4130
if (file == null)
4231
{
4332
// TODO - do we want to throw exception or just exit silently?
33+
// ANswer - exit silenty
4434
throw new InvalidOperationException("File not found");
4535
}
4636

@@ -51,19 +41,20 @@ public async Task Run([QueueTrigger("file-extract")] FileExtractQueueMessage mes
5141
file.Status == MeshFileStatus.Extracting && file.LastUpdatedUtc > DateTime.UtcNow.AddHours(-12))
5242
{
5343
// TODO - do we want to throw exception or just exit silently?
44+
// ANswer - exit silenty
5445
throw new InvalidOperationException("File is not in expected status");
5546
}
5647

5748
file.Status = MeshFileStatus.Extracting;
5849
file.LastUpdatedUtc = DateTime.UtcNow;
5950

60-
await _serviceLayerDbContext.SaveChangesAsync();
51+
await serviceLayerDbContext.SaveChangesAsync();
6152
await transaction.CommitAsync();
6253

6354
var mailboxId = Environment.GetEnvironmentVariable("MeshMailboxId")
6455
?? throw new InvalidOperationException($"Environment variable 'MeshMailboxId' is not set or is empty.");
6556

66-
var meshResponse = await _meshInboxService.GetMessageByIdAsync(mailboxId, file.FileId);
57+
var meshResponse = await meshInboxService.GetMessageByIdAsync(mailboxId, file.FileId);
6758
if (!meshResponse.IsSuccessful)
6859
{
6960
// TODO - what to do if unsuccessful?
@@ -75,17 +66,17 @@ public async Task Run([QueueTrigger("file-extract")] FileExtractQueueMessage mes
7566

7667
public async Task<bool> UploadFileToBlobStorage(BlobFile blobFile, bool overwrite = false)
7768
{
78-
var blobClient = _blobContainerClient.GetBlobClient(blobFile.FileName);
69+
var blobClient = blobContainerClient.GetBlobClient(blobFile.FileName);
7970

80-
await _blobContainerClient.CreateIfNotExistsAsync(PublicAccessType.None);
71+
await blobContainerClient.CreateIfNotExistsAsync(PublicAccessType.None);
8172

8273
try
8374
{
8475
await blobClient.UploadAsync(blobFile.Data, overwrite: overwrite);
8576
}
8677
catch (Exception ex)
8778
{
88-
_logger.LogError(ex, "There has been a problem while uploading the file: {Message}", ex.Message);
79+
logger.LogError(ex, "There has been a problem while uploading the file: {Message}", ex.Message);
8980
return false;
9081
}
9182

src/ServiceLayer.Mesh/Messaging/IFileTransformQueueClient.cs

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

33
namespace ServiceLayer.Mesh.Messaging;
44

5-
internal interface IFileTransformQueueClient
5+
public interface IFileTransformQueueClient
66
{
77
Task EnqueueFileTransformAsync(MeshFile file);
88
Task SendToPoisonQueueAsync(FileTransformQueueMessage message);

tests/ServiceLayer.Mesh.Tests/Functions/DiscoveryFunctionTests.cs renamed to tests/ServiceLayer.Mesh.Tests/Functions/FileDiscoveryFunctionTests.cs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,22 @@
1-
using System;
2-
using System.Linq;
3-
using System.Threading;
4-
using System.Threading.Tasks;
5-
using Microsoft.Extensions.Logging;
1+
using Microsoft.Extensions.Logging;
62
using Moq;
7-
using Xunit;
83
using ServiceLayer.Mesh.Functions;
94
using ServiceLayer.Mesh.Models;
105
using ServiceLayer.Mesh.Data;
116
using Microsoft.EntityFrameworkCore;
127
using NHS.MESH.Client.Contracts.Services;
13-
using Microsoft.Azure.Functions.Worker;
148
using NHS.MESH.Client.Models;
159
using Azure.Storage.Queues;
16-
using Azure.Storage.Queues.Models;
17-
using Azure;
1810

19-
public class DiscoveryFunctionTests
11+
public class FileDiscoveryFunctionTests
2012
{
2113
private readonly Mock<ILogger<DiscoveryFunction>> _loggerMock;
2214
private readonly Mock<IMeshInboxService> _meshInboxServiceMock;
2315
private readonly ServiceLayerDbContext _dbContext;
2416
private readonly Mock<QueueClient> _queueClientMock;
2517
private readonly DiscoveryFunction _function;
2618

27-
public DiscoveryFunctionTests()
19+
public FileDiscoveryFunctionTests()
2820
{
2921
_loggerMock = new Mock<ILogger<DiscoveryFunction>>();
3022
_meshInboxServiceMock = new Mock<IMeshInboxService>();

tests/ServiceLayer.Mesh.Tests/Functions/ExtractFunctionTests.cs renamed to tests/ServiceLayer.Mesh.Tests/Functions/FileExtractFunctionTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace ServiceLayer.Mesh.Tests.Functions;
22

3-
public class ExtractFunctionTests
3+
public class FileExtractFunctionTests
44
{
5-
5+
66
}

0 commit comments

Comments
 (0)