Skip to content

Commit 6735c1d

Browse files
Merge pull request #789 from Mark-Simulacrum/update-deps
Bump dependencies
2 parents 78250a7 + 1fd3a80 commit 6735c1d

File tree

11 files changed

+393
-485
lines changed

11 files changed

+393
-485
lines changed

Cargo.lock

Lines changed: 341 additions & 413 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ dotenv = "0.15"
3434
env_logger = "0.10.0"
3535
flate2 = "1"
3636
hmac = "0.12"
37-
http = "0.2"
38-
hyper = "0.14"
3937
indexmap = { version = "2.0.2", features = ["serde"] }
4038
lazy_static = "1.0"
4139
log = "0.4.6"
@@ -49,7 +47,7 @@ rand = "0.8"
4947
rayon = "1.10"
5048
regex = "1.0"
5149
remove_dir_all = "0.7"
52-
reqwest = { version = "0.11", features = ["blocking", "json"] }
50+
reqwest = { version = "0.12", features = ["blocking", "json"] }
5351
rusqlite = { version = "0.32.1", features = ["chrono", "functions", "bundled"] }
5452
rust_team_data = { git = "https://github.com/rust-lang/team" }
5553
rustwide = { version = "0.19.3", features = [
@@ -70,7 +68,7 @@ tokio = "1.24"
7068
toml = "0.8.6"
7169
url = { version = "2", features = ["serde"] }
7270
walkdir = "2"
73-
warp = "0.3"
71+
warp = { version = "0.4", features = ["server"] }
7472
zstd = "0.13.0"
7573

7674
[dev-dependencies]

src/server/api_types.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
use crate::config::Config;
22
use crate::prelude::*;
3-
use http::header::{HeaderValue, CONTENT_TYPE};
4-
use http::Response;
5-
use http::StatusCode;
6-
use hyper::Body;
73
use serde::Serialize;
84
use std::fmt;
95
use std::fmt::Display;
106
use std::str::FromStr;
7+
use warp::http::header::{HeaderValue, CONTENT_TYPE};
8+
use warp::http::StatusCode;
9+
use warp::reply::Response;
1110

1211
#[derive(Serialize, Deserialize)]
1312
#[serde(rename_all = "kebab-case")]
@@ -53,7 +52,7 @@ impl<T> ApiResponse<T> {
5352
}
5453

5554
impl<T: Serialize> ApiResponse<T> {
56-
pub(in crate::server) fn into_response(self) -> Fallible<Response<Body>> {
55+
pub(in crate::server) fn into_response(self) -> Fallible<Response> {
5756
let serialized = ::serde_json::to_vec(&self)?;
5857

5958
let mut resp = Response::new(serialized.into());
@@ -76,9 +75,9 @@ impl Display for CraterToken {
7675
}
7776

7877
impl FromStr for CraterToken {
79-
type Err = ::hyper::Error;
78+
type Err = warp::hyper::Error;
8079

81-
fn from_str(s: &str) -> ::hyper::Result<CraterToken> {
80+
fn from_str(s: &str) -> warp::hyper::Result<CraterToken> {
8281
Ok(CraterToken {
8382
token: s.to_owned(),
8483
})

src/server/auth.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ use crate::config::Config;
22
use crate::prelude::*;
33
use crate::server::github::{GitHub, GitHubApi};
44
use crate::server::{Data, GithubData, HttpError};
5-
use http::header::{HeaderMap, AUTHORIZATION, USER_AGENT};
65
use regex::Regex;
76
use rust_team_data::v1 as team_data;
87
use std::collections::{HashMap, HashSet};
98
use std::sync::{Arc, RwLock};
9+
use warp::http::header::{HeaderMap, AUTHORIZATION, USER_AGENT};
1010
use warp::{Filter, Rejection};
1111

1212
lazy_static! {

src/server/mod.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ use crate::server::agents::Agents;
1818
use crate::server::auth::ACL;
1919
use crate::server::github::{GitHub, GitHubApi};
2020
use crate::server::tokens::{BotTokens, Tokens};
21-
use http::{header::HeaderValue, Response};
22-
use hyper::Body;
2321
use metrics::Metrics;
2422
use std::collections::VecDeque;
2523
use std::net::SocketAddr;
2624
use std::sync::{Arc, Mutex};
2725
use std::time::Instant;
26+
use warp::http::header::HeaderValue;
27+
use warp::reply::Response;
2828
use warp::Filter;
2929

3030
lazy_static! {
@@ -132,15 +132,13 @@ pub fn run(config: Config, bind: SocketAddr) -> Fallible<()> {
132132
.or(routes::ui::routes(data))
133133
.unify(),
134134
)
135-
.map(
136-
|_guard: routes::agent::RequestGuard, mut resp: Response<Body>| {
137-
resp.headers_mut().insert(
138-
http::header::SERVER,
139-
HeaderValue::from_static(&SERVER_HEADER),
140-
);
141-
resp
142-
},
143-
);
135+
.map(|_guard: routes::agent::RequestGuard, mut resp: Response| {
136+
resp.headers_mut().insert(
137+
warp::http::header::SERVER,
138+
HeaderValue::from_static(&SERVER_HEADER),
139+
);
140+
resp
141+
});
144142

145143
let rt = tokio::runtime::Builder::new_multi_thread()
146144
.enable_all()

src/server/routes/agent.rs

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@ use crate::server::auth::{auth_filter, AuthDetails};
88
use crate::server::messages::Message;
99
use crate::server::{Data, GithubData, HttpError};
1010
use crossbeam_channel::Sender;
11-
use http::Response;
12-
use hyper::Body;
1311
use std::collections::HashMap;
1412
use std::sync::{Arc, Condvar, Mutex};
1513
use std::time::Instant;
14+
use warp::reply::Response;
1615
use warp::{Filter, Rejection};
1716

1817
#[derive(Deserialize)]
@@ -27,7 +26,7 @@ pub fn routes(
2726
data: Arc<Data>,
2827
mutex: Arc<Mutex<Data>>,
2928
github_data: Option<Arc<GithubData>>,
30-
) -> impl Filter<Extract = (Response<Body>,), Error = Rejection> + Clone {
29+
) -> impl Filter<Extract = (Response,), Error = Rejection> + Clone {
3130
let data_cloned = data.clone();
3231
let data_filter = warp::any().map(move || data_cloned.clone());
3332
let mutex_filter = warp::any().map(move || mutex.clone());
@@ -100,11 +99,7 @@ pub fn routes(
10099
.unify()
101100
}
102101

103-
fn endpoint_config(
104-
caps: Capabilities,
105-
data: Arc<Data>,
106-
auth: AuthDetails,
107-
) -> Fallible<Response<Body>> {
102+
fn endpoint_config(caps: Capabilities, data: Arc<Data>, auth: AuthDetails) -> Fallible<Response> {
108103
data.agents.add_capabilities(&auth.name, &caps)?;
109104

110105
Ok(ApiResponse::Success {
@@ -120,7 +115,7 @@ fn endpoint_next_experiment(
120115
mutex: Arc<Mutex<Data>>,
121116
github_data: Option<Arc<GithubData>>,
122117
auth: AuthDetails,
123-
) -> Fallible<Response<Body>> {
118+
) -> Fallible<Response> {
124119
//we need to make sure that Experiment::next executes uninterrupted
125120
let data = mutex.lock().unwrap();
126121
let next = Experiment::next(&data.db, &Assignee::Agent(auth.name))?;
@@ -181,7 +176,7 @@ fn endpoint_next_crate(
181176
experiment: String,
182177
data: Arc<Data>,
183178
_auth: AuthDetails,
184-
) -> Fallible<Response<Body>> {
179+
) -> Fallible<Response> {
185180
Ok(ApiResponse::Success {
186181
result: endpoint_next_crate_inner(experiment, data)?,
187182
}
@@ -332,7 +327,7 @@ fn endpoint_record_progress(
332327
result: ExperimentData<ProgressData>,
333328
data: Arc<Data>,
334329
_auth: AuthDetails,
335-
) -> Fallible<Response<Body>> {
330+
) -> Fallible<Response> {
336331
let start = Instant::now();
337332

338333
data.metrics
@@ -356,11 +351,7 @@ fn endpoint_record_progress(
356351
ret
357352
}
358353

359-
fn endpoint_heartbeat(
360-
id: WorkerInfo,
361-
data: Arc<Data>,
362-
auth: AuthDetails,
363-
) -> Fallible<Response<Body>> {
354+
fn endpoint_heartbeat(id: WorkerInfo, data: Arc<Data>, auth: AuthDetails) -> Fallible<Response> {
364355
data.agents.add_worker(id);
365356
if let Some(rev) = auth.git_revision {
366357
data.agents.set_git_revision(&auth.name, &rev)?;
@@ -376,7 +367,7 @@ fn endpoint_error(
376367
error: ExperimentData<HashMap<String, String>>,
377368
mutex: Arc<Mutex<Data>>,
378369
auth: AuthDetails,
379-
) -> Fallible<Response<Body>> {
370+
) -> Fallible<Response> {
380371
log::error!(
381372
"agent {} failed while running {}: {:?}",
382373
auth.name,
@@ -393,7 +384,7 @@ fn endpoint_error(
393384
Ok(ApiResponse::Success { result: true }.into_response()?)
394385
}
395386

396-
fn handle_results(resp: Fallible<Response<Body>>) -> Response<Body> {
387+
fn handle_results(resp: Fallible<Response>) -> Response {
397388
match resp {
398389
Ok(resp) => resp,
399390
Err(err) => ApiResponse::internal_error(err.to_string())
@@ -402,7 +393,7 @@ fn handle_results(resp: Fallible<Response<Body>>) -> Response<Body> {
402393
}
403394
}
404395

405-
async fn handle_errors(err: Rejection) -> Result<Response<Body>, Rejection> {
396+
async fn handle_errors(err: Rejection) -> Result<Response, Rejection> {
406397
let error = if let Some(compat) = err.find::<HttpError>() {
407398
Some(*compat)
408399
} else if err.is_not_found() {

src/server/routes/metrics.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
use crate::prelude::*;
22
use crate::server::agents::Agent;
33
use crate::server::Data;
4-
use http::{Response, StatusCode};
5-
use hyper::Body;
64
use prometheus::{Encoder, TextEncoder};
75
use std::sync::Arc;
6+
use warp::http::StatusCode;
7+
use warp::reply::Response;
88
use warp::{Filter, Rejection};
99

10-
pub fn routes(
11-
data: Arc<Data>,
12-
) -> impl Filter<Extract = (Response<Body>,), Error = Rejection> + Clone {
10+
pub fn routes(data: Arc<Data>) -> impl Filter<Extract = (Response,), Error = Rejection> + Clone {
1311
let data_filter = warp::any().map(move || data.clone());
1412

1513
warp::get()
@@ -28,7 +26,7 @@ pub fn routes(
2826
})
2927
}
3028

31-
fn endpoint_metrics(data: Arc<Data>) -> Fallible<Response<Body>> {
29+
fn endpoint_metrics(data: Arc<Data>) -> Fallible<Response> {
3230
data.metrics.update_agent_status(
3331
&data.db,
3432
&data.agents.all()?.iter().collect::<Vec<&Agent>>(),
@@ -39,5 +37,5 @@ fn endpoint_metrics(data: Arc<Data>) -> Fallible<Response<Body>> {
3937
let mut buffer = Vec::new();
4038
let families = prometheus::gather();
4139
TextEncoder::new().encode(&families, &mut buffer)?;
42-
Ok(Response::new(Body::from(buffer)))
40+
Ok(Response::new(String::from_utf8(buffer).unwrap().into()))
4341
}

src/server/routes/ui/agents.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ use crate::server::agents::AgentStatus;
33
use crate::server::routes::ui::{render_template, LayoutContext};
44
use crate::server::Data;
55
use chrono::SecondsFormat;
6-
use http::Response;
7-
use hyper::Body;
86
use std::sync::Arc;
7+
use warp::reply::Response;
98

109
#[derive(Serialize)]
1110
struct AgentData {
@@ -24,7 +23,7 @@ struct ListContext {
2423
agents: Vec<AgentData>,
2524
}
2625

27-
pub fn endpoint_list(data: Arc<Data>) -> Fallible<Response<Body>> {
26+
pub fn endpoint_list(data: Arc<Data>) -> Fallible<Response> {
2827
let mut agents = Vec::new();
2928
for agent in &data.agents.all()? {
3029
let (status_class, status_pretty, show_assigned) = match agent.status() {

src/server/routes/ui/experiments.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ use crate::prelude::*;
33
use crate::server::routes::ui::{render_template, LayoutContext};
44
use crate::server::{Data, HttpError};
55
use chrono::{Duration, SecondsFormat, Utc};
6-
use http::Response;
7-
use hyper::Body;
86
use std::sync::Arc;
7+
use warp::reply::Response;
98

109
#[derive(Serialize)]
1110
struct ExperimentData {
@@ -61,7 +60,7 @@ struct ListContext {
6160
experiments: Vec<ExperimentData>,
6261
}
6362

64-
pub fn endpoint_queue(data: Arc<Data>) -> Fallible<Response<Body>> {
63+
pub fn endpoint_queue(data: Arc<Data>) -> Fallible<Response> {
6564
let mut queued = Vec::new();
6665
let mut running = Vec::new();
6766
let mut needs_report = Vec::new();
@@ -146,7 +145,7 @@ fn humanize(duration: Duration) -> String {
146145
}
147146
}
148147

149-
pub fn endpoint_experiment(name: String, data: Arc<Data>) -> Fallible<Response<Body>> {
148+
pub fn endpoint_experiment(name: String, data: Arc<Data>) -> Fallible<Response> {
150149
if let Some(ex) = Experiment::get(&data.db, &name)? {
151150
let (completed_jobs, total_jobs) = ex.raw_progress(&data.db)?;
152151

src/server/routes/ui/mod.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
use crate::assets;
22
use crate::prelude::*;
33
use crate::server::{Data, HttpError};
4-
use http::header::{HeaderValue, CONTENT_TYPE};
5-
use http::{Response, StatusCode};
6-
use hyper::Body;
74
use serde::Serialize;
85
use std::sync::Arc;
6+
use warp::http::header::{HeaderValue, CONTENT_TYPE};
7+
use warp::http::StatusCode;
8+
use warp::reply::Response;
99
use warp::{Filter, Rejection};
1010

1111
mod agents;
@@ -24,9 +24,7 @@ impl LayoutContext {
2424
}
2525
}
2626

27-
pub fn routes(
28-
data: Arc<Data>,
29-
) -> impl Filter<Extract = (Response<Body>,), Error = Rejection> + Clone {
27+
pub fn routes(data: Arc<Data>) -> impl Filter<Extract = (Response,), Error = Rejection> + Clone {
3028
let data_filter = warp::any().map(move || data.clone());
3129

3230
let queue = warp::get()
@@ -68,7 +66,7 @@ pub fn routes(
6866
.unify()
6967
}
7068

71-
fn endpoint_assets(path: String) -> Fallible<Response<Body>> {
69+
fn endpoint_assets(path: String) -> Fallible<Response> {
7270
if let Ok(asset) = assets::load(&path) {
7371
if let Ok(content) = asset.content() {
7472
let mut resp = Response::new(content.into_owned().into());
@@ -88,7 +86,7 @@ struct ErrorContext {
8886
layout: LayoutContext,
8987
}
9088

91-
fn error_404() -> Fallible<Response<Body>> {
89+
fn error_404() -> Fallible<Response> {
9290
let mut resp = render_template(
9391
"ui/404.html",
9492
&ErrorContext {
@@ -100,7 +98,7 @@ fn error_404() -> Fallible<Response<Body>> {
10098
Ok(resp)
10199
}
102100

103-
fn error_500() -> Response<Body> {
101+
fn error_500() -> Response {
104102
// Ensure the 500 error page always renders
105103
let mut resp = match render_template(
106104
"ui/500.html",
@@ -120,7 +118,7 @@ fn error_500() -> Response<Body> {
120118
resp
121119
}
122120

123-
fn handle_results(resp: Fallible<Response<Body>>) -> Response<Body> {
121+
fn handle_results(resp: Fallible<Response>) -> Response {
124122
match resp {
125123
Ok(resp) => resp,
126124
Err(err) => {
@@ -144,7 +142,7 @@ fn handle_results(resp: Fallible<Response<Body>>) -> Response<Body> {
144142
}
145143
}
146144

147-
async fn handle_errors(err: Rejection) -> Result<Response<Body>, Rejection> {
145+
async fn handle_errors(err: Rejection) -> Result<Response, Rejection> {
148146
if err.is_not_found() {
149147
match error_404() {
150148
Ok(resp) => return Ok(resp),
@@ -159,7 +157,7 @@ async fn handle_errors(err: Rejection) -> Result<Response<Body>, Rejection> {
159157
Err(err)
160158
}
161159

162-
fn render_template<C: Serialize>(name: &str, context: &C) -> Fallible<Response<Body>> {
160+
fn render_template<C: Serialize>(name: &str, context: &C) -> Fallible<Response> {
163161
let mut resp = Response::new(assets::render_template(name, context)?.into());
164162
resp.headers_mut()
165163
.insert(CONTENT_TYPE, HeaderValue::from_static("text/html"));

0 commit comments

Comments
 (0)