/* ======================================================================== * Copyright (c) 2005-2025 The OPC Foundation, Inc. All rights reserved. * * OPC Foundation MIT License 1.00 * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation * files (the "Software"), to deal in the Software without * restriction, including without limitation the rights to use, * copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following * conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. * * The complete license agreement can be found here: * http://opcfoundation.org/License/MIT/1.00/ * ======================================================================*/ using System; using System.Threading; using System.Threading.Tasks; namespace Opc.Ua.Client { /// /// Defines the subscription engine that manages the publish loop, /// subscription lifecycle, and notification dispatch for a session. /// Implementations can be swapped at session creation time to use /// different publish strategies (e.g., classic fire-and-forget vs. /// Channel-based worker pool). /// public interface ISubscriptionEngine : IDisposable { /// /// Start the publish loop. Called after the session is activated /// and subscriptions may begin receiving notifications. /// /// The timeout for publish requests in /// milliseconds. /// Whether to fill the publish queue /// completely on start. void StartPublishing(int timeout, bool fullQueue); /// /// Stop the publish loop and wait for outstanding publish /// requests to complete or be cancelled. Called before session /// close or dispose. /// /// Cancellation token. ValueTask StopPublishingAsync(CancellationToken ct = default); /// /// Pause publishing. Called when the session enters a reconnect /// state and publish responses should not be processed. /// void PausePublishing(); /// /// Resume publishing after a pause. Called when the session /// reconnect completes and publish responses can be processed /// again. /// void ResumePublishing(); /// /// Notify the engine that subscriptions have been added, removed, /// or modified, so the publish pipeline depth should be /// re-evaluated. /// void NotifySubscriptionsChanged(); /// /// Drive a recreate / transfer pass for all subscriptions managed /// by the engine after the underlying session has been /// (re-)established. Implementations that maintain their own /// subscription bookkeeping (e.g. the V2 /// ) drive /// transfer-on-recreate or per-subscription recreate here. /// Implementations that do not (e.g. the classic engine, where /// the host drives recreate via subscription /// templates) MUST treat this as a no-op. /// /// /// The previous server-assigned of the /// session before it was re-created. May be null when the /// caller has no prior session id (initial connect). When /// non-null, V2 subscriptions configured for transfer-on-recreate /// will attempt to transfer their server-side state from the /// previous session into the current one. /// /// Cancellation token. ValueTask RecreateSubscriptionsAsync( NodeId? previousSessionId, CancellationToken ct = default); /// /// The number of currently outstanding publish requests that /// have received a successful response. /// int GoodPublishRequestCount { get; } /// /// The number of publish requests that resulted in an error. /// int BadPublishRequestCount { get; } /// /// The current number of active publish workers or in-flight /// publish requests. /// int PublishWorkerCount { get; } /// /// Gets or sets the minimum number of publish requests to /// keep in the pipeline. /// int MinPublishRequestCount { get; set; } /// /// Gets or sets the maximum number of publish requests to /// keep in the pipeline. /// int MaxPublishRequestCount { get; set; } } }