BatchedRemoteTranslationsService class
Service for batch translations with smart batching.
This service automatically batches translation requests to reduce network overhead. It uses debouncing to collect requests within a time window and sends them as a single batch to the API.
The batching is fully transparent to the caller.
Features:
- Debounced batching (configurable, default 100ms)
- Maximum batch size limit (configurable, default 100)
- Deduplication of identical requests
- Per-locale batching (separate batches per target language)
- Automatic fallback to individual requests if batching is disabled
Constructors
- BatchedRemoteTranslationsService(BatchedRemoteTranslationsRepository _repository, {BatchTranslationConfig? config})
- Creates a new BatchedRemoteTranslationsService.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
dispose(
) → void - Disposes the service and cancels any pending timers.
-
flush(
) → Future< void> - Forces an immediate flush of all pending translations.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
translate(
String originalText, SolvroLocale from, SolvroLocale to) → Future< RemoteTranslationResponse> -
Translates the given
textfrom one language to another.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited