-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Try to exploit Change Streams instead of observe
/observeChanges
#999
Comments
This is progress on #999.
One problem with point 3. is that For ordered callbacks (
This is implemented by Meteor's For unordered callbacks ( This is implemented by Meteor's |
Note that Meteor's current implementation also fails to implement all possible queries supported by |
Note also that Meteor's oplog observe driver becomes quite complicated once Unless |
This is progress on #999.
This is progress on #999.
This is progress on #999.
If resorting to pure change stream updates instead of polling, the following const handleChangeStreamEvents = <TSchema extends { _id: string, [key: string]: any }>(
self: Subscription,
collectionName: string,
doc: ChangeStreamDocument<TSchema>
) => {
switch (doc.operationType) {
case "replace":
if (doc.fullDocument) {
self.changed(collectionName, doc.documentKey._id, doc.fullDocument);
}
break;
case "insert":
if (doc.fullDocument) {
self.added(collectionName, doc.documentKey._id, doc.fullDocument);
}
break;
case "delete":
self.removed(collectionName, doc.documentKey._id);
break;
case "update":
const {removedFields, updatedFields} = doc.updateDescription;
const fields = Object.fromEntries([
...(removedFields?.map((key: keyof TSchema) => [key, undefined] as const) ?? []),
...Object.entries(updatedFields ?? {}),
]) as Partial<TSchema>;
self.changed(collectionName, doc.documentKey._id, fields);
break;
case "drop":
case "dropDatabase":
case "rename":
case "invalidate":
self.stop();
break;
default:
break;
}
}; See also: https://forums.meteor.com/t/pub-sub-with-mongodb-change-stream/57495. |
This is progress on #999.
This is progress on #999.
This is progress on #999.
This is progress on #999.
This is progress on #999.
This is progress on #999.
This is progress on #999.
This is progress on #999.
This is progress on #999.
This is progress on #999.
This is progress on #999.
This is progress on #999.
This is progress on #999.
This is progress on #999.
observeChangesAsync
can have extreme lag when combined with raw collection operations (e.g. transactions). We should try to exploit Change Streams instead. Might also help with migrating away from Meteor.See:
The text was updated successfully, but these errors were encountered: