Table of Contents

Interface IDatabase

Namespace
FishMMO.Database
Assembly
FishMMO-DB.dll

Defines the contract for the database orchestrator and facade. Provides centralized access to database services, health monitoring, and metrics. Abstracts the underlying database implementation for testability and flexibility.

public interface IDatabase

Remarks

This interface follows the Facade Pattern and enables:

  • Easy mocking/stubbing for unit tests
  • Swapping implementations (e.g., in-memory for testing)
  • Dependency injection in Unity or server frameworks
  • Decoupling client code from concrete database implementations

Properties

DbContextFactory

Gets the database context factory. Exposed for direct access when needed (e.g., custom queries, migrations, raw SQL). In most cases, prefer using services from ServiceRegistry.

INpgsqlDbContextFactory DbContextFactory { get; }

Property Value

INpgsqlDbContextFactory

HealthMonitor

Gets the database health monitor for connectivity and performance checks. Use this to verify database availability and response times.

DatabaseHealthMonitor HealthMonitor { get; }

Property Value

DatabaseHealthMonitor

MetricsTracker

Gets the database metrics tracker for operation statistics. Provides insights into query performance and connection pool usage.

DatabaseMetricsTracker MetricsTracker { get; }

Property Value

DatabaseMetricsTracker

ServiceRegistry

Gets the service registry for accessing database services. Provides type-safe access to all registered database service interfaces.

IDatabaseServiceRegistry ServiceRegistry { get; }

Property Value

IDatabaseServiceRegistry

Methods

Shutdown()

Shuts down the database orchestrator. Unity-friendly synchronous shutdown (safe to call from main thread). After shutdown, new DbContext creation should be rejected.

void Shutdown()

ShutdownAsync(CancellationToken)

Asynchronously shuts down the database orchestrator. After shutdown, new DbContext creation should be rejected.

Task ShutdownAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Returns

Task