swarm-controller: move the review concern into its own module
Refs #6897
This commit is contained in:
parent
b52fc0ec8e
commit
237cdaffaa
12 changed files with 24 additions and 12 deletions
|
|
@ -76,8 +76,6 @@ mod message_stream;
|
|||
mod meta_build;
|
||||
mod meta_fanout;
|
||||
mod meta_flake;
|
||||
mod notify_flows;
|
||||
mod notify_router_api;
|
||||
mod observability_grant;
|
||||
mod otel_http_client;
|
||||
mod pause_hold;
|
||||
|
|
@ -87,8 +85,7 @@ mod proxy_credential;
|
|||
mod pulls;
|
||||
mod queue_identity;
|
||||
mod read_policy;
|
||||
mod request_reviewer;
|
||||
mod review_classifier;
|
||||
mod review;
|
||||
mod routes;
|
||||
mod schedules;
|
||||
mod ssh_connections;
|
||||
|
|
@ -105,6 +102,8 @@ mod wanted;
|
|||
mod webhook;
|
||||
|
||||
use jobq::{Late, WorkerDeps, spawn_jobq_worker};
|
||||
// The review modules keep their crate-root paths (`crate::review_classifier::…`).
|
||||
use review::{notify_flows, notify_router_api, request_reviewer, review_classifier};
|
||||
use routes::AppState;
|
||||
use startup::{
|
||||
agent_icon_reader, agent_status_reader, agents_md_reader, build_app,
|
||||
|
|
|
|||
7
swarm-controller/src/review/mod.rs
Normal file
7
swarm-controller/src/review/mod.rs
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
//! The review concern: the review classifier, requested reviews and the
|
||||
//! notification flows, with their routes.
|
||||
|
||||
pub(crate) mod notify_flows;
|
||||
pub(crate) mod notify_router_api;
|
||||
pub(crate) mod request_reviewer;
|
||||
pub(crate) mod review_classifier;
|
||||
|
|
@ -1406,7 +1406,7 @@ classifications:
|
|||
let [yml_path, _] = RULES_PATHS;
|
||||
let rules = parse_rules(
|
||||
yml_path,
|
||||
include_str!("../../.hyperhive/review-classifier.yml").as_bytes(),
|
||||
include_str!("../../../.hyperhive/review-classifier.yml").as_bytes(),
|
||||
)
|
||||
.expect("the repo's rules file parses");
|
||||
let names: Vec<_> = rules.iter().map(|c| c.name.as_str()).collect();
|
||||
|
|
@ -214,14 +214,14 @@ pub(super) mod testing {
|
|||
use super::{Metrics, SdkMeterProvider};
|
||||
|
||||
/// Instruments on a provider that exports to memory.
|
||||
pub(in crate::review_classifier) struct Recorder {
|
||||
pub(in crate::review_classifier) metrics: Metrics,
|
||||
pub(in crate::review::review_classifier) struct Recorder {
|
||||
pub(in crate::review::review_classifier) metrics: Metrics,
|
||||
provider: SdkMeterProvider,
|
||||
exporter: InMemoryMetricExporter,
|
||||
}
|
||||
|
||||
impl Recorder {
|
||||
pub(in crate::review_classifier) fn new() -> Self {
|
||||
pub(in crate::review::review_classifier) fn new() -> Self {
|
||||
let exporter = InMemoryMetricExporter::default();
|
||||
let reader = PeriodicReader::builder(exporter.clone()).build();
|
||||
let provider = SdkMeterProvider::builder().with_reader(reader).build();
|
||||
|
|
@ -246,7 +246,10 @@ pub(super) mod testing {
|
|||
|
||||
/// The counter `name`'s value per label set, each set as
|
||||
/// `key=value,key=value` in key order. Empty when nothing was added.
|
||||
pub(in crate::review_classifier) fn counter(&self, name: &str) -> BTreeMap<String, u64> {
|
||||
pub(in crate::review::review_classifier) fn counter(
|
||||
&self,
|
||||
name: &str,
|
||||
) -> BTreeMap<String, u64> {
|
||||
self.export(name, |data| {
|
||||
let AggregatedMetrics::U64(MetricData::Sum(sum)) = data else {
|
||||
panic!("not a u64 sum: {data:?}");
|
||||
|
|
@ -260,7 +263,10 @@ pub(super) mod testing {
|
|||
|
||||
/// The histogram `name`'s sample count per label set, as
|
||||
/// [`Self::counter`] writes them.
|
||||
pub(in crate::review_classifier) fn histogram(&self, name: &str) -> BTreeMap<String, u64> {
|
||||
pub(in crate::review::review_classifier) fn histogram(
|
||||
&self,
|
||||
name: &str,
|
||||
) -> BTreeMap<String, u64> {
|
||||
self.export(name, |data| {
|
||||
let AggregatedMetrics::F64(MetricData::Histogram(h)) = data else {
|
||||
panic!("not an f64 histogram: {data:?}");
|
||||
|
|
@ -533,7 +533,7 @@ mod tests {
|
|||
}
|
||||
}
|
||||
|
||||
const OWN: &str = include_str!("../../../.hyperhive/review-classifier.yml");
|
||||
const OWN: &str = include_str!("../../../../.hyperhive/review-classifier.yml");
|
||||
|
||||
#[test]
|
||||
fn a_new_rule_leaves_every_existing_entry_as_it_was_written() {
|
||||
Loading…
Reference in a new issue