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 safekeeper;
21 : mod safekeeper_client;
22 : mod scheduler;
23 : mod schema;
24 : pub mod service;
25 : mod tenant_shard;
26 :
27 : #[derive(Ord, PartialOrd, Eq, PartialEq, Copy, Clone, Serialize)]
28 : struct Sequence(u64);
29 :
30 : impl Sequence {
31 0 : fn initial() -> Self {
32 0 : Self(0)
33 0 : }
34 : }
35 :
36 : impl std::fmt::Display for Sequence {
37 0 : fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
38 0 : write!(f, "{}", self.0)
39 0 : }
40 : }
41 :
42 : impl std::fmt::Debug for Sequence {
43 0 : fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
44 0 : write!(f, "{}", self.0)
45 0 : }
46 : }
47 :
48 : impl MonotonicCounter<Sequence> for Sequence {
49 0 : fn cnt_advance(&mut self, v: Sequence) {
50 0 : assert!(*self <= v);
51 0 : *self = v;
52 0 : }
53 0 : fn cnt_value(&self) -> Sequence {
54 0 : *self
55 0 : }
56 : }
57 :
58 : impl Sequence {
59 0 : fn next(&self) -> Sequence {
60 0 : Sequence(self.0 + 1)
61 0 : }
62 : }
|