Line data Source code
1 : use serde::{Deserialize, Serialize};
2 : use utils::seqwait::MonotonicCounter;
3 :
4 : mod compute_hook;
5 : pub mod http;
6 : pub mod metrics;
7 : mod node;
8 : pub mod persistence;
9 : mod reconciler;
10 : mod scheduler;
11 : mod schema;
12 : pub mod service;
13 : mod tenant_state;
14 :
15 0 : #[derive(Clone, Serialize, Deserialize, Debug)]
16 : enum PlacementPolicy {
17 : /// Cheapest way to attach a tenant: just one pageserver, no secondary
18 : Single,
19 : /// Production-ready way to attach a tenant: one attached pageserver and
20 : /// some number of secondaries.
21 : Double(usize),
22 : /// Do not attach to any pageservers
23 : Detached,
24 : }
25 :
26 0 : #[derive(Ord, PartialOrd, Eq, PartialEq, Copy, Clone, Serialize)]
27 : struct Sequence(u64);
28 :
29 : impl Sequence {
30 0 : fn initial() -> Self {
31 0 : Self(0)
32 0 : }
33 : }
34 :
35 : impl std::fmt::Display for Sequence {
36 0 : fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
37 0 : write!(f, "{}", self.0)
38 0 : }
39 : }
40 :
41 : impl std::fmt::Debug for Sequence {
42 0 : fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
43 0 : write!(f, "{}", self.0)
44 0 : }
45 : }
46 :
47 : impl MonotonicCounter<Sequence> for Sequence {
48 0 : fn cnt_advance(&mut self, v: Sequence) {
49 0 : assert!(*self <= v);
50 0 : *self = v;
51 0 : }
52 0 : fn cnt_value(&self) -> Sequence {
53 0 : *self
54 0 : }
55 : }
56 :
57 : impl Sequence {
58 0 : fn next(&self) -> Sequence {
59 0 : Sequence(self.0 + 1)
60 0 : }
61 : }
62 :
63 : impl Default for PlacementPolicy {
64 0 : fn default() -> Self {
65 0 : PlacementPolicy::Double(1)
66 0 : }
67 : }
|