AsyncPublisherWithBufferAndParam<Param extends Object?, Log extends CustomLog> class
final
An asynchronous publisher that batches log events along with their associated parameters.
Combines the capabilities of AsyncPublisherWithBuffer and
AsyncPublisherWithParam, processing batches of logs where each log event
is paired with an auxiliary parameter for context.
Example usage:
final asyncPublisher = AsyncPublisherWithBufferAndParam<String, Log>((entries, retryBuffer) async {
try {
await db.insertBatch(entries); // entries are a list of (String collectionName, Log log)
} catch (e) {
retryBuffer.addAll(entries); // Retry them next time
}
});
log.publisher = asyncPublisher.withParam(collectionName);
- Inheritance
-
- Object
- AsyncPublisherWithBufferAndParamBase<
Param, Log> - AsyncPublisherWithBufferAndParam
Constructors
-
AsyncPublisherWithBufferAndParam(FutureOr<
void> handler(List<(Param, Log)> entries, List<(Param, Log)> retryBuffer), {bool sync = false, void onError(Object error, StackTrace stackTrace)?}) -
Creates a publisher backed by
handler.
Properties
-
handler
→ FutureOr<
void> Function(List<(Param, Log)> entries, List<(Param, Log)> retryBuffer) -
The function that processes a batch of buffered parameter-log entries.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- isClosed → bool
-
Whether close has been called.
no setterinherited
- onError → void Function(Object error, StackTrace stackTrace)?
-
Called when handle throws.
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- sync → bool
-
Whether the underlying stream controller delivers events synchronously.
finalinherited
Methods
-
close(
) → Future< void> -
Closes the publisher after draining the queue: every log accepted
before closing is processed, including logs published while a batch
was in flight. Entries returned to the retry buffer after closing are
dropped.
inherited
-
flush(
) → Future< void> -
Completes when the queue has been fully drained.
inherited
-
handle(
List< (Param, Log)> entries, List<(Param, Log)> retryBuffer) → FutureOr<void> -
Processes a batch of buffered parameter-log
entries.override -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
withParam(
Param param) → CustomLogPublisher< Log> -
Returns a CustomLogPublisher that publishes into this shared buffer
with the given
paramattached to every log event.inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited