Skip to content

Commit 1fa7caa

Browse files
committed
Doc comments on sync lines
1 parent d0019a1 commit 1fa7caa

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

packages/powersync_core/lib/src/sync_types.dart

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'dart:convert';
22

3+
/// Messages sent from the sync service.
34
sealed class StreamingSyncLine {
45
const StreamingSyncLine();
56

@@ -23,6 +24,10 @@ sealed class StreamingSyncLine {
2324
}
2425
}
2526

27+
/// Indicates that a checkpoint is available, along with checksums for each
28+
/// bucket in the checkpoint.
29+
///
30+
/// Note: Called `StreamingSyncCheckpoint` in sync-service.
2631
final class Checkpoint extends StreamingSyncLine {
2732
final String lastOpId;
2833
final String? writeCheckpoint;
@@ -70,6 +75,11 @@ class BucketChecksum {
7075
lastOpId = json['last_op_id'];
7176
}
7277

78+
/// A variant of [Checkpoint] that may be sent when the server has already sent
79+
/// a [Checkpoint] message before.
80+
///
81+
/// It has the same conceptual meaning as a [Checkpoint] message, but only
82+
/// contains details about changed buckets as an optimization.
7383
final class StreamingSyncCheckpointDiff extends StreamingSyncLine {
7484
String lastOpId;
7585
List<BucketChecksum> updatedBuckets;
@@ -88,6 +98,11 @@ final class StreamingSyncCheckpointDiff extends StreamingSyncLine {
8898
removedBuckets = List<String>.from(json['removed_buckets']);
8999
}
90100

101+
/// Sent after the last [SyncBucketData] message for a checkpoint.
102+
///
103+
/// Since this indicates that we may have a consistent view of the data, the
104+
/// client may make previous [SyncBucketData] rows visible to the application
105+
/// at this point.
91106
final class StreamingSyncCheckpointComplete extends StreamingSyncLine {
92107
String lastOpId;
93108

@@ -97,6 +112,11 @@ final class StreamingSyncCheckpointComplete extends StreamingSyncLine {
97112
: lastOpId = json['last_op_id'];
98113
}
99114

115+
/// Sent as a periodic ping to keep the connection alive and to notify the
116+
/// client about the remaining lifetime of the JWT.
117+
///
118+
/// When the token is nearing its expiry date, the client may ask for another
119+
/// one and open a new sync session with that token.
100120
final class StreamingSyncKeepalive extends StreamingSyncLine {
101121
int tokenExpiresIn;
102122

0 commit comments

Comments
 (0)