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