@@ -22,16 +22,12 @@ use restate_storage_api::vqueue_table::{
2222} ;
2323use restate_types:: clock:: UniqueTimestamp ;
2424use restate_types:: identifiers:: PartitionKey ;
25- use restate_types:: vqueue:: { EffectivePriority , VQueueId , VQueueInstance , VQueueParent } ;
25+ use restate_types:: vqueue:: { EffectivePriority , VQueueId } ;
2626
2727use crate :: PartitionStore ;
2828
2929fn test_qid ( ) -> VQueueId {
30- VQueueId :: new (
31- VQueueParent :: from_raw ( 1 ) ,
32- PartitionKey :: from ( 1000u64 ) ,
33- VQueueInstance :: from_raw ( 1 ) ,
34- )
30+ VQueueId :: custom ( PartitionKey :: from ( 1000u64 ) , "1" )
3531}
3632
3733fn entry_card ( id : u8 ) -> EntryCard {
@@ -120,11 +116,7 @@ fn verify_priority_ordering(db: &crate::PartitionDb) {
120116
121117/// Test: Within the same priority, items are ordered by visible_at then created_at.
122118async fn ordering_within_same_priority < W : WriteVQueueTable > ( txn : & mut W ) {
123- let qid = VQueueId :: new (
124- VQueueParent :: from_raw ( 1 ) ,
125- PartitionKey :: from ( 2000u64 ) ,
126- VQueueInstance :: from_raw ( 1 ) ,
127- ) ;
119+ let qid = VQueueId :: custom ( 2000 , "1" ) ;
128120
129121 // All entries have UserDefault priority, but different visible_at and created_at
130122 // visible_at ordering: Now (0) < At(ts)
@@ -155,11 +147,7 @@ async fn ordering_within_same_priority<W: WriteVQueueTable>(txn: &mut W) {
155147}
156148
157149fn verify_ordering_within_same_priority ( db : & crate :: PartitionDb ) {
158- let qid = VQueueId :: new (
159- VQueueParent :: from_raw ( 1 ) ,
160- PartitionKey :: from ( 2000u64 ) ,
161- VQueueInstance :: from_raw ( 1 ) ,
162- ) ;
150+ let qid = VQueueId :: custom ( 2000 , "1" ) ;
163151 let mut reader = db. new_inbox_reader ( & qid) ;
164152 let items = collect_cursor ( & mut reader) ;
165153
@@ -173,11 +161,7 @@ fn verify_ordering_within_same_priority(db: &crate::PartitionDb) {
173161
174162/// Test: Running and inbox stages are separate namespaces.
175163async fn running_and_inbox_are_separate < W : WriteVQueueTable > ( txn : & mut W ) {
176- let qid = VQueueId :: new (
177- VQueueParent :: from_raw ( 1 ) ,
178- PartitionKey :: from ( 3000u64 ) ,
179- VQueueInstance :: from_raw ( 1 ) ,
180- ) ;
164+ let qid = VQueueId :: custom ( 3000 , "1" ) ;
181165
182166 // Put one entry in Run stage
183167 let run_entry = entry_card ( 10 ) ;
@@ -191,11 +175,7 @@ async fn running_and_inbox_are_separate<W: WriteVQueueTable>(txn: &mut W) {
191175}
192176
193177fn verify_running_and_inbox_are_separate ( db : & crate :: PartitionDb ) {
194- let qid = VQueueId :: new (
195- VQueueParent :: from_raw ( 1 ) ,
196- PartitionKey :: from ( 3000u64 ) ,
197- VQueueInstance :: from_raw ( 1 ) ,
198- ) ;
178+ let qid = VQueueId :: custom ( 3000 , "1" ) ;
199179
200180 // Running reader should only see the Run stage entry
201181 let mut run_reader = db. new_run_reader ( & qid) ;
@@ -217,11 +197,7 @@ fn verify_running_and_inbox_are_separate(db: &crate::PartitionDb) {
217197
218198/// Test: seek_after positions cursor strictly after the given item.
219199async fn seek_after_works < W : WriteVQueueTable > ( txn : & mut W ) {
220- let qid = VQueueId :: new (
221- VQueueParent :: from_raw ( 1 ) ,
222- PartitionKey :: from ( 4000u64 ) ,
223- VQueueInstance :: from_raw ( 1 ) ,
224- ) ;
200+ let qid = VQueueId :: custom ( 4000 , "1" ) ;
225201
226202 // Insert entries in order
227203 let entries: Vec < _ > = ( 1 ..=5 ) . map ( entry_card) . collect ( ) ;
@@ -231,11 +207,7 @@ async fn seek_after_works<W: WriteVQueueTable>(txn: &mut W) {
231207}
232208
233209fn verify_seek_after_works ( db : & crate :: PartitionDb ) {
234- let qid = VQueueId :: new (
235- VQueueParent :: from_raw ( 1 ) ,
236- PartitionKey :: from ( 4000u64 ) ,
237- VQueueInstance :: from_raw ( 1 ) ,
238- ) ;
210+ let qid = VQueueId :: custom ( 4000 , "1" ) ;
239211
240212 let entries: Vec < _ > = ( 1 ..=5 ) . map ( entry_card) . collect ( ) ;
241213
@@ -255,11 +227,7 @@ fn verify_seek_after_works(db: &crate::PartitionDb) {
255227
256228/// Test: Empty queue returns None from peek.
257229fn verify_empty_queue_returns_none ( db : & crate :: PartitionDb ) {
258- let qid = VQueueId :: new (
259- VQueueParent :: from_raw ( 99 ) ,
260- PartitionKey :: from ( 9999u64 ) , // unused partition key
261- VQueueInstance :: from_raw ( 99 ) ,
262- ) ;
230+ let qid = VQueueId :: custom ( 9999 , "99" ) ;
263231
264232 let mut run_reader = db. new_run_reader ( & qid) ;
265233 run_reader. seek_to_first ( ) ;
@@ -279,18 +247,9 @@ fn verify_empty_queue_returns_none(db: &crate::PartitionDb) {
279247/// Test: Different vqueues (different parent/instance) are isolated.
280248async fn vqueue_isolation < W : WriteVQueueTable > ( txn : & mut W ) {
281249 let pkey = PartitionKey :: from ( 5000u64 ) ;
282-
283- let qid1 = VQueueId :: new ( VQueueParent :: from_raw ( 1 ) , pkey, VQueueInstance :: from_raw ( 1 ) ) ;
284- let qid2 = VQueueId :: new (
285- VQueueParent :: from_raw ( 1 ) ,
286- pkey,
287- VQueueInstance :: from_raw ( 2 ) , // different instance
288- ) ;
289- let qid3 = VQueueId :: new (
290- VQueueParent :: from_raw ( 2 ) , // different parent
291- pkey,
292- VQueueInstance :: from_raw ( 1 ) ,
293- ) ;
250+ let qid1 = VQueueId :: custom ( pkey, "1" ) ;
251+ let qid2 = VQueueId :: custom ( pkey, "2" ) ;
252+ let qid3 = VQueueId :: custom ( pkey, "3" ) ;
294253
295254 txn. put_inbox_entry ( & qid1, Stage :: Inbox , & entry_card ( 1 ) ) ;
296255 txn. put_inbox_entry ( & qid2, Stage :: Inbox , & entry_card ( 2 ) ) ;
@@ -300,9 +259,9 @@ async fn vqueue_isolation<W: WriteVQueueTable>(txn: &mut W) {
300259fn verify_vqueue_isolation ( db : & crate :: PartitionDb ) {
301260 let pkey = PartitionKey :: from ( 5000u64 ) ;
302261
303- let qid1 = VQueueId :: new ( VQueueParent :: from_raw ( 1 ) , pkey, VQueueInstance :: from_raw ( 1 ) ) ;
304- let qid2 = VQueueId :: new ( VQueueParent :: from_raw ( 1 ) , pkey, VQueueInstance :: from_raw ( 2 ) ) ;
305- let qid3 = VQueueId :: new ( VQueueParent :: from_raw ( 2 ) , pkey, VQueueInstance :: from_raw ( 1 ) ) ;
262+ let qid1 = VQueueId :: custom ( pkey, "1" ) ;
263+ let qid2 = VQueueId :: custom ( pkey, "2" ) ;
264+ let qid3 = VQueueId :: custom ( pkey, "3" ) ;
306265
307266 // Each queue should only see its own entry
308267 let mut reader1 = db. new_inbox_reader ( & qid1) ;
@@ -326,11 +285,7 @@ fn verify_vqueue_isolation(db: &crate::PartitionDb) {
326285/// This verifies that the inbox reader (which uses a tailing iterator) can see
327286/// items that were added after the reader was created, when re-seeking.
328287async fn tailing_iterator_sees_new_items_on_reseek ( rocksdb : & mut PartitionStore ) {
329- let qid = VQueueId :: new (
330- VQueueParent :: from_raw ( 1 ) ,
331- PartitionKey :: from ( 6000u64 ) ,
332- VQueueInstance :: from_raw ( 1 ) ,
333- ) ;
288+ let qid = VQueueId :: custom ( 6000 , "1" ) ;
334289
335290 // Insert initial entries
336291 let entry1 = entry_card ( 1 ) ;
@@ -388,11 +343,7 @@ async fn tailing_iterator_sees_new_items_on_reseek(rocksdb: &mut PartitionStore)
388343/// This verifies that when using seek_after to resume iteration, newly added
389344/// items that sort after the seek position are visible.
390345async fn tailing_iterator_sees_new_items_on_seek_after ( rocksdb : & mut PartitionStore ) {
391- let qid = VQueueId :: new (
392- VQueueParent :: from_raw ( 1 ) ,
393- PartitionKey :: from ( 7000u64 ) ,
394- VQueueInstance :: from_raw ( 1 ) ,
395- ) ;
346+ let qid = VQueueId :: custom ( 7000 , "1" ) ;
396347
397348 // Insert initial entries with different priorities
398349 let entry_high = entry_card_with_priority ( 1 , EffectivePriority :: System ) ;
@@ -440,11 +391,7 @@ async fn tailing_iterator_sees_new_items_on_seek_after(rocksdb: &mut PartitionSt
440391/// This verifies that when an item is deleted while the reader is open,
441392/// re-seeking will not return the deleted item.
442393async fn deleted_items_not_visible_after_reseek ( rocksdb : & mut PartitionStore ) {
443- let qid = VQueueId :: new (
444- VQueueParent :: from_raw ( 1 ) ,
445- PartitionKey :: from ( 8000u64 ) ,
446- VQueueInstance :: from_raw ( 1 ) ,
447- ) ;
394+ let qid = VQueueId :: custom ( 8000 , "1" ) ;
448395
449396 // Insert initial entries
450397 let entry1 = entry_card ( 1 ) ;
@@ -492,11 +439,7 @@ async fn deleted_items_not_visible_after_reseek(rocksdb: &mut PartitionStore) {
492439/// This verifies that deleted items are not returned when using seek_after
493440/// to resume iteration past a certain point.
494441async fn deleted_items_not_visible_after_seek_after ( rocksdb : & mut PartitionStore ) {
495- let qid = VQueueId :: new (
496- VQueueParent :: from_raw ( 1 ) ,
497- PartitionKey :: from ( 8500u64 ) ,
498- VQueueInstance :: from_raw ( 1 ) ,
499- ) ;
442+ let qid = VQueueId :: custom ( 8500 , "1" ) ;
500443
501444 // Insert entries
502445 let entry1 = entry_card ( 1 ) ;
@@ -540,11 +483,7 @@ async fn deleted_items_not_visible_after_seek_after(rocksdb: &mut PartitionStore
540483/// This tests a more complex scenario where items are both added and removed
541484/// while the reader is open.
542485async fn concurrent_enqueue_and_delete ( rocksdb : & mut PartitionStore ) {
543- let qid = VQueueId :: new (
544- VQueueParent :: from_raw ( 1 ) ,
545- PartitionKey :: from ( 9000u64 ) ,
546- VQueueInstance :: from_raw ( 1 ) ,
547- ) ;
486+ let qid = VQueueId :: custom ( 9000 , "1" ) ;
548487
549488 // Insert initial entries with different priorities
550489 let entry_high = entry_card_with_priority ( 10 , EffectivePriority :: System ) ;
0 commit comments