Skip to content

Commit

Permalink
outbox Dir
Browse files Browse the repository at this point in the history
  • Loading branch information
johnml1135 committed Jul 1, 2024
1 parent 2207ae3 commit 908db33
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ public class MessageOutboxOptions
{
public const string Key = "MessageOutbox";

public string DataDir { get; set; } = "outbox";
public string OutboxDir { get; set; } = "outbox";
public TimeSpan MessageExpirationTimeout { get; set; } = TimeSpan.FromHours(48);
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ ILogger<MessageOutboxDeliveryService> logger

protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
Initialize();
using IServiceScope scope = _services.CreateScope();
var messages = scope.ServiceProvider.GetRequiredService<IRepository<OutboxMessage>>();
using ISubscription<OutboxMessage> subscription = await messages.SubscribeAsync(e => true, stoppingToken);
Expand All @@ -31,6 +32,11 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken)
}
}

private void Initialize()
{
_fileSystem.CreateDirectory(_options.CurrentValue.OutboxDir);
}

internal async Task ProcessMessagesAsync(
IRepository<OutboxMessage> messages,
CancellationToken cancellationToken = default
Expand Down Expand Up @@ -99,7 +105,7 @@ private async Task ProcessGroupMessagesAsync(
)
{
Stream? contentStream = null;
string filePath = Path.Combine(_options.CurrentValue.DataDir, message.Id);
string filePath = Path.Combine(_options.CurrentValue.OutboxDir, message.Id);
if (message.HasContentStream)
contentStream = _fileSystem.OpenRead(filePath);
try
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ await _outboxes.UpdateAsync(
Content = content,
HasContentStream = contentStream is not null
};
string filePath = Path.Combine(_options.CurrentValue.DataDir, outboxMessage.Id);
string filePath = Path.Combine(_options.CurrentValue.OutboxDir, outboxMessage.Id);
try
{
if (contentStream is not null)
Expand Down
3 changes: 2 additions & 1 deletion src/SIL.Machine.Serval.EngineServer/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
"BuildPollingEnabled": true
},
"MessageOutbox": {
"MessageExpirationInHours": 48
"MessageExpirationInHours": 48,
"OutboxDir": "/var/lib/machine/outbox"
},
"Logging": {
"LogLevel": {
Expand Down
4 changes: 4 additions & 0 deletions src/SIL.Machine.Serval.JobServer/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
"ClearML": {
"BuildPollingEnabled": false
},
"MessageOutbox": {
"MessageExpirationInHours": 48,
"OutboxDir": "/var/lib/machine/outbox"
},
"Logging": {
"LogLevel": {
"System.Net.Http.HttpClient.Default": "Warning"
Expand Down

0 comments on commit 908db33

Please sign in to comment.