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