surrealdb_core/
options.rs

1use std::time::Duration;
2
3/// Configuration for the engine behaviour
4///
5/// The defaults are optimal so please only modify these if you know deliberately why you are modifying them.
6#[derive(Clone, Copy, Debug)]
7#[non_exhaustive]
8pub struct EngineOptions {
9	pub node_membership_refresh_interval: Duration,
10	pub node_membership_check_interval: Duration,
11	pub node_membership_cleanup_interval: Duration,
12	pub changefeed_gc_interval: Duration,
13	/// Interval for running the index compaction process
14	///
15	/// The index compaction thread runs at this interval to process indexes
16	/// that have been marked for compaction. Compaction helps optimize index
17	/// performance, particularly for full-text indexes, by consolidating
18	/// changes and removing unnecessary data.
19	///
20	/// Default: 5 seconds
21	pub index_compaction_interval: Duration,
22}
23
24impl Default for EngineOptions {
25	fn default() -> Self {
26		Self {
27			node_membership_refresh_interval: Duration::from_secs(3),
28			node_membership_check_interval: Duration::from_secs(15),
29			node_membership_cleanup_interval: Duration::from_secs(300),
30			changefeed_gc_interval: Duration::from_secs(10),
31			index_compaction_interval: Duration::from_secs(5),
32		}
33	}
34}
35
36impl EngineOptions {
37	pub fn with_node_membership_refresh_interval(mut self, interval: Duration) -> Self {
38		self.node_membership_refresh_interval = interval;
39		self
40	}
41	pub fn with_node_membership_check_interval(mut self, interval: Duration) -> Self {
42		self.node_membership_check_interval = interval;
43		self
44	}
45	pub fn with_node_membership_cleanup_interval(mut self, interval: Duration) -> Self {
46		self.node_membership_cleanup_interval = interval;
47		self
48	}
49	pub fn with_changefeed_gc_interval(mut self, interval: Duration) -> Self {
50		self.changefeed_gc_interval = interval;
51		self
52	}
53
54	pub fn with_index_compaction_interval(mut self, interval: Duration) -> Self {
55		self.index_compaction_interval = interval;
56		self
57	}
58}