@powersync/service-module-mongodb 0.15.1 → 0.15.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/replication/ChangeStream.d.ts +4 -12
  3. package/dist/replication/ChangeStream.js +378 -443
  4. package/dist/replication/ChangeStream.js.map +1 -1
  5. package/dist/replication/ChangeStreamReplicationJob.d.ts +1 -1
  6. package/dist/replication/ChangeStreamReplicationJob.js +1 -1
  7. package/dist/replication/ChangeStreamReplicationJob.js.map +1 -1
  8. package/dist/replication/ChangeStreamReplicator.d.ts +0 -1
  9. package/dist/replication/ChangeStreamReplicator.js +0 -21
  10. package/dist/replication/ChangeStreamReplicator.js.map +1 -1
  11. package/dist/replication/MongoSnapshotQuery.d.ts +2 -0
  12. package/dist/replication/MongoSnapshotQuery.js +4 -2
  13. package/dist/replication/MongoSnapshotQuery.js.map +1 -1
  14. package/dist/replication/internal-mongodb-utils.d.ts +21 -0
  15. package/dist/replication/internal-mongodb-utils.js +70 -0
  16. package/dist/replication/internal-mongodb-utils.js.map +1 -0
  17. package/dist/replication/replication-index.d.ts +1 -0
  18. package/dist/replication/replication-index.js +1 -0
  19. package/dist/replication/replication-index.js.map +1 -1
  20. package/package.json +8 -8
  21. package/src/replication/ChangeStream.ts +84 -31
  22. package/src/replication/ChangeStreamReplicationJob.ts +1 -1
  23. package/src/replication/ChangeStreamReplicator.ts +0 -21
  24. package/src/replication/MongoSnapshotQuery.ts +7 -3
  25. package/src/replication/internal-mongodb-utils.ts +91 -0
  26. package/src/replication/replication-index.ts +1 -0
  27. package/test/src/change_stream.test.ts +57 -1
  28. package/test/src/internal_mongodb_utils.test.ts +103 -0
  29. package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # @powersync/service-module-mongodb
2
2
 
3
+ ## 0.15.3
4
+
5
+ ### Patch Changes
6
+
7
+ - 11b4deb: Restructure `powersync_replication_lag_seconds` metric.
8
+ - Updated dependencies [df451c6]
9
+ - Updated dependencies [dea1e00]
10
+ - Updated dependencies [ada86f2]
11
+ - Updated dependencies [11b4deb]
12
+ - @powersync/service-core@1.20.4
13
+ - @powersync/service-sync-rules@0.34.1
14
+ - @powersync/lib-services-framework@0.9.2
15
+ - @powersync/lib-service-mongodb@0.6.23
16
+
17
+ ## 0.15.2
18
+
19
+ ### Patch Changes
20
+
21
+ - 9f30b26: [MongoDB] Fix replication batching/performance under high write checkpoint load.
22
+ - c546708: Track bytes replicated and transactions replicated for MongoDB.
23
+ - @powersync/service-core@1.20.3
24
+
3
25
  ## 0.15.1
4
26
 
5
27
  ### Patch Changes
@@ -1,7 +1,7 @@
1
1
  import { mongo } from '@powersync/lib-service-mongodb';
2
2
  import { DatabaseConnectionError, Logger } from '@powersync/lib-services-framework';
3
3
  import { MetricsEngine, SourceEntityDescriptor, SourceTable, storage } from '@powersync/service-core';
4
- import { DatabaseInputRow, SqliteInputRow, HydratedSyncRules, TablePattern } from '@powersync/service-sync-rules';
4
+ import { DatabaseInputRow, HydratedSyncRules, SqliteInputRow, TablePattern } from '@powersync/service-sync-rules';
5
5
  import { MongoManager } from './MongoManager.js';
6
6
  export interface ChangeStreamOptions {
7
7
  connections: MongoManager;
@@ -48,16 +48,7 @@ export declare class ChangeStream {
48
48
  private readonly maxAwaitTimeMS;
49
49
  private abort_signal;
50
50
  private relationCache;
51
- /**
52
- * Time of the oldest uncommitted change, according to the source db.
53
- * This is used to determine the replication lag.
54
- */
55
- private oldestUncommittedChange;
56
- /**
57
- * Keep track of whether we have done a commit or keepalive yet.
58
- * We can only compute replication lag if isStartingReplication == false, or oldestUncommittedChange is present.
59
- */
60
- private isStartingReplication;
51
+ private replicationLag;
61
52
  private checkpointStreamId;
62
53
  private logger;
63
54
  private snapshotChunkLength;
@@ -106,8 +97,9 @@ export declare class ChangeStream {
106
97
  initReplication(): Promise<void>;
107
98
  streamChanges(): Promise<void>;
108
99
  private openChangeStream;
100
+ private getBufferedChangeCount;
109
101
  streamChangesInternal(): Promise<void>;
110
- getReplicationLagMillis(): Promise<number | undefined>;
102
+ getReplicationLagMillis(): number | undefined;
111
103
  private lastTouchedAt;
112
104
  private touch;
113
105
  }