go_zoom_kinesis::processor

Struct RecordMetadata

source
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>

source

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 record
  • shard_id - ID of the shard this record came from
  • attempt_number - Current processing attempt number (starts at 1)
source

pub fn sequence_number(&self) -> &str

Gets the sequence number of the record

This is a unique identifier for the record within its shard.

source

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.

source

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.

source

pub fn shard_id(&self) -> &str

Gets the ID of the shard this record came from

source

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§

source§

impl<'a> Debug for RecordMetadata<'a>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
source§

impl<T> Same for T

source§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more