2
0
mirror of https://github.com/9ParsonsB/Pulsar.git synced 2025-04-05 17:39:39 -04:00
pulsar/Pulsar/Features/Journal/JournalService.cs
Ben Parsons efd0b3e0c0 Journals Now processed in own thread
Some invalid journal data is now handled
Journals now use polymorphic deserialization
Added Event names to all journal events
Remove unused controllers
2024-05-24 19:30:12 +10:00

44 lines
1.0 KiB
C#

namespace Pulsar.Features.Journal;
using System.Collections.Concurrent;
using Observatory.Framework.Files.Journal;
public interface IJournalService : IJournalHandler<List<JournalBase>>
{
public bool TryDequeue(out string filePath);
}
public class JournalService(
ILogger<JournalService> logger
) : IJournalService
{
public string FileName => FileHandlerService.JournalLogFileName;
private readonly ConcurrentQueue<string> JournalFileQueue = new();
public void EnqueueFile(string filePath)
{
JournalFileQueue.Enqueue(filePath);
}
public bool TryDequeue(out string filePath)
{
return JournalFileQueue.TryDequeue(out filePath);
}
public Task HandleFile(string filePath, CancellationToken token = new())
{
if (!FileHelper.ValidateFile(filePath))
{
return Task.CompletedTask;
}
EnqueueFile(filePath);
return Task.CompletedTask;
}
public async Task<List<JournalBase>> Get()
{
return [];
}
}