using ZB.MOM.WW.ScadaBridge.Commons.Interfaces.Services; using ZB.MOM.WW.ScadaBridge.Commons.Messages.Communication; namespace ZB.MOM.WW.ScadaBridge.ManagementService.Tests; /// /// Test stand-in for the central cache-invalidation bus (ScadaBridge#100 item 3): records every /// published invalidation and hands it to the "peer" node's handlers, as the subscriber on the /// other central node would. /// internal sealed class PeerCacheInvalidationPublisher : ICentralCacheInvalidationPublisher { private readonly ICentralCacheInvalidationHandler[] _peerHandlers; /// Creates the publisher. /// The peer node's handlers. public PeerCacheInvalidationPublisher(params ICentralCacheInvalidationHandler[] peerHandlers) => _peerHandlers = peerHandlers; /// Gets every invalidation published. public List Published { get; } = new(); /// public void Publish(ICentralCacheInvalidation invalidation) { lock (Published) Published.Add(invalidation); foreach (var handler in _peerHandlers) handler.Apply(invalidation); } }