1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
use async_trait;
use ;
use crate::;
use Change;
/// A pluggable change-capture mechanism — logical replication (WAL) today,
/// polling or trigger-based capture later.
///
/// The mechanism exposes two independent capabilities; the engine decides when
/// to use each:
///
/// - [`live`](Self::live) streams ongoing changes, resuming from the
/// mechanism's own durable position (a replication slot's
/// `confirmed_flush_lsn`, a poll cursor, …). No position is threaded through
/// this API — resume state is the mechanism's to own.
/// - [`snapshot`](Self::snapshot) reads the *current* rows of a set of tables as
/// a finite stream — the data an initial backfill needs. Whether a backfill
/// is *needed* is not the mechanism's call: the engine asks the **sink**
/// whether a target is already seeded and only then requests a snapshot. A
/// mechanism that cannot snapshot keeps the default (an empty stream).
///
/// Each emitted [`Change`] carries an [`Ack`](super::Ack); for `live`, the
/// mechanism only advances its durable resume point once changes are confirmed,
/// which makes delivery at-least-once across restarts. Snapshot changes are not
/// resumable (a crashed backfill simply re-runs, idempotently), so their acks
/// need not move any cursor.
///
/// Returned streams are `'static` and `Send`: an implementation moves whatever
/// it needs (its connection, its [`AckSink`](super::AckSink)) into the stream
/// rather than borrowing from `self`.