Create a [`TestDB`] which stores data in a local commitlog. Note that flushing the log is an asynchronous process. [`Self::reopen`] ensures all data has been flushed to disk before re-opening the database.
()
| 1924 | /// ensures all data has been flushed to disk before re-opening the |
| 1925 | /// database. |
| 1926 | pub fn durable() -> Result<Self, DBError> { |
| 1927 | let dir = TempReplicaDir::new()?; |
| 1928 | let rt = TokioRuntimeBuilder::new_multi_thread().enable_all().build()?; |
| 1929 | // Enter the runtime so that `Self::durable_internal` can spawn a `SnapshotWorker`. |
| 1930 | let _rt = rt.enter(); |
| 1931 | let (db, durability) = Self::durable_internal(&dir, rt.handle().clone(), true)?; |
| 1932 | let durable = DurableState { |
| 1933 | durability, |
| 1934 | rt, |
| 1935 | replica_dir: dir.into(), |
| 1936 | }; |
| 1937 | |
| 1938 | Ok(Self { |
| 1939 | db: Arc::new(db), |
| 1940 | durable: Some(durable), |
| 1941 | want_snapshot_repo: true, |
| 1942 | }) |
| 1943 | } |
| 1944 | |
| 1945 | pub fn durable_without_snapshot_repo() -> Result<Self, DBError> { |
| 1946 | let dir = TempReplicaDir::new()?; |