ServiceLocator class
Dependency injection container for ODBC Fast services.
Provides a singleton instance that manages the lifecycle of core services including the native ODBC connection, repository, and service layers.
Usage profiles
initialize defaults to OdbcUsageProfile.legacy to preserve the historical sync-only behavior. Use OdbcUsageProfile.balanced, OdbcUsageProfile.balancedFlutter, OdbcUsageProfile.balancedServer, or OdbcUsageProfile.highThroughput to opt in to async presets with bounded backpressure and recommended connection / pool options. Inspect resolvedUsageProfile to see the effective configuration after applying explicit overrides.
Example (default sync / legacy)
final locator = ServiceLocator()..initialize();
final service = locator.service;
await service.initialize();
final conn = await service.connect(
dsn,
options: locator.recommendedConnectionOptions,
);
Example (balanced async profile)
final locator = ServiceLocator()
..initialize(profile: OdbcUsageProfile.balanced);
final service = locator.service;
await service.initialize();
See also:
- AsyncNativeOdbcConnection for non-blocking database operations
- NativeOdbcConnection for synchronous operations
Constructors
- ServiceLocator()
-
Gets the singleton instance of ServiceLocator.
factory
Properties
- adminRepository → IAdminRepository
-
no setter
- adminService → IAdminService
-
no setter
- asyncAuditLogger → AsyncOdbcAuditLogger
-
Gets async typed audit logger wrapper.
no setter
- asyncNativeConnection → AsyncNativeOdbcConnection
-
Gets the AsyncNativeOdbcConnection instance.
no setter
- asyncService → OdbcService
-
Gets the async OdbcService instance.
no setter
- auditLogger → OdbcAuditLogger
-
Gets the typed native audit logger wrapper.
no setter
- connectionRepository → IConnectionRepository
-
Narrow repository views for capability-focused dependency injection.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- isAsyncMode → bool
-
Whether the locator was initialized with async mode.
no setter
- nativeConnection → NativeOdbcConnection
-
Gets the NativeOdbcConnection instance.
no setter
- poolRepository → IPoolRepository
-
no setter
- poolService → IPoolService
-
no setter
- queryRepository → IQueryRepository
-
no setter
- queryService → IQueryService
-
Narrow service views matching IQueryService, ITransactionService,
IPoolService, and IAdminService. When telemetry is enabled, these
route through the capability decorators so narrow consumers stay
instrumented without depending on the full aggregate.
no setter
- recommendedConnectionOptions → ConnectionOptions
-
Connection options aligned with resolvedUsageProfile.
no setter
- recommendedPoolMaxSize → int
-
Suggested native pool
maxSizefor resolvedUsageProfile.no setter - recommendedPoolOptions → PoolOptions
-
Pool eviction / acquire timeouts aligned with resolvedUsageProfile.
no setter
- recommendedResultEncoding → ResultEncoding
-
Suggested ResultEncoding for analytics SELECT workloads on
resolvedUsageProfile. Server presets (
balancedServer,highThroughput) apply this as the repository default forexecuteQueryParamValuesunless callers passresultEncodingexplicitly.no setter - repository → IOdbcRepository
-
Gets the appropriate repository based on initialization mode.
no setter
- resolvedUsageProfile → ResolvedOdbcUsageProfile
-
Effective configuration after applying initialize overrides.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- service → IOdbcService
-
Gets the appropriate service based on initialization mode.
no setter
- syncService → OdbcService
-
Gets the sync OdbcService instance.
no setter
- telemetry → SimpleTelemetryService?
-
Optional telemetry sink wired when initialize receives telemetry.
no setter
- transactionRepository → ITransactionRepository
-
no setter
- transactionService → ITransactionService
-
no setter
- usageProfile → OdbcUsageProfile
-
Preset selected in the last initialize call.
no setter
Methods
-
initialize(
{OdbcUsageProfile profile = OdbcUsageProfile.legacy, bool? useAsync, int? asyncWorkerCount, int? asyncMaxPendingRequests, AsyncBackpressureMode? asyncBackpressureMode, Duration? asyncBackpressureTimeout, SimpleTelemetryService? telemetry}) → void - Initializes all services and dependencies.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
shutdown(
) → void - Releases all native resources and worker isolates. Call on app exit.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited