pub struct DiskEnvironmentStore { /* private fields */ }Expand description
DiskEnvironmentStore implements the EnvironmentStore trait for production use. PostBundles are stored as files in a directory tree, while config, metadata, feedback, and post-expiry metainformation are stored in a key-value database.
A lot of time was spent comparing the different available databases. Given the nature of hashiverse, it makes sense that some sort of key-value (KV) database is used.
For simplicity of building and maintenance, we decided to use a pure-Rust implementation. This narrowed teh field down to redb, sled, and fjall.
We would have liked to use redb, because of its self-reported performance with individual writes and random range reads - both things that hashiverse does a lot of.
Unfortunately it requires occasional compaction of the ever-growing files on disk, something that needs downtime and 2x disk space to do. This essentially killed it for us.
Next was sled, which autocompacts and seemed the next most performant, but there seems to be little improvement and support for it - it’s own github repo says use this as beta software only, and work on its v1.0 release seems to have stalled.
That leaves fjall - seemingly third place in performance, but gauging by its github activity, is ever improving and is highly supported. It also does autocompaction.
Trait Implementations§
Source§impl EnvironmentStore for DiskEnvironmentStore
impl EnvironmentStore for DiskEnvironmentStore
fn post_bundle_count(&self) -> Result<usize>
fn post_bundle_metadata_get( &self, location_id: &Id, ) -> Result<Option<PostBundleMetadata>>
fn post_bundle_metadata_put( &self, location_id: &Id, post_bundle_metadata: &PostBundleMetadata, ) -> Result<()>
fn post_bundle_bytes_get(&self, location_id: &Id) -> Result<Option<Bytes>>
fn post_bundle_bytes_put(&self, location_id: &Id, bytes: &[u8]) -> Result<()>
Source§fn post_bundle_feedbacks_bytes_get(
&self,
post_bundle_location_id: &Id,
) -> Result<Bytes>
fn post_bundle_feedbacks_bytes_get( &self, post_bundle_location_id: &Id, ) -> Result<Bytes>
Source§fn post_feedback_put_if_more_powerful(
&self,
location_id: &Id,
encoded_post_feedback: &EncodedPostFeedbackV1,
) -> Result<()>
fn post_feedback_put_if_more_powerful( &self, location_id: &Id, encoded_post_feedback: &EncodedPostFeedbackV1, ) -> Result<()>
fn post_bundles_delete(&self, location_ids: &[Id]) -> Result<()>
fn post_bundles_last_accessed_flush( &self, post_bundles_last_accessed: &HashMap<Id, TimeMillis>, ) -> Result<()>
fn post_bundles_last_accessed_iter( &self, location_id: &Id, ) -> Box<dyn Iterator<Item = Result<(Id, TimeMillisBytes), Error>> + '_>
fn config_get_bytes(&self, key: &str) -> Result<Option<Vec<u8>>>
fn config_put_bytes(&self, key: &str, v: Vec<u8>) -> Result<()>
fn config_get_usize(&self, key: &str) -> Result<Option<usize>>
fn config_put_usize(&self, key: &str, v: usize) -> Result<()>
Auto Trait Implementations§
impl Freeze for DiskEnvironmentStore
impl !RefUnwindSafe for DiskEnvironmentStore
impl Send for DiskEnvironmentStore
impl Sync for DiskEnvironmentStore
impl Unpin for DiskEnvironmentStore
impl UnsafeUnpin for DiskEnvironmentStore
impl !UnwindSafe for DiskEnvironmentStore
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
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>
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