Table of Contents

Interface IDbContextFactory

Namespace
FishMMO.Database.Npgsql
Assembly
FishMMO-DB.dll

Core factory interface for creating NpgsqlDbContext instances. Implementations must be thread-safe and create new contexts per call. DbContext instances are short-lived and should not be pooled.

public interface IDbContextFactory : IDisposable, IAsyncDisposable
Inherited Members

Remarks

This interface follows the Interface Segregation Principle by providing only the essential context creation functionality. For monitoring capabilities, see IDbContextFactoryMonitoring.

Methods

CreateDbContext()

Creates a new DbContext instance. Each call creates a fresh context - safe for concurrent use.

NpgsqlDbContext CreateDbContext()

Returns

NpgsqlDbContext

A new NpgsqlDbContext instance.

CreateDbContextAsync(CancellationToken)

Asynchronously creates a new DbContext instance. Each call creates a fresh context - safe for concurrent use.

Task<NpgsqlDbContext> CreateDbContextAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Cancellation token.

Returns

Task<NpgsqlDbContext>

A new NpgsqlDbContext instance.

Shutdown()

Shuts down the factory and rejects new DbContext creation. Unity-friendly synchronous shutdown (safe to call from main thread).

void Shutdown()

ShutdownAsync(CancellationToken)

Asynchronously shuts down the factory and rejects new DbContext creation.

Task ShutdownAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Cancellation token.

Returns

Task

A task representing the asynchronous shutdown operation.