[−][src]Function kekbit_core::shm::shm_writer
pub fn shm_writer(
root_path: &Path,
header: &Header
) -> Result<ShmWriter, ChannelError>
Creates a file backed memory mapped kekbit channel and a writer associate with it.
Returns a ready to use writer to the new created channel or an error if the operation fails.
Arguments
root_path
- The path to the folder where all the channels will be stored grouped by writers id.header
- a structure of type Header which contains the complete information required to create a channel.
Errors
Various errors may occur if the operation fails.
Examples
use kekbit_core::tick::TickUnit::Nanos; use kekbit_core::shm::*; use kekbit_core::header::Header; use kekbit_core::api::Writer; const FOREVER: u64 = 99_999_999_999; let writer_id = 1850; let channel_id = 42; let capacity = 3000; let max_msg_len = 100; let header = Header::new(writer_id, channel_id, capacity, max_msg_len, FOREVER, Nanos); let test_tmp_dir = tempdir::TempDir::new("kektest").unwrap(); let mut writer = shm_writer(&test_tmp_dir.path(), &header).unwrap(); writer.heartbeat().unwrap();