namespace ZB.MOM.WW.OtOpcUa.Core.Abstractions;
///
/// Required capability for every driver instance. Owns lifecycle, metadata, health.
/// Other capabilities (, ,
/// , , ,
/// , ,
/// ) are composable — a driver implements only what its
/// backend actually supports.
///
///
/// Per docs/v2/plan.md decisions #4 (composable capability interfaces) and #53
/// (capability discovery via is checks — no redundant flag enum).
///
public interface IDriver
{
/// Stable logical ID of this driver instance, sourced from the central config DB.
string DriverInstanceId { get; }
/// Driver type name (e.g. "Galaxy", "ModbusTcp", "AbCip"). Matches DriverInstance.DriverType.
string DriverType { get; }
/// Initialize the driver from its DriverConfig JSON; open connections; prepare for first use.
Task InitializeAsync(string driverConfigJson, CancellationToken cancellationToken);
///
/// Apply a config change in place without tearing down the driver process.
/// Used by IGenerationApplier when only this driver's config changed in the new generation.
///
///
/// Per docs/v2/driver-stability.md §"In-process only (Tier A/B)" — Reinitialize is the
/// only Core-initiated recovery path for in-process drivers; if it fails, the driver instance
/// is marked Faulted and its nodes go Bad quality, but the server process keeps running.
///
Task ReinitializeAsync(string driverConfigJson, CancellationToken cancellationToken);
/// Stop the driver, close connections, release resources. Called on shutdown or driver removal.
Task ShutdownAsync(CancellationToken cancellationToken);
/// Current health snapshot, polled by Core for the status dashboard and ServiceLevel.
DriverHealth GetHealth();
///
/// Approximate driver-attributable footprint in bytes (caches, queues, symbol tables).
/// Polled every 30s by Core; on cache-budget breach, Core asks the driver to flush via
/// .
///
///
/// Per docs/v2/driver-stability.md §"In-process only (Tier A/B) — driver-instance
/// allocation tracking". Tier C drivers (process-isolated) report through the same
/// interface but the cache-flush is internal to their host.
///
long GetMemoryFootprint();
///
/// Drop optional caches (symbol cache, browse cache, etc.) to bring footprint back below budget.
/// Required-for-correctness state must NOT be flushed.
///
Task FlushOptionalCachesAsync(CancellationToken cancellationToken);
}