@@ -17,14 +17,15 @@ pub struct Read {
17
17
/// Most-recent journal write head observed by this Read.
18
18
pub ( crate ) last_write_head : i64 ,
19
19
20
- key_ptr : Vec < doc:: Pointer > , // Pointers to the document key.
21
- key_schema : avro:: Schema , // Avro schema when encoding keys.
22
- key_schema_id : u32 , // Registry ID of the key's schema.
23
- meta_op_ptr : doc:: Pointer , // Location of document op (currently always `/_meta/op`).
24
- not_before : uuid:: Clock , // Not before this clock.
25
- stream : ReadJsonLines , // Underlying document stream.
26
- uuid_ptr : doc:: Pointer , // Location of document UUID.
27
- value_schema_id : u32 , // Registry ID of the value's schema.
20
+ key_ptr : Vec < doc:: Pointer > , // Pointers to the document key.
21
+ key_schema : avro:: Schema , // Avro schema when encoding keys.
22
+ key_schema_id : u32 , // Registry ID of the key's schema.
23
+ meta_op_ptr : doc:: Pointer , // Location of document op (currently always `/_meta/op`).
24
+ not_before : Option < uuid:: Clock > , // Not before this clock.
25
+ not_after : Option < uuid:: Clock > , // Not after this clock.
26
+ stream : ReadJsonLines , // Underlying document stream.
27
+ uuid_ptr : doc:: Pointer , // Location of document UUID.
28
+ value_schema_id : u32 , // Registry ID of the value's schema.
28
29
extractors : Vec < ( avro:: Schema , utils:: CustomizableExtractor ) > , // Projections to apply
29
30
30
31
// Keep these details around so we can create a new ReadRequest if we need to skip forward
@@ -69,7 +70,10 @@ impl Read {
69
70
rewrite_offsets_from : Option < i64 > ,
70
71
auth : & SessionAuthentication ,
71
72
) -> anyhow:: Result < Self > {
72
- let ( not_before_sec, _) = collection. not_before . to_unix ( ) ;
73
+ let ( not_before_sec, _) = collection
74
+ . not_before
75
+ . map ( |not_before| not_before. to_unix ( ) )
76
+ . unwrap_or ( ( 0 , 0 ) ) ;
73
77
74
78
let stream = client. clone ( ) . read_json_lines (
75
79
broker:: ReadRequest {
@@ -94,6 +98,7 @@ impl Read {
94
98
key_schema_id,
95
99
meta_op_ptr : doc:: Pointer :: from_str ( "/_meta/op" ) ,
96
100
not_before : collection. not_before ,
101
+ not_after : collection. not_after ,
97
102
stream,
98
103
uuid_ptr : collection. uuid_ptr . clone ( ) ,
99
104
value_schema_id,
@@ -217,13 +222,23 @@ impl Read {
217
222
} ;
218
223
let ( producer, clock, flags) = gazette:: uuid:: parse_str ( uuid. as_str ( ) ) ?;
219
224
220
- if clock < self . not_before {
225
+ // Is this a non-content control document, such as a transaction ACK?
226
+ let is_control = flags. is_ack ( ) ;
227
+
228
+ let should_skip = match ( self . not_before , self . not_after ) {
229
+ ( Some ( not_before) , Some ( not_after) ) => clock < not_before || clock > not_after,
230
+ ( Some ( not_before) , None ) => clock < not_before,
231
+ ( None , Some ( not_after) ) => clock > not_after,
232
+ ( None , None ) => false ,
233
+ } ;
234
+
235
+ // Only filter non-ack documents to allow the consumer to make and
236
+ // record progress scanning through the offset range.
237
+ if !is_control && should_skip {
221
238
continue ;
222
239
}
223
240
last_source_published_at = Some ( clock) ;
224
241
225
- // Is this a non-content control document, such as a transaction ACK?
226
- let is_control = flags. is_ack ( ) ;
227
242
// Is this a deletion?
228
243
let is_deletion = matches ! (
229
244
self . meta_op_ptr. query( root. get( ) ) ,
0 commit comments