mirror of
https://github.com/deps-rs/deps.rs.git
synced 2024-12-04 23:46:30 +00:00
refactor: drop unused cadence
metrics (#243)
This commit is contained in:
parent
c27c8ea184
commit
ab2a38efb2
4 changed files with 2 additions and 38 deletions
10
Cargo.lock
generated
10
Cargo.lock
generated
|
@ -470,15 +470,6 @@ dependencies = [
|
||||||
"bytes",
|
"bytes",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "cadence"
|
|
||||||
version = "1.5.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "62fd689c825a93386a2ac05a46f88342c6df9ec3e79416f665650614e92e7475"
|
|
||||||
dependencies = [
|
|
||||||
"crossbeam-channel",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "camino"
|
name = "camino"
|
||||||
version = "1.1.9"
|
version = "1.1.9"
|
||||||
|
@ -3575,7 +3566,6 @@ dependencies = [
|
||||||
"actix-web-lab",
|
"actix-web-lab",
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"badge",
|
"badge",
|
||||||
"cadence",
|
|
||||||
"crates-index",
|
"crates-index",
|
||||||
"derive_more 1.0.0",
|
"derive_more 1.0.0",
|
||||||
"dotenvy",
|
"dotenvy",
|
||||||
|
|
|
@ -17,7 +17,6 @@ badge = { path = "./libs/badge" }
|
||||||
actix-web = "4"
|
actix-web = "4"
|
||||||
actix-web-lab = "0.23"
|
actix-web-lab = "0.23"
|
||||||
anyhow = "1"
|
anyhow = "1"
|
||||||
cadence = "1"
|
|
||||||
crates-index = { version = "3", default-features = false, features = ["git"] }
|
crates-index = { version = "3", default-features = false, features = ["git"] }
|
||||||
derive_more = { version = "1", features = ["display", "error", "from"] }
|
derive_more = { version = "1", features = ["display", "error", "from"] }
|
||||||
dotenvy = "0.15"
|
dotenvy = "0.15"
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
use std::{
|
use std::{
|
||||||
collections::HashSet,
|
collections::HashSet,
|
||||||
panic::RefUnwindSafe,
|
|
||||||
sync::{Arc, LazyLock},
|
sync::{Arc, LazyLock},
|
||||||
time::{Duration, Instant},
|
time::{Duration, Instant},
|
||||||
};
|
};
|
||||||
|
|
||||||
use actix_web::dev::Service;
|
use actix_web::dev::Service;
|
||||||
use anyhow::{anyhow, Error};
|
use anyhow::{anyhow, Error};
|
||||||
use cadence::{MetricSink, NopMetricSink, StatsdClient};
|
|
||||||
use futures_util::{
|
use futures_util::{
|
||||||
future::try_join_all,
|
future::try_join_all,
|
||||||
stream::{self, LocalBoxStream},
|
stream::{self, LocalBoxStream},
|
||||||
|
@ -39,7 +37,6 @@ use self::fut::{analyze_dependencies, crawl_manifest};
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct Engine {
|
pub struct Engine {
|
||||||
metrics: Arc<StatsdClient>,
|
|
||||||
query_crate: Cache<QueryCrate, CrateName>,
|
query_crate: Cache<QueryCrate, CrateName>,
|
||||||
get_popular_crates: Cache<GetPopularCrates, ()>,
|
get_popular_crates: Cache<GetPopularCrates, ()>,
|
||||||
get_popular_repos: Cache<GetPopularRepos, ()>,
|
get_popular_repos: Cache<GetPopularRepos, ()>,
|
||||||
|
@ -49,8 +46,6 @@ pub struct Engine {
|
||||||
|
|
||||||
impl Engine {
|
impl Engine {
|
||||||
pub fn new(client: reqwest::Client, index: ManagedIndex) -> Engine {
|
pub fn new(client: reqwest::Client, index: ManagedIndex) -> Engine {
|
||||||
let metrics = Arc::new(StatsdClient::from_sink("engine", NopMetricSink));
|
|
||||||
|
|
||||||
let query_crate = Cache::new(QueryCrate::new(index), Duration::from_secs(10), 500);
|
let query_crate = Cache::new(QueryCrate::new(index), Duration::from_secs(10), 500);
|
||||||
let get_popular_crates = Cache::new(
|
let get_popular_crates = Cache::new(
|
||||||
GetPopularCrates::new(client.clone()),
|
GetPopularCrates::new(client.clone()),
|
||||||
|
@ -70,7 +65,6 @@ impl Engine {
|
||||||
);
|
);
|
||||||
|
|
||||||
Engine {
|
Engine {
|
||||||
metrics,
|
|
||||||
query_crate,
|
query_crate,
|
||||||
get_popular_crates,
|
get_popular_crates,
|
||||||
get_popular_repos,
|
get_popular_repos,
|
||||||
|
@ -78,10 +72,6 @@ impl Engine {
|
||||||
fetch_advisory_db,
|
fetch_advisory_db,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_metrics<M: MetricSink + Send + Sync + RefUnwindSafe + 'static>(&mut self, sink: M) {
|
|
||||||
self.metrics = Arc::new(StatsdClient::from_sink("engine", sink));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|
19
src/main.rs
19
src/main.rs
|
@ -1,18 +1,13 @@
|
||||||
#![deny(rust_2018_idioms)]
|
#![deny(rust_2018_idioms)]
|
||||||
#![warn(missing_debug_implementations)]
|
#![warn(missing_debug_implementations)]
|
||||||
|
|
||||||
use std::{
|
use std::{env, net::Ipv4Addr, time::Duration};
|
||||||
env,
|
|
||||||
net::{Ipv4Addr, UdpSocket},
|
|
||||||
time::Duration,
|
|
||||||
};
|
|
||||||
|
|
||||||
use actix_web::{
|
use actix_web::{
|
||||||
middleware::Logger,
|
middleware::Logger,
|
||||||
web::{self, ThinData},
|
web::{self, ThinData},
|
||||||
};
|
};
|
||||||
use actix_web_lab::middleware::NormalizePath;
|
use actix_web_lab::middleware::NormalizePath;
|
||||||
use cadence::{QueuingMetricSink, UdpMetricSink};
|
|
||||||
use reqwest::redirect::Policy as RedirectPolicy;
|
use reqwest::redirect::Policy as RedirectPolicy;
|
||||||
|
|
||||||
mod engine;
|
mod engine;
|
||||||
|
@ -26,14 +21,6 @@ use self::{engine::Engine, utils::index::ManagedIndex};
|
||||||
|
|
||||||
const DEPS_RS_UA: &str = "deps.rs";
|
const DEPS_RS_UA: &str = "deps.rs";
|
||||||
|
|
||||||
fn init_metrics() -> QueuingMetricSink {
|
|
||||||
let socket = UdpSocket::bind("0.0.0.0:0").unwrap();
|
|
||||||
socket.set_nonblocking(true).unwrap();
|
|
||||||
let host = ("127.0.0.1", 8125);
|
|
||||||
let sink = UdpMetricSink::from(host, socket).unwrap();
|
|
||||||
QueuingMetricSink::from(sink)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn init_tracing_subscriber() {
|
fn init_tracing_subscriber() {
|
||||||
use tracing::level_filters::LevelFilter;
|
use tracing::level_filters::LevelFilter;
|
||||||
use tracing_subscriber::{fmt, prelude::*, EnvFilter};
|
use tracing_subscriber::{fmt, prelude::*, EnvFilter};
|
||||||
|
@ -57,7 +44,6 @@ fn init_tracing_subscriber() {
|
||||||
async fn main() {
|
async fn main() {
|
||||||
dotenvy::dotenv().ok();
|
dotenvy::dotenv().ok();
|
||||||
init_tracing_subscriber();
|
init_tracing_subscriber();
|
||||||
let metrics = init_metrics();
|
|
||||||
|
|
||||||
let client = reqwest::Client::builder()
|
let client = reqwest::Client::builder()
|
||||||
.user_agent(DEPS_RS_UA)
|
.user_agent(DEPS_RS_UA)
|
||||||
|
@ -81,8 +67,7 @@ async fn main() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut engine = Engine::new(client.clone(), index);
|
let engine = Engine::new(client.clone(), index);
|
||||||
engine.set_metrics(metrics);
|
|
||||||
|
|
||||||
let server = actix_web::HttpServer::new(move || {
|
let server = actix_web::HttpServer::new(move || {
|
||||||
actix_web::App::new()
|
actix_web::App::new()
|
||||||
|
|
Loading…
Reference in a new issue