Skip to content

Commit

Permalink
Support UUID version 7 directly
Browse files Browse the repository at this point in the history
  • Loading branch information
tt committed Oct 12, 2024
1 parent b931d6c commit e5466f4
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ tokio = { version = "1.6", optional = true }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
# Uuid generation
uuid = { version = "1.1", features = ["serde", "v4"] }
uuid = { version = "1.6", features = ["serde", "v4", "v7"] }
# Time esrs-core
chrono = { version = "0.4", features = ["serde"] }
# Build async trait
Expand Down
2 changes: 2 additions & 0 deletions src/store/postgres/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ use super::{PgStore, Schema};
/// The `UuidFormat` enum defines the UUID format preference:
///
/// - `V4`: Uses the random UUID version 4 as defined by RFC 9562 section 5.4.
/// - `V7`: Uses the time-ordered UUID version 7 as defined by RFC 9562 section 5.7.
pub enum UuidFormat {
V4,
V7,
}

/// Struct used to build a brand new [`PgStore`].
Expand Down
1 change: 1 addition & 0 deletions src/store/postgres/event_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ where
) -> Result<StoreEvent<A::Event>, PgStoreError> {
let id: Uuid = match self.inner.event_id_format {
UuidFormat::V4 => Uuid::new_v4(),
UuidFormat::V7 => Uuid::now_v7(),
};

#[cfg(feature = "upcasting")]
Expand Down

0 comments on commit e5466f4

Please sign in to comment.