Support for partitioned identifiers + state mutation request id - #4569
Conversation
tillrohrmann
left a comment
There was a problem hiding this comment.
Thanks for creating support for partitioned resource ids @AhmedSoliman. The changes look really great. +1 for merging :-)
| // read pkey as u64 (big-endian) | ||
| let partition_key = u64::from_be_bytes(b[..size_of::<$crate::PartitionKey>()].try_into().unwrap()); |
There was a problem hiding this comment.
big-endian to make the partitioned resource id have the same byte sort order as the deserialized id?
There was a problem hiding this comment.
primarily to maintain compatibility with other ulid-based resource types that use u128 in big-endian as well.
| let encoded = id.to_string(); | ||
| assert!(encoded.starts_with("tst_1")); | ||
| assert_eq!(encoded.len(), 38); | ||
| println!("{encoded}"); |
There was a problem hiding this comment.
Is this for visual checks?
| ulid_backed_id!(PartitionProcessorRpcRequest); | ||
| ulid_backed_id!(Snapshot @with_resource_id); | ||
|
|
||
| partitioned::partitioned_resource_id!( |
There was a problem hiding this comment.
Could we theoretically replace the manual ResourceId implementation for the InvocationId with that here?
There was a problem hiding this comment.
Yes, but we'll need to do one extra level of indirection (a type to wrap the remainder bytes).
…amps This timestamp type is intended to be used for invocation scheduling and the `RunAt` field of vqueues. While it's internally represented as 4-byte integer, it'll be serialized as u63 (yes, missing one bit) in EntryKey. This is done to allow future expansion of the granularity if needed. The granularity is chosen to be second-level to (a) reflect the realistic expecations of invocation scheduling and (b) to allow invocations in queues to be reordered dynamically withing a single-second window based on their sequence ordering. Some helpers in this type are not used (floor_to_minute, smear_to_minute) but are kept for future use if we need to use this type for coarse jittering or if we need to expand the window-bucketing further.
Added the missing support for borrowed decoding for this type.
Stack created with Sapling. Best reviewed with ReviewStack.