DVCapture class

The capture log for one database.

Stored through the record operations every engine implements (DVRecordAdapter), never through SQL, so the log lives wherever the application's data does: a SQL table, or a document database's collection.

Constructors

DVCapture({required DVDatabaseAdapter database, required Duration retention, DateTime clock()?, Duration lease = const Duration(seconds: 30), Duration strandedAfter = const Duration(minutes: 5)})

Properties

consumers → Map<String, DVCaptureConsumer>
The consumers registered here, by name.
no setter
database → DVDatabaseAdapter
final
hashCode → int
The hash code for this object.
no setterinherited
lease → Duration
How long a publisher may hold a range of sequences before another process treats it as dead and moves past it.
final
onPublished ↔ void Function(int published)?
Called after changes are published, with how many. The framework's delivery runtime uses it to send them on without waiting for its next tick; a failure in it never reaches the write that published.
getter/setter pair
retention → Duration
How long a published change is kept. Bounded and declared: a consumer further behind than this is told to backfill (DV-CDC-002).
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
strandedAfter → Duration
How old a staged change must be before publishStranded treats the transaction that staged it as gone.
final
tracked → Map<String, DVRecordTable>
The captured tables this log knows, by name.
no setter

Methods

changes({int after = 0, int? limit}) → Future<List<DVCapturedChange>>
Published record changes after after, oldest first. Schema changes are not included; changes an erasure purged are.
consumer(String name, {required DVCaptureSink sink, String? tenant, Set<String>? models, int batchSize = 500, Duration? lagThreshold}) → DVCaptureConsumer
A consumer: one destination's position in the log.
dispatchBackfill(DVCaptureBackfillJob job, {DVQueues queues = const DVQueues()}) → Future<DVJobEnvelope<DVCaptureBackfillJob>>
dispatchDelivery(String consumer, {DVQueues queues = const DVQueues(), String queue = 'default'}) → Future<DVJobEnvelope<DVCaptureDeliveryJob>>
ensureSchema() → Future<void>
eraseRecord(DVRecordTable table, Object key) → Future<DVCapturedChange>
Removes every value the log holds for one record, and captures what an erasure left of it: a delete when it is gone, or its anonymized values when a retention kept it. Returns that change, published.
The newest published sequence.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
prune() → Future<int>
Removes published changes older than retention, returning how many.
publishStranded() → Future<int>
Publishes changes a crash left staged: written, never given a sequence.
record({required DVRecordTable table, required DVCaptureOp operation, required Object key, required int version, required Map<String, Object?> values, String? tenant, bool erased = false}) → Future<String>
Captures one write. Called by DVRecordTable after the row is written.
recordErasure(DVRecordTable table, Object key, {int? version}) → Future<String>
Purges every value the log holds for one record and captures what a removal left of it, returning the change id: published at once, or staged and published after commit inside DV.transaction.
registerJobs(DVQueues queues) → void
Registers delivery and backfill on the durable job layer, with the codecs a queue shared between processes stores them under. A refused batch throws, so the queue retries it with its backoff.
toString() → String
A string representation of this object.
inherited
track(DVRecordTable table) → void
Makes table known to backfill jobs. DVRecordTable calls it, and so does the framework for every captured model it starts with.

Operators

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

Static Properties

configured → DVCapture?
The log a model declared @DVModel(capture: true) writes to.
no setter

Static Methods

configure(DVCapture log) → void
Records every captured model in this process to log.
unconfigure() → void
Forgets the configured log. A captured model then records to a log in the configured database, as a process the server did not start does.

Constants

backfillTable → const String
checkpointTable → const String
defaultRetention → const Duration
How long a published change is kept when nothing declared a retention.
logTable → const String
schemaTable → const String
stateTable → const String