pub struct Topic { /* private fields */ }Expand description
Represents a topic with multiple partitions
Implementations§
Source§impl Topic
impl Topic
Sourcepub async fn new(
config: &Config,
name: String,
num_partitions: u32,
) -> Result<Self>
pub async fn new( config: &Config, name: String, num_partitions: u32, ) -> Result<Self>
Create a new topic with the specified number of partitions
Sourcepub async fn new_with_tiered_storage(
config: &Config,
name: String,
num_partitions: u32,
tiered_storage: Option<Arc<TieredStorage>>,
) -> Result<Self>
pub async fn new_with_tiered_storage( config: &Config, name: String, num_partitions: u32, tiered_storage: Option<Arc<TieredStorage>>, ) -> Result<Self>
Create a new topic with the specified number of partitions and optional tiered storage
Sourcepub fn num_partitions(&self) -> usize
pub fn num_partitions(&self) -> usize
Get the number of partitions
Sourcepub async fn append(&self, partition_id: u32, message: Message) -> Result<u64>
pub async fn append(&self, partition_id: u32, message: Message) -> Result<u64>
Append a message to a specific partition
Sourcepub async fn read(
&self,
partition_id: u32,
start_offset: u64,
max_messages: usize,
) -> Result<Vec<Message>>
pub async fn read( &self, partition_id: u32, start_offset: u64, max_messages: usize, ) -> Result<Vec<Message>>
Read messages from a specific partition
Sourcepub fn all_partitions(&self) -> Vec<Arc<Partition>>
pub fn all_partitions(&self) -> Vec<Arc<Partition>>
Get all partitions
Sourcepub async fn find_offset_for_timestamp(
&self,
partition_id: u32,
target_timestamp: i64,
) -> Result<Option<u64>>
pub async fn find_offset_for_timestamp( &self, partition_id: u32, target_timestamp: i64, ) -> Result<Option<u64>>
Find the first offset with timestamp >= target_timestamp (milliseconds since epoch) Returns None if no matching offset is found.
Sourcepub async fn add_partitions(
&self,
config: &Config,
new_total: u32,
tiered_storage: Option<Arc<TieredStorage>>,
) -> Result<u32>
pub async fn add_partitions( &self, config: &Config, new_total: u32, tiered_storage: Option<Arc<TieredStorage>>, ) -> Result<u32>
Dynamically add partitions to this topic.
Creates new partitions with IDs from current_count to new_total - 1.
Existing partitions and their data are unaffected.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Topic
impl !RefUnwindSafe for Topic
impl Send for Topic
impl Sync for Topic
impl Unpin for Topic
impl !UnwindSafe for Topic
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Mutably borrows from an owned value. Read more
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>
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 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>
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