Line data Source code
1 : use serde::Serialize;
2 : use utils::seqwait::MonotonicCounter;
3 :
4 : mod auth;
5 : mod compute_hook;
6 : mod heartbeater;
7 : pub mod http;
8 : mod id_lock_map;
9 : pub mod metrics;
10 : mod node;
11 : mod pageserver_client;
12 : pub mod persistence;
13 : mod reconciler;
14 : mod scheduler;
15 : mod schema;
16 : pub mod service;
17 : mod tenant_shard;
18 :
19 : #[derive(Ord, PartialOrd, Eq, PartialEq, Copy, Clone, Serialize)]
20 : struct Sequence(u64);
21 :
22 : impl Sequence {
23 0 : fn initial() -> Self {
24 0 : Self(0)
25 0 : }
26 : }
27 :
28 : impl std::fmt::Display for Sequence {
29 0 : fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
30 0 : write!(f, "{}", self.0)
31 0 : }
32 : }
33 :
34 : impl std::fmt::Debug for Sequence {
35 0 : fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
36 0 : write!(f, "{}", self.0)
37 0 : }
38 : }
39 :
40 : impl MonotonicCounter<Sequence> for Sequence {
41 0 : fn cnt_advance(&mut self, v: Sequence) {
42 0 : assert!(*self <= v);
43 0 : *self = v;
44 0 : }
45 0 : fn cnt_value(&self) -> Sequence {
46 0 : *self
47 0 : }
48 : }
49 :
50 : impl Sequence {
51 0 : fn next(&self) -> Sequence {
52 0 : Sequence(self.0 + 1)
53 0 : }
54 : }
|