summaryrefslogtreecommitdiffstats
path: root/src/config/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/config/mod.rs')
-rw-r--r--src/config/mod.rs39
1 files changed, 37 insertions, 2 deletions
diff --git a/src/config/mod.rs b/src/config/mod.rs
index c83ca70..c56afa6 100644
--- a/src/config/mod.rs
+++ b/src/config/mod.rs
@@ -66,7 +66,7 @@ const fn option(
}
/// What `--force` may override at start (`force`).
-pub(crate) const FORCE: &[&str] = &["swarmId"];
+pub(crate) const FORCE: &[&str] = &["swarmId", "badDocumentFile", "replaceDocumentFile"];
/// Every option. Names are the long option names and the configuration file keys.
pub(crate) const OPTIONS: &[OptionSpec] = &[
@@ -117,7 +117,7 @@ pub(crate) const OPTIONS: &[OptionSpec] = &[
Kind::List,
"NAME,[NAME...]",
None,
- "Override checks that otherwise refuse to start: true for all, or names: swarmId (a backup of another swarm than the state file remembers).",
+ "Override checks that otherwise refuse to start: true for all, or names: swarmId (a document to start on is of another swarm than the state file remembers), badDocumentFile (an unusable document file: moved aside, start without it), replaceDocumentFile (recover-from while the document file holds a document).",
),
option(
"recover-from",
@@ -127,6 +127,27 @@ pub(crate) const OPTIONS: &[OptionSpec] = &[
"Start the swarm again from a backup (as GET /admin/document saves it): this node loads it, on the swarm and epoch it names, and is ready at once; other nodes join it. Members of the swarm still running merge with it, or it rejoins them if they moved on to a newer epoch (the backup is then dropped).",
),
option(
+ "document-file",
+ Kind::Text,
+ "PATH",
+ None,
+ "This node's document on disk. Read at start: the node resumes with it, ready at once. Kept up to date while ready: changes are appended every --document-append-secs, and the file is rewritten after a switch, a rejoin or a restart, and when the appended changes outgrew it.",
+ ),
+ option(
+ "document-append-secs",
+ Kind::Integer,
+ "SECONDS",
+ Some("5"),
+ "How often changes are appended to the document file.",
+ ),
+ option(
+ "document-rewrite-secs",
+ Kind::Integer,
+ "SECONDS",
+ Some("3600"),
+ "Shortest time between rewrites of the document file because its appended changes outgrew its full save (a new epoch or a restart rewrites it at once).",
+ ),
+ option(
"state-file",
Kind::Text,
"PATH",
@@ -247,6 +268,11 @@ pub(crate) struct Settings {
#[serde(default)]
pub(crate) genesis: bool,
pub(crate) state_file: Option<PathBuf>,
+ pub(crate) document_file: Option<PathBuf>,
+ #[serde(default = "default_document_append_secs")]
+ pub(crate) document_append_secs: u64,
+ #[serde(default = "default_document_rewrite_secs")]
+ pub(crate) document_rewrite_secs: u64,
pub(crate) recover_from: Option<PathBuf>,
#[serde(default)]
pub(crate) force: Vec<String>,
@@ -273,6 +299,12 @@ pub(crate) struct Settings {
fn default_bind_addr() -> SocketAddr {
SocketAddr::from(([127, 0, 0, 1], 3000))
}
+fn default_document_append_secs() -> u64 {
+ 5
+}
+fn default_document_rewrite_secs() -> u64 {
+ 3600
+}
fn default_keepalive_secs() -> u64 {
60
}
@@ -340,6 +372,9 @@ impl Settings {
if self.neighbours < 2 {
bail!("neighbours must be at least 2");
}
+ if self.document_append_secs == 0 || self.document_rewrite_secs == 0 {
+ bail!("document-append-secs and document-rewrite-secs must be at least 1");
+ }
if self.keepalive_secs == 0 {
bail!("keepalive-secs must be at least 1");
}