/* ======================================================================== * 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; namespace Opc.Ua.Server.Historian { /// /// Back-pressure policy for the auto-capture queue. /// public enum CaptureFullMode { /// /// Drop the oldest pending sample to make room for the new one /// (default). Keeps the queue length bounded and prefers freshness /// over completeness; appropriate for high-frequency telemetry /// where a brief overload should not block the value-setting /// thread. /// DropOldest = 0, /// /// Drop the new sample. Preserves the order of the existing /// queued samples; appropriate when older samples are more /// important than the latest reading (rare). /// DropNewest = 1, /// /// Block the value-setting thread until queue space frees up. /// Guarantees no sample loss at the cost of back-pressuring the /// producer. /// Wait = 2 } /// /// Knobs for the per-provider auto-capture pipeline. Defaults are /// tuned for typical industrial telemetry (a few hundred Hz across /// thousands of variables). /// /// /// /// One HistorianCaptureSink is constructed per /// HistorianBuilder (i.e. per server-side historian binding); /// the same options apply to every variable opted in via /// Historize(autoCapture: true) through that builder. /// /// public sealed record HistorianCaptureOptions { /// /// Maximum number of samples buffered in the capture queue before /// kicks in. Default 4096. /// public int MaxQueuedSamples { get; init; } = 4096; /// /// Target sample count per flush. The consumer attempts to drain /// up to this many items per flush; smaller batches reduce /// latency, larger ones amortise per-call provider overhead. /// Default 64. /// public int BatchTarget { get; init; } = 64; /// /// Maximum time the consumer waits for additional samples before /// flushing a partial batch. Lower values reduce capture /// latency; higher values pack more samples per flush. Default /// 25 ms. /// public TimeSpan BatchWindow { get; init; } = TimeSpan.FromMilliseconds(25); /// /// Behavior when the queue is full. Default /// . /// public CaptureFullMode FullMode { get; init; } = CaptureFullMode.DropOldest; } }