Skip to main content

reifydb_runtime/context/
mod.rs

1// SPDX-License-Identifier: Apache-2.0
2// Copyright (c) 2026 ReifyDB
3
4pub mod clock;
5pub mod rng;
6
7use clock::{Clock, MockClock};
8use rng::Rng;
9
10use crate::version_epoch::VersionEpoch;
11
12#[derive(Clone)]
13pub struct RuntimeContext {
14	pub clock: Clock,
15	pub rng: Rng,
16	pub version_epoch: VersionEpoch,
17}
18
19impl RuntimeContext {
20	pub fn new(clock: Clock, rng: Rng, version_epoch: VersionEpoch) -> Self {
21		Self {
22			clock,
23			rng,
24			version_epoch,
25		}
26	}
27
28	pub fn with_clock(clock: Clock) -> Self {
29		Self {
30			clock,
31			rng: Rng::default(),
32			version_epoch: VersionEpoch::new(),
33		}
34	}
35
36	pub fn testing(initial_millis: u64, seed: u64) -> Self {
37		Self {
38			clock: Clock::Mock(MockClock::from_millis(initial_millis)),
39			rng: Rng::seeded(seed),
40			version_epoch: VersionEpoch::new(),
41		}
42	}
43}