pub struct RecordMetadata<'a> {
record: &'a Record,
shard_id: String,
attempt_number: u32,
}
Expand description
Metadata associated with a Kinesis record during processing
This struct provides access to record metadata through reference-based accessors, avoiding unnecessary data copying while maintaining access to processing context such as shard ID and attempt count.
§Examples
use go_zoom_kinesis::processor::RecordMetadata;
use aws_sdk_kinesis::types::Record;
fn process_with_metadata(metadata: &RecordMetadata) {
println!("Processing record {} from shard {}",
metadata.sequence_number(),
metadata.shard_id()
);
if metadata.attempt_number() > 1 {
println!("Retry attempt {}", metadata.attempt_number());
}
if let Some(timestamp) = metadata.approximate_arrival_timestamp() {
println!("Record arrived at: {}", timestamp);
}
}
Fields§
§record: &'a Record
Reference to the underlying Kinesis record
shard_id: String
ID of the shard this record came from
attempt_number: u32
Number of processing attempts for this record (starts at 1)
Implementations§
source§impl<'a> RecordMetadata<'a>
impl<'a> RecordMetadata<'a>
sourcepub fn new(record: &'a Record, shard_id: String, attempt_number: u32) -> Self
pub fn new(record: &'a Record, shard_id: String, attempt_number: u32) -> Self
Creates a new metadata instance for a record
§Arguments
record
- Reference to the Kinesis recordshard_id
- ID of the shard this record came fromattempt_number
- Current processing attempt number (starts at 1)
sourcepub fn sequence_number(&self) -> &str
pub fn sequence_number(&self) -> &str
Gets the sequence number of the record
This is a unique identifier for the record within its shard.
sourcepub fn approximate_arrival_timestamp(&self) -> Option<DateTime<Utc>>
pub fn approximate_arrival_timestamp(&self) -> Option<DateTime<Utc>>
Gets the approximate time when the record was inserted into the stream
Returns None
if the timestamp is not available or cannot be converted
to the chrono timestamp format.
sourcepub fn partition_key(&self) -> &str
pub fn partition_key(&self) -> &str
Gets the partition key of the record
The partition key is used to determine which shard in the stream the record belongs to.
sourcepub fn attempt_number(&self) -> u32
pub fn attempt_number(&self) -> u32
Gets the current processing attempt number
This starts at 1 for the first attempt and increments for each retry.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for RecordMetadata<'a>
impl<'a> RefUnwindSafe for RecordMetadata<'a>
impl<'a> Send for RecordMetadata<'a>
impl<'a> Sync for RecordMetadata<'a>
impl<'a> Unpin for RecordMetadata<'a>
impl<'a> UnwindSafe for RecordMetadata<'a>
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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