Premiere commit - Omika

This commit is contained in:
2026-10-23 18:46:50 +02:00
commit 8ea76c1b24
2155 changed files with 984301 additions and 0 deletions
@@ -0,0 +1,58 @@
using Omika.Core.Observability.External;
using Omika.Diagnostics.Import;
namespace Omika.Diagnostics.Tests.Fakes;
/// <summary>
/// Source JSONL en mémoire : modèle un flux de <see cref="RemoteDiagnosticRecord"/>
/// avec un checkpoint (LineIndex = index du dernier enregistrement lu). Permet de
/// tester l'importeur et son avancement de checkpoint sans PostgreSQL.
/// </summary>
public sealed class FakeDiagnosticJsonlSource : IDiagnosticJsonlSource
{
private readonly List<RemoteDiagnosticRecord> _records;
private DiagnosticImportCheckpoint? _checkpoint;
public FakeDiagnosticJsonlSource(IReadOnlyList<RemoteDiagnosticRecord> records)
{
_records = records.ToList();
}
public int CommitCount { get; private set; }
public DiagnosticImportCheckpoint? LastCommitted { get; private set; }
public DiagnosticImportCheckpoint? LoadCheckpoint() => _checkpoint;
public DiagnosticJsonlReadResult ReadNext(DiagnosticImportCheckpoint? after, int maxCount)
{
int start = after is null ? 0 : after.LineIndex + 1;
if (start >= _records.Count)
{
return new DiagnosticJsonlReadResult { ReachedEnd = true };
}
int count = Math.Min(maxCount, _records.Count - start);
List<RemoteDiagnosticRecord> records = _records.GetRange(start, count);
var next = new DiagnosticImportCheckpoint
{
FileName = "fake.jsonl",
LineIndex = start + count - 1
};
return new DiagnosticJsonlReadResult
{
Records = records,
NextPosition = next,
ReachedEnd = start + count >= _records.Count
};
}
public void Commit(DiagnosticImportCheckpoint position)
{
_checkpoint = position;
LastCommitted = position;
CommitCount++;
}
}