Skip to content

Commit de59e44

Browse files
committed
Add runtime snapshot adapter for live and replay data sources
1 parent a6cd5ed commit de59e44

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using ProcessBus.Core.Services;
2+
3+
namespace ProcessBus.Iec61850.Raw.Runtime;
4+
5+
/// <summary>
6+
/// Adapts any analyzer data source, including the live Npcap-backed source, to the
7+
/// immutable runtime publication boundary. This enables staged consumer migration
8+
/// without changing the existing capture contract or introducing a second decoder.
9+
/// </summary>
10+
public sealed class AnalyzerRuntimeSnapshotSource
11+
{
12+
private readonly IAnalyzerDataSource _source;
13+
private readonly SvRuntimeSnapshotPublisher _publisher = new();
14+
15+
public AnalyzerRuntimeSnapshotSource(IAnalyzerDataSource source)
16+
{
17+
_source = source ?? throw new ArgumentNullException(nameof(source));
18+
}
19+
20+
public string Name => _source.Name;
21+
public SvRuntimeSnapshot Latest => _publisher.Latest;
22+
23+
public async Task<SvRuntimeSnapshot> GetSnapshotAsync(CancellationToken cancellationToken = default)
24+
{
25+
var analyzerSnapshot = await _source.GetSnapshotAsync(cancellationToken).ConfigureAwait(false);
26+
cancellationToken.ThrowIfCancellationRequested();
27+
return _publisher.Publish(analyzerSnapshot);
28+
}
29+
30+
public void Reset() => _publisher.Reset();
31+
}

0 commit comments

Comments
 (0)