mirror of
https://github.com/loro-dev/loro.git
synced 2025-02-05 20:17:13 +00:00
chore: add gc config
This commit is contained in:
parent
fb27c1656b
commit
81ccf8fc4a
3 changed files with 47 additions and 6 deletions
|
@ -52,8 +52,17 @@ impl HasLength for Change {
|
|||
}
|
||||
|
||||
pub struct ChangeMergeCfg {
|
||||
max_change_length: usize,
|
||||
max_change_interval: usize,
|
||||
pub max_change_length: usize,
|
||||
pub max_change_interval: usize,
|
||||
}
|
||||
|
||||
impl Default for ChangeMergeCfg {
|
||||
fn default() -> Self {
|
||||
ChangeMergeCfg {
|
||||
max_change_length: 1024,
|
||||
max_change_interval: 60,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Mergable<ChangeMergeCfg> for Change {
|
||||
|
|
|
@ -3,17 +3,42 @@ use std::collections::HashMap;
|
|||
use string_cache::{Atom, DefaultAtom, EmptyStaticAtomSet};
|
||||
|
||||
use crate::{change::Change, id::ClientID, ChangeMergeCfg, Lamport, ID};
|
||||
const YEAR: u64 = 365 * 24 * 60 * 60;
|
||||
const MONTH: u64 = 30 * 24 * 60 * 60;
|
||||
|
||||
pub struct GcConfig {
|
||||
pub gc: bool,
|
||||
pub interval: u64,
|
||||
}
|
||||
|
||||
impl Default for GcConfig {
|
||||
fn default() -> Self {
|
||||
GcConfig {
|
||||
gc: false,
|
||||
interval: 6 * MONTH,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Configure {
|
||||
pub change: ChangeMergeCfg,
|
||||
pub gc: GcConfig,
|
||||
}
|
||||
|
||||
pub struct LogStore {
|
||||
ops: HashMap<ClientID, RleVec<Change, ChangeMergeCfg>>,
|
||||
lamport: Lamport,
|
||||
cfg: Configure,
|
||||
latest_lamport: Lamport,
|
||||
latest_timestamp: Lamport,
|
||||
}
|
||||
|
||||
impl LogStore {
|
||||
pub fn new() -> Self {
|
||||
pub fn new(cfg: Configure) -> Self {
|
||||
Self {
|
||||
cfg,
|
||||
ops: HashMap::new(),
|
||||
lamport: 0,
|
||||
latest_lamport: 0,
|
||||
latest_timestamp: 0,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,6 +51,9 @@ impl LogStore {
|
|||
|
||||
impl Default for LogStore {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
Self::new(Configure {
|
||||
change: Default::default(),
|
||||
gc: Default::default(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,6 +81,10 @@ impl RawStore {
|
|||
|
||||
version_vector
|
||||
}
|
||||
|
||||
pub fn sign(&self, pub_key: ()) {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for RawStore {
|
||||
|
|
Loading…
Reference in a new issue