Skip to content

Commit 9becf29

Browse files
committed
Upgrade to axum 0.8
1 parent 119ceab commit 9becf29

File tree

4 files changed

+23
-57
lines changed

4 files changed

+23
-57
lines changed

ui/Cargo.lock

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

ui/Cargo.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@ fork-bomb-prevention = []
1010

1111
[dependencies]
1212
asm-cleanup = { path = "../compiler/base/asm-cleanup" }
13-
async-trait = "0.1.52"
14-
axum = { version = "0.7", features = ["ws"] }
15-
axum-extra = { version = "0.9.0", features = ["typed-header"] }
13+
axum = { version = "0.8", features = ["ws"] }
14+
axum-extra = { version = "0.10", features = ["typed-header"] }
1615
dotenv = "0.15.0"
1716
futures = "0.3.21"
1817
octocrab = "0.42"

ui/src/server_axum.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use crate::{
77
request_database::Handle,
88
Config, GhToken, MetricsToken, WebSocketConfig,
99
};
10-
use async_trait::async_trait;
1110
use axum::{
1211
body::Body,
1312
extract::{self, ws::WebSocketUpgrade, Extension, Path},
@@ -100,7 +99,7 @@ pub(crate) async fn serve(config: Config) {
10099
.route("/meta/versions", get(meta_versions))
101100
.route("/meta/gist", post(meta_gist_create))
102101
.route("/meta/gist/", post(meta_gist_create)) // compatibility with lax frontend code
103-
.route("/meta/gist/:id", get(meta_gist_get))
102+
.route("/meta/gist/{id}", get(meta_gist_get))
104103
.route("/metrics", get(metrics))
105104
.route("/websocket", get(websocket))
106105
.route("/nowebsocket", post(nowebsocket))
@@ -712,7 +711,6 @@ enum CacheVersionsError {
712711
Shutdown { source: coordinator::Error },
713712
}
714713

715-
#[async_trait]
716714
impl<S> extract::FromRequestParts<S> for MetricsAuthorization
717715
where
718716
S: Send + Sync,
@@ -756,7 +754,6 @@ impl IntoResponse for Error {
756754
/// error and format it using our expected JSON error object.
757755
struct Json<T>(T);
758756

759-
#[async_trait]
760757
impl<T, S> extract::FromRequest<S> for Json<T>
761758
where
762759
T: serde::de::DeserializeOwned,

ui/src/server_axum/websocket.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ async fn handle_core(
380380
// browser disconnected
381381
break;
382382
}
383-
Some(Ok(Message::Text(txt))) => handle_msg(txt, &tx, &mut manager, &mut active_executions, &db).await,
383+
Some(Ok(Message::Text(txt))) => handle_msg(&txt, &tx, &mut manager, &mut active_executions, &db).await,
384384
Some(Ok(_)) => {
385385
// unknown message type
386386
continue;
@@ -507,7 +507,7 @@ fn response_to_message(response: MessageResponse) -> Message {
507507
const LAST_CHANCE_ERROR: &str =
508508
r#"{ "type": "WEBSOCKET_ERROR", "error": "Unable to serialize JSON" }"#;
509509
let resp = serde_json::to_string(&response).unwrap_or_else(|_| LAST_CHANCE_ERROR.into());
510-
Message::Text(resp)
510+
Message::Text(resp.into())
511511
}
512512

513513
async fn handle_idle(manager: &mut CoordinatorManager, tx: &ResponseTx) -> ControlFlow<()> {
@@ -528,22 +528,22 @@ async fn handle_idle(manager: &mut CoordinatorManager, tx: &ResponseTx) -> Contr
528528
type ActiveExecutionInfo = (CancellationToken, Option<mpsc::Sender<String>>);
529529

530530
async fn handle_msg(
531-
txt: String,
531+
txt: &str,
532532
tx: &ResponseTx,
533533
manager: &mut CoordinatorManager,
534534
active_executions: &mut BTreeMap<i64, ActiveExecutionInfo>,
535535
db: &Handle,
536536
) {
537537
use WSMessageRequest::*;
538538

539-
let msg = serde_json::from_str(&txt).context(DeserializationSnafu);
539+
let msg = serde_json::from_str(txt).context(DeserializationSnafu);
540540

541541
match msg {
542542
Ok(ExecuteRequest { payload, meta }) => {
543543
let token = CancellationToken::new();
544544
let (execution_tx, execution_rx) = mpsc::channel(8);
545545

546-
let guard = db.clone().start_with_guard("ws.Execute", &txt).await;
546+
let guard = db.clone().start_with_guard("ws.Execute", txt).await;
547547

548548
active_executions.insert(meta.sequence_number, (token.clone(), Some(execution_tx)));
549549

0 commit comments

Comments
 (0)