namespace ZB.MOM.WW.OtOpcUa.Commons.OpcUa;
///
/// Late-binding adapter that holds an inner reference
/// swappable at runtime. Mirrors : Akka actors resolve
/// the publisher at DI time, but the production SdkServiceLevelPublisher only exists
/// after StandardServer.Start. The Host's hosted service swaps the inner once the SDK
/// is up; until then writes route through .
///
public sealed class DeferredServiceLevelPublisher : IServiceLevelPublisher
{
private volatile IServiceLevelPublisher _inner = NullServiceLevelPublisher.Instance;
/// Swap the underlying publisher. Pass null to revert to the Null no-op.
/// The publisher implementation to use, or null to use the null publisher.
public void SetInner(IServiceLevelPublisher? inner) =>
_inner = inner ?? NullServiceLevelPublisher.Instance;
/// Publishes a service level value to the inner publisher.
/// The service level to publish.
public void Publish(byte serviceLevel) => _inner.Publish(serviceLevel);
}