Skip to content

Commit 39454c8

Browse files
authored
RUST-1290 Add the wall_time field to change stream events. (#658)
1 parent 194b44b commit 39454c8

File tree

3 files changed

+67
-1
lines changed

3 files changed

+67
-1
lines changed

src/change_stream/event.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::{cursor::CursorSpecification, options::ChangeStreamOptions};
66

77
#[cfg(test)]
88
use bson::Bson;
9-
use bson::{Document, RawBson, RawDocumentBuf, Timestamp};
9+
use bson::{DateTime, Document, RawBson, RawDocumentBuf, Timestamp};
1010
use serde::{Deserialize, Serialize};
1111

1212
/// An opaque token used for resuming an interrupted
@@ -87,6 +87,9 @@ pub struct ChangeStreamEvent<T> {
8787
/// The cluster time at which the change occurred.
8888
pub cluster_time: Option<Timestamp>,
8989

90+
/// The wall time from the mongod that the change event originated from.
91+
pub wall_time: Option<DateTime>,
92+
9093
/// The `Document` created or modified by the `insert`, `replace`, `delete`, `update`
9194
/// operations (i.e. CRUD operations).
9295
///

src/test/spec/json/change-streams/unified/change-streams.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1428,6 +1428,48 @@
14281428
]
14291429
}
14301430
]
1431+
},
1432+
{
1433+
"description": "Test wallTime field is set in a change event",
1434+
"runOnRequirements": [
1435+
{
1436+
"minServerVersion": "6.0.0"
1437+
}
1438+
],
1439+
"operations": [
1440+
{
1441+
"name": "createChangeStream",
1442+
"object": "collection0",
1443+
"arguments": {
1444+
"pipeline": []
1445+
},
1446+
"saveResultAsEntity": "changeStream0"
1447+
},
1448+
{
1449+
"name": "insertOne",
1450+
"object": "collection0",
1451+
"arguments": {
1452+
"document": {
1453+
"_id": 1,
1454+
"a": 1
1455+
}
1456+
}
1457+
},
1458+
{
1459+
"name": "iterateUntilDocumentOrError",
1460+
"object": "changeStream0",
1461+
"expectResult": {
1462+
"operationType": "insert",
1463+
"ns": {
1464+
"db": "database0",
1465+
"coll": "collection0"
1466+
},
1467+
"wallTime": {
1468+
"$$exists": true
1469+
}
1470+
}
1471+
}
1472+
]
14311473
}
14321474
]
14331475
}

src/test/spec/json/change-streams/unified/change-streams.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,3 +737,24 @@ tests:
737737
pipeline: [ { $changeStream: {} } ]
738738
commandName: aggregate
739739
databaseName: *database0
740+
741+
- description: "Test wallTime field is set in a change event"
742+
runOnRequirements:
743+
- minServerVersion: "6.0.0"
744+
operations:
745+
- name: createChangeStream
746+
object: *collection0
747+
arguments: { pipeline: [] }
748+
saveResultAsEntity: &changeStream0 changeStream0
749+
- name: insertOne
750+
object: *collection0
751+
arguments:
752+
document: { "_id": 1, "a": 1 }
753+
- name: iterateUntilDocumentOrError
754+
object: *changeStream0
755+
expectResult:
756+
operationType: "insert"
757+
ns:
758+
db: *database0
759+
coll: *collection0
760+
wallTime: { $$exists: true }

0 commit comments

Comments
 (0)