Skip to content
This repository was archived by the owner on Jun 24, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ mod topic;

use client::IggyClient;
use pyo3::prelude::*;
use receive_message::{PollingStrategy, ReceiveMessage};
use receive_message::{MessageState, PollingStrategy, ReceiveMessage};
use send_message::SendMessage;
use stream::StreamDetails;
use topic::TopicDetails;
Expand All @@ -20,5 +20,6 @@ fn iggy_py(_py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> {
m.add_class::<StreamDetails>()?;
m.add_class::<TopicDetails>()?;
m.add_class::<PollingStrategy>()?;
m.add_class::<MessageState>()?;
Ok(())
}
50 changes: 50 additions & 0 deletions src/receive_message.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use iggy::messages::poll_messages::PollingStrategy as RustPollingStrategy;
use iggy::models::messages::MessageState as RustMessageState;
use iggy::models::messages::PolledMessage as RustReceiveMessage;
use pyo3::prelude::*;
use pyo3::types::PyBytes;
Expand All @@ -20,6 +21,15 @@ impl ReceiveMessage {
}
}

#[pyclass(eq, eq_int)]
#[derive(PartialEq)]
pub enum MessageState {
Available,
Unavailable,
Poisoned,
MarkedForDeletion,
}

#[pymethods]
impl ReceiveMessage {
/// Retrieves the payload of the received message.
Expand All @@ -35,6 +45,46 @@ impl ReceiveMessage {
pub fn offset(&self) -> u64 {
self.inner.offset
}

/// Retrieves the timestamp of the received message.
///
/// The timestamp represents the time of the message within its topic.
pub fn timestamp(&self) -> u64 {
self.inner.timestamp
}

/// Retrieves the id of the received message.
///
/// The id represents unique identifier of the message within its topic.
pub fn id(&self) -> u128 {
self.inner.id
}

/// Retrieves the checksum of the received message.
///
/// The checksum represents the integrity of the message within its topic.
pub fn checksum(&self) -> u32 {
self.inner.checksum
}

/// Retrieves the Message's state of the received message.
///
/// State represents the state of the response.
pub fn state(&self) -> MessageState {
match self.inner.state {
RustMessageState::Available => MessageState::Available,
RustMessageState::Unavailable => MessageState::Unavailable,
RustMessageState::Poisoned => MessageState::Poisoned,
RustMessageState::MarkedForDeletion => MessageState::MarkedForDeletion,
}
}

/// Retrieves the length of the received message.
///
/// The length represents the length of the payload.
pub fn length(&self) -> u32 {
self.inner.length
}
}

#[derive(Clone, Copy)]
Expand Down