pub struct OperationIdGenerator { /* private fields */ }Expand description
Generates deterministic operation IDs using blake2b hashing.
The ID is generated by hashing the parent ID (or execution ARN for root) combined with the step counter value. This ensures:
- Same inputs always produce the same ID
- Different step counts produce different IDs
- IDs are unique within an execution
Implementations§
Source§impl OperationIdGenerator
impl OperationIdGenerator
Sourcepub fn new(base_id: impl Into<String>) -> Self
pub fn new(base_id: impl Into<String>) -> Self
Creates a new OperationIdGenerator with the given base ID.
§Arguments
base_id- The base identifier to use for hashing (typically execution ARN or parent ID)
Sourcepub fn with_counter(base_id: impl Into<String>, initial_counter: u64) -> Self
pub fn with_counter(base_id: impl Into<String>, initial_counter: u64) -> Self
Creates a new OperationIdGenerator with a specific starting counter value.
§Arguments
base_id- The base identifier to use for hashinginitial_counter- The initial value for the step counter
Sourcepub fn next_id(&self) -> String
pub fn next_id(&self) -> String
Generates the next operation ID.
This method atomically increments the step counter and generates a deterministic ID based on the base ID and counter value.
§Returns
A unique, deterministic operation ID string.
§Memory Ordering
Uses Ordering::Relaxed because the step counter only needs to provide
unique values - there’s no synchronization requirement with other data.
Each call gets a unique counter value, and the hash function ensures
deterministic ID generation regardless of ordering between threads.
Requirements: 4.1, 4.6
Sourcepub fn id_for_counter(&self, counter: u64) -> String
pub fn id_for_counter(&self, counter: u64) -> String
Sourcepub fn current_counter(&self) -> u64
pub fn current_counter(&self) -> u64
Returns the current counter value without incrementing.
§Memory Ordering
Uses Ordering::Relaxed because this is an informational read that doesn’t
need to synchronize with other operations. The value may be slightly stale
in concurrent scenarios, but this is acceptable for debugging/monitoring use.
Requirements: 4.1, 4.6
Sourcepub fn create_child(&self, parent_operation_id: impl Into<String>) -> Self
pub fn create_child(&self, parent_operation_id: impl Into<String>) -> Self
Creates a child generator with a new base ID.
The child generator starts with counter 0 and uses the provided parent operation ID as its base.
§Arguments
parent_operation_id- The operation ID to use as the base for the child
Trait Implementations§
Source§impl Clone for OperationIdGenerator
impl Clone for OperationIdGenerator
Auto Trait Implementations§
impl !Freeze for OperationIdGenerator
impl RefUnwindSafe for OperationIdGenerator
impl Send for OperationIdGenerator
impl Sync for OperationIdGenerator
impl Unpin for OperationIdGenerator
impl UnsafeUnpin for OperationIdGenerator
impl UnwindSafe for OperationIdGenerator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more