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:

Constructors

ServiceLocator()
Gets the singleton instance of ServiceLocator.
factory

Properties

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
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
recommendedConnectionOptions ConnectionOptions
Connection options aligned with resolvedUsageProfile.
no setter
recommendedPoolMaxSize int
Suggested native pool maxSize for resolvedUsageProfile.
no setter
recommendedPoolOptions PoolOptions
Pool eviction / acquire timeouts aligned with resolvedUsageProfile.
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 OdbcService
Gets the appropriate service based on initialization mode.
no setter
syncService OdbcService
Gets the sync OdbcService instance.
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}) → void
Initializes all services and dependencies.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
shutdown() → void
Releases async resources (worker isolate). Call on app exit when using async mode. Safe to call multiple times; subsequent initialize calls dispose any previous async worker automatically.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited