From 80d6ad916e8f7be6c75eb854db437170ff92feb6 Mon Sep 17 00:00:00 2001 From: James Wilson Date: Wed, 11 Aug 2021 17:23:22 +0100 Subject: [PATCH] Address David's comments --- backend/common/src/id_type.rs | 4 ++-- backend/common/src/rolling_total.rs | 2 +- backend/telemetry_core/src/aggregator/aggregator.rs | 2 +- backend/telemetry_core/src/state/chain.rs | 4 ++-- backend/telemetry_shard/src/aggregator.rs | 2 +- backend/telemetry_shard/src/real_ip.rs | 12 +++++++----- 6 files changed, 14 insertions(+), 12 deletions(-) diff --git a/backend/common/src/id_type.rs b/backend/common/src/id_type.rs index 0274b80..e73b8b2 100644 --- a/backend/common/src/id_type.rs +++ b/backend/common/src/id_type.rs @@ -46,8 +46,8 @@ macro_rules! id_type { #[cfg(test)] mod test { - //! Mostly we're just checking that everything compiles OK - //! when the macro is used as expected.. + // Mostly we're just checking that everything compiles OK + // when the macro is used as expected.. // A basic definition is possible: id_type! { diff --git a/backend/common/src/rolling_total.rs b/backend/common/src/rolling_total.rs index a2af5e2..5d2bcc3 100644 --- a/backend/common/src/rolling_total.rs +++ b/backend/common/src/rolling_total.rs @@ -148,7 +148,7 @@ where self.total } - /// Fetch the current time source, incase we need to modify it. + /// Fetch the current time source, in case we need to modify it. pub fn time_source(&mut self) -> &mut Time { &mut self.time_source } diff --git a/backend/telemetry_core/src/aggregator/aggregator.rs b/backend/telemetry_core/src/aggregator/aggregator.rs index 3f90131..7c975ee 100644 --- a/backend/telemetry_core/src/aggregator/aggregator.rs +++ b/backend/telemetry_core/src/aggregator/aggregator.rs @@ -37,7 +37,7 @@ pub struct Aggregator(Arc); struct AggregatorInternal { /// Shards that connect are each assigned a unique connection ID. /// This helps us know who to send messages back to (especially in - /// conjunction with the [`LocalId`] that messages will come with). + /// conjunction with the `ShardNodeId` that messages will come with). shard_conn_id: AtomicU64, /// Feeds that connect have their own unique connection ID, too. feed_conn_id: AtomicU64, diff --git a/backend/telemetry_core/src/state/chain.rs b/backend/telemetry_core/src/state/chain.rs index ea416f4..d5df95b 100644 --- a/backend/telemetry_core/src/state/chain.rs +++ b/backend/telemetry_core/src/state/chain.rs @@ -97,7 +97,7 @@ impl Chain { } /// Can we add a node? If not, it's because the chain is at its quota. - pub fn can_add_node(&self) -> bool { + pub fn is_overquota(&self) -> bool { // Dynamically determine the max nodes based on the most common // label so far, in case it changes to something with a different limit. self.nodes.len() < max_nodes(self.labels.best()) @@ -105,7 +105,7 @@ impl Chain { /// Assign a node to this chain. pub fn add_node(&mut self, node: Node) -> AddNodeResult { - if !self.can_add_node() { + if !self.is_overquota() { return AddNodeResult::Overquota; } diff --git a/backend/telemetry_shard/src/aggregator.rs b/backend/telemetry_shard/src/aggregator.rs index d80bbba..1200240 100644 --- a/backend/telemetry_shard/src/aggregator.rs +++ b/backend/telemetry_shard/src/aggregator.rs @@ -30,7 +30,7 @@ use std::sync::Arc; /// A unique Id is assigned per websocket connection (or more accurately, /// per thing-that-subscribes-to-the-aggregator). That connection might send /// data on behalf of multiple chains, so this ID is local to the aggregator, -/// and a unique ID is assigned per batch of data too ([`internal_messages::LocalId`]). +/// and a unique ID is assigned per batch of data too ([`internal_messages::ShardNodeId`]). type ConnId = u64; /// Incoming messages are either from websocket connections or diff --git a/backend/telemetry_shard/src/real_ip.rs b/backend/telemetry_shard/src/real_ip.rs index 79a1bc2..d0828d9 100644 --- a/backend/telemetry_shard/src/real_ip.rs +++ b/backend/telemetry_shard/src/real_ip.rs @@ -83,7 +83,7 @@ fn pick_best_ip_from_options( realip } -/// Follow https://datatracker.ietf.org/doc/html/rfc7239 to decode the Forwarded header value. +/// Follow to decode the Forwarded header value. /// Roughly, proxies can add new sets of values by appending a comma to the existing list /// (so we have something like "values1, values2, values3" from proxy1, proxy2 and proxy3 for /// instance) and then the valeus themselves are ';' separated name=value pairs. The value in each @@ -91,10 +91,12 @@ fn pick_best_ip_from_options( /// /// Examples from the RFC: /// -/// Forwarded: for="_gazonk" -/// Forwarded: For="[2001:db8:cafe::17]:4711" -/// Forwarded: for=192.0.2.60;proto=http;by=203.0.113.43 -/// Forwarded: for=192.0.2.43, for=198.51.100.17 +/// ```text +/// Forwarded: for="_gazonk" +/// Forwarded: For="[2001:db8:cafe::17]:4711" +/// Forwarded: for=192.0.2.60;proto=http;by=203.0.113.43 +/// Forwarded: for=192.0.2.43, for=198.51.100.17 +/// ``` fn get_first_addr_from_forwarded_header(value: &str) -> Option<&str> { let first_values = value.split(',').next()?;