Skip to main content

beacon_interval

beacon_interval sets how far apart the file's beacons sit; denser beacons seek in finer steps and make the file larger.

A beacon is an index entry the file client writes into the stream file at a fixed interval of bytes. Beacons are the file's index: a seek finds its place in the file by them, so closer beacons make seeking finer-grained. Each beacon takes room in the file. The client's default is one beacon every 1 MiB.

The interval is a number of bytes, a positive multiple of 1024. Any other value fails startup with SeaFileError::Invalid, in a TestApp test as on a real file. The interval is written into the header of a file the broker creates.

Example​

The broker writes a beacon every 64 KiB. The test reads the interval back out of the header of the file it created.

/// A beacon every 64 KiB of the file: sixteen times as dense as the client's default of 1 MiB.
fn broker(path: &str) -> FileBroker {
FileBroker::new(path).beacon_interval(64 * 1024)
}

fn service(path: &str) -> impl App<State = ()> {
RustStream::new(AppInfo::new("orders", "0.1.0")).with_broker(broker(path), |b| {
b.include(handle);
})
}