feat(adminui): add DriverStatusSignalRBridge + InMemory snapshot store
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
using System.Collections.Concurrent;
|
||||
using ZB.MOM.WW.OtOpcUa.Commons.Messages.Drivers;
|
||||
|
||||
namespace ZB.MOM.WW.OtOpcUa.AdminUI.Hubs;
|
||||
|
||||
/// <summary>
|
||||
/// Thread-safe in-memory implementation of <see cref="IDriverStatusSnapshotStore"/>.
|
||||
/// Keyed by <see cref="DriverHealthChanged.DriverInstanceId"/>; last write wins.
|
||||
/// </summary>
|
||||
public sealed class InMemoryDriverStatusSnapshotStore : IDriverStatusSnapshotStore
|
||||
{
|
||||
private readonly ConcurrentDictionary<string, DriverHealthChanged> _byInstance = new();
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Upsert(DriverHealthChanged snapshot)
|
||||
=> _byInstance[snapshot.DriverInstanceId] = snapshot;
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool TryGet(string driverInstanceId, out DriverHealthChanged snapshot)
|
||||
=> _byInstance.TryGetValue(driverInstanceId, out snapshot!);
|
||||
}
|
||||
Reference in New Issue
Block a user