using Opc.Ua;
using ZB.MOM.WW.OtOpcUa.Core.Abstractions.DataConnections;
using ZB.MOM.WW.OtOpcUa.OpcUaServer.Security;
namespace ZB.MOM.WW.OtOpcUa.OpcUaServer;
/// A caller- and item-scoped projection demand, bound to its original local and remote authority.
public interface IProjectedDemandLease : IDisposable
{
DataView OriginView { get; }
DataRealm Realm { get; }
string LocalIdentifier { get; }
long ProjectionGeneration { get; }
/// Maximum allowed origin-cache age; zero denies sample delivery.
TimeSpan MaximumSampleAge => TimeSpan.Zero;
ServingIdentity Serving { get; }
CancellationToken CancellationToken { get; }
bool IsValid { get; }
}
/// Nonblocking local admission and bounded scheduling for projected data.
public interface IProjectedDataAccess
{
TimeProvider Clock { get; }
bool TryAcquire(NodeId nodeId, RoleCarryingUserIdentity caller, DataOperations operation, out IProjectedDemandLease? demand);
/// On success owns the demand through physical completion; otherwise the caller retains it.
bool ScheduleRead(IProjectedDemandLease demand, DataBudget budget, long requestStartedTimestamp);
Task WriteAsync(IProjectedDemandLease demand, object? value, DataBudget budget,
long requestStartedTimestamp, CancellationToken cancellationToken);
bool StartSubscription(IProjectedDemandLease demand, TimeSpan publishingInterval);
/// Requests a coalesced fresh authenticated snapshot without changing caller ownership.
bool RequestFreshSnapshot(IProjectedDemandLease demand) => false;
/// True while a demand or physically retained operation still owns this projection.
bool HasLiveDemand(DataRealm realm, string localIdentifier) => true;
}