Struct streambed_logged::FileLog
source · pub struct FileLog { /* private fields */ }Expand description
A commit log implementation that uses the file system as its backing store.
Considerations:
- Partition values cannot be non-zero.
- The number of subscriptions of a topic will translate to the number of tasks that are spawned, along with their associated resources.
- Only one process can produce to a specific topic. There is no process-wide locking considered. Multiple processes can read a topic though.
Implementations§
source§impl FileLog
impl FileLog
sourcepub fn new<P>(root_path: P) -> Self
pub fn new<P>(root_path: P) -> Self
Construct a new file log that will also spawn a task for each topic being produced.
sourcepub fn with_config<P>(
root_path: P,
compaction_threshold_size: u64,
read_buffer_size: usize,
compaction_write_buffer_size: usize,
write_buffer_size: usize,
max_record_size: usize,
) -> Self
pub fn with_config<P>( root_path: P, compaction_threshold_size: u64, read_buffer_size: usize, compaction_write_buffer_size: usize, write_buffer_size: usize, max_record_size: usize, ) -> Self
Construct a new file log that will also spawn a task for each topic being produced. The compaction_threshold_size is the size of the active file that the compactor looks at before deciding to perform a compaction (in bytes). This typically equates to the blocksize on disk i.e. 64KB for flash based storage. 64KB is still small enough that scans over a topic are relatively fast, working on the principle of having roughly 2,000 records. We also require a read and write buffer sizes to reduce system calls. When writing, either the buffer reaches capacity or a flush of the buffer occurs in the absence of another write to perform.
sourcepub fn close_topic(&mut self, topic: &Topic)
pub fn close_topic(&mut self, topic: &Topic)
Frees resources associated with a topic, but not any associated compaction. Invoking the method is benign in that if consuming or producing occurs on this post closing, resources will be re-established.
sourcepub async fn register_compaction<CS>(
&mut self,
topic: Topic,
compaction_strategy: CS,
) -> Result<(), CompactionRegistrationError>
pub async fn register_compaction<CS>( &mut self, topic: Topic, compaction_strategy: CS, ) -> Result<(), CompactionRegistrationError>
Register compaction for a given topic. Any previously registered compaction is replaced. A new task for compaction will be created in the background.
Compaction’s memory can be controlled somewhat through compaction_write_buffer_size
when creating this file commit log. This buffer size is selected to minimize
writing to flash and will be allocated once per topic compaction registered here.
sourcepub fn unregister_compaction(&mut self, topic: &Topic)
pub fn unregister_compaction(&mut self, topic: &Topic)
Unregister compaction for a given topic
Trait Implementations§
source§impl CommitLog for FileLog
impl CommitLog for FileLog
source§fn offsets<'life0, 'async_trait>(
&'life0 self,
topic: Topic,
_partition: Partition,
) -> Pin<Box<dyn Future<Output = Option<PartitionOffsets>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn offsets<'life0, 'async_trait>(
&'life0 self,
topic: Topic,
_partition: Partition,
) -> Pin<Box<dyn Future<Output = Option<PartitionOffsets>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
source§fn produce<'life0, 'async_trait>(
&'life0 self,
record: ProducerRecord,
) -> Pin<Box<dyn Future<Output = Result<ProducedOffset, ProducerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn produce<'life0, 'async_trait>(
&'life0 self,
record: ProducerRecord,
) -> Pin<Box<dyn Future<Output = Result<ProducedOffset, ProducerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
source§fn scoped_subscribe<'a>(
&'a self,
_consumer_group_name: &str,
offsets: Vec<ConsumerOffset>,
subscriptions: Vec<Subscription>,
idle_timeout: Option<Duration>,
) -> Pin<Box<dyn Stream<Item = ConsumerRecord> + Send + 'a>>
fn scoped_subscribe<'a>( &'a self, _consumer_group_name: &str, offsets: Vec<ConsumerOffset>, subscriptions: Vec<Subscription>, idle_timeout: Option<Duration>, ) -> Pin<Box<dyn Stream<Item = ConsumerRecord> + Send + 'a>>
Auto Trait Implementations§
impl Freeze for FileLog
impl RefUnwindSafe for FileLog
impl Send for FileLog
impl Sync for FileLog
impl Unpin for FileLog
impl UnwindSafe for FileLog
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§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)