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