Skip to content

Commit 04224a6

Browse files
committed
rustfmt
1 parent 1dbc769 commit 04224a6

File tree

11 files changed

+64
-61
lines changed

11 files changed

+64
-61
lines changed

engine/language_server/src/lib.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -47,24 +47,24 @@ pub fn run_server() -> anyhow::Result<()> {
4747

4848
{
4949
let playground_tx = playground_tx.clone();
50-
tokio_runtime.spawn(futures::future::join(
51-
async move {
52-
eprintln!("Playground server started");
53-
let server = playground_server::PlaygroundServer {
54-
app_state: playground_server::AppState {
55-
broadcast_rx,
56-
playground_tx: playground_tx.clone(),
57-
playground_port: port_picks.playground_port,
58-
proxy_port: port_picks.proxy_port,
59-
},
60-
};
61-
let fut = server.run(port_picks.playground_listener).await;
62-
eprintln!("Playground server finished");
63-
fut
64-
},
65-
cors_bypass_proxy::ProxyServer {}.run(port_picks.proxy_listener),
66-
));
67-
}
50+
tokio_runtime.spawn(futures::future::join(
51+
async move {
52+
eprintln!("Playground server started");
53+
let server = playground_server::PlaygroundServer {
54+
app_state: playground_server::AppState {
55+
broadcast_rx,
56+
playground_tx: playground_tx.clone(),
57+
playground_port: port_picks.playground_port,
58+
proxy_port: port_picks.proxy_port,
59+
},
60+
};
61+
let fut = server.run(port_picks.playground_listener).await;
62+
eprintln!("Playground server finished");
63+
fut
64+
},
65+
cors_bypass_proxy::ProxyServer {}.run(port_picks.proxy_listener),
66+
));
67+
}
6868

6969
eprintln!(
7070
"Playground started on: http://localhost:{}",

engine/language_server/src/server.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,6 @@ impl Server {
197197
let lsp_sender = server.connection.make_sender();
198198
let playground_tx = server.session.playground_tx.clone();
199199
server.args.tokio_handle.spawn(async move {
200-
201200
lsp_sender
202201
.send(Message::Notification(lsp_server::Notification::new(
203202
"baml/port".to_string(),
@@ -313,7 +312,10 @@ impl Server {
313312

314313
std::thread::spawn(|| {
315314
const DEADLOCK_WATCHDOG_INTERVAL: Duration = Duration::from_secs(10);
316-
tracing::info!("Starting deadlock watchdog (will poll every {:?})", DEADLOCK_WATCHDOG_INTERVAL);
315+
tracing::info!(
316+
"Starting deadlock watchdog (will poll every {:?})",
317+
DEADLOCK_WATCHDOG_INTERVAL
318+
);
317319
loop {
318320
std::thread::sleep(DEADLOCK_WATCHDOG_INTERVAL);
319321
// NB: this shows deadlocks detected since the _last_ check, not all current deadlocks.

engine/playground-server/src/bin/playground_barebones.rs

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use playground_server::{
2-
pick_ports, PortConfiguration, PlaygroundServer, AppState,
3-
LangServerToWasmMessage, FrontendMessage, PreLangServerToWasmMessage,
2+
pick_ports, AppState, FrontendMessage, LangServerToWasmMessage, PlaygroundServer,
3+
PortConfiguration, PreLangServerToWasmMessage,
44
};
55
use std::collections::HashMap;
66
use tokio::io::AsyncBufReadExt;
@@ -12,11 +12,14 @@ pub struct Playground2Server {
1212
}
1313

1414
impl Playground2Server {
15-
pub async fn run(self, listener: tokio::net::TcpListener) -> Result<(), Box<dyn std::error::Error + Send>> {
15+
pub async fn run(
16+
self,
17+
listener: tokio::net::TcpListener,
18+
) -> Result<(), Box<dyn std::error::Error + Send>> {
1619
let server = PlaygroundServer {
1720
app_state: self.app_state,
1821
};
19-
22+
2023
server.run(listener).await
2124
}
2225
}
@@ -38,8 +41,9 @@ pub async fn run_server() -> anyhow::Result<()> {
3841
let port_picks = pick_ports(PortConfiguration {
3942
base_port: 3900,
4043
max_attempts: 100,
41-
}).await?;
42-
44+
})
45+
.await?;
46+
4347
let server = Playground2Server {
4448
app_state: AppState {
4549
broadcast_rx,
@@ -75,14 +79,13 @@ pub async fn run_server() -> anyhow::Result<()> {
7579
}
7680
));
7781
tokio::time::sleep(std::time::Duration::from_secs(1)).await;
78-
let playground_message = LangServerToWasmMessage::PlaygroundMessage(
79-
FrontendMessage::run_test {
82+
let playground_message =
83+
LangServerToWasmMessage::PlaygroundMessage(FrontendMessage::run_test {
8084
function_name: "ExtractResume".to_string(),
8185
test_name: "vaibhav_resume".to_string(),
82-
}
83-
);
86+
});
8487
tracing::info!("Sending playground message: {:?}", playground_message);
85-
let _ = broadcast_tx.send(playground_message);
88+
let _ = broadcast_tx.send(playground_message);
8689
}
8790
PreLangServerToWasmMessage::FrontendMessage(msg) => {
8891
tracing::info!("Received frontend message: {:?}", msg);
@@ -98,26 +101,25 @@ pub async fn run_server() -> anyhow::Result<()> {
98101
tokio::spawn(async move {
99102
let stdin = tokio::io::stdin();
100103
let mut lines = tokio::io::BufReader::new(stdin).lines();
101-
104+
102105
loop {
103106
println!("Press enter to send test message");
104107
let Ok(Some(_line)) = lines.next_line().await else {
105108
break;
106109
};
107-
let playground_message = LangServerToWasmMessage::PlaygroundMessage(
108-
FrontendMessage::run_test {
110+
let playground_message =
111+
LangServerToWasmMessage::PlaygroundMessage(FrontendMessage::run_test {
109112
function_name: "ExtractResume".to_string(),
110113
test_name: "vaibhav_resume".to_string(),
111-
}
112-
);
114+
});
113115
tracing::info!("Sending playground message: {:?}", playground_message);
114-
let _ = broadcast_tx.send(playground_message);
116+
let _ = broadcast_tx.send(playground_message);
115117
}
116-
118+
117119
Ok::<(), anyhow::Error>(())
118120
});
119121

120122
let _ = playground_task.await?;
121123

122124
Ok(())
123-
}
125+
}

engine/playground-server/src/handlers/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ pub mod websocket_ws;
44

55
pub use ping::ping_handler;
66
pub use websocket_rpc::ws_rpc_handler;
7-
pub use websocket_ws::ws_handler;
7+
pub use websocket_ws::ws_handler;

engine/playground-server/src/handlers/ping.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ pub async fn ping_handler(extract::Query(query): extract::Query<PingQuery>) -> R
3131
}
3232
_ => format!("{response}\n").into_response(),
3333
}
34-
}
34+
}

engine/playground-server/src/handlers/websocket_rpc.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,12 @@ use crate::{definitions::PreLangServerToWasmMessage, server::AppState};
1111
pub async fn ws_rpc_handler(
1212
ws: WebSocketUpgrade,
1313
State(state): State<AppState>,
14-
) -> impl IntoResponse
15-
{
14+
) -> impl IntoResponse {
1615
ws.on_upgrade(|ws| async move { handle_rpc_websocket(ws, state).await })
1716
}
1817

1918
/// Handles all playground RPC commands over the WebSocket connection.
20-
pub async fn handle_rpc_websocket(ws: axum::extract::ws::WebSocket, state: AppState)
21-
{
19+
pub async fn handle_rpc_websocket(ws: axum::extract::ws::WebSocket, state: AppState) {
2220
let (mut ws_tx, mut ws_rx) = ws.split();
2321
while let Some(Ok(msg)) = ws_rx.next().await {
2422
if let Ok(msg) = msg.to_text() {
@@ -34,9 +32,13 @@ pub async fn handle_rpc_websocket(ws: axum::extract::ws::WebSocket, state: AppSt
3432
"rpcId": rpc_id,
3533
"data": { "ok": true }
3634
});
37-
if let Err(e) = state.playground_tx.send(PreLangServerToWasmMessage::WasmIsInitialized)
35+
if let Err(e) = state
36+
.playground_tx
37+
.send(PreLangServerToWasmMessage::WasmIsInitialized)
3838
{
39-
tracing::error!("Failed to send INITIALIZED message to language-server: {e}");
39+
tracing::error!(
40+
"Failed to send INITIALIZED message to language-server: {e}"
41+
);
4042
}
4143
tracing::info!("Sent INITIALIZED message to language-server");
4244
let _ = ws_tx.send(Message::text(response.to_string())).await;
@@ -83,4 +85,4 @@ pub async fn handle_rpc_websocket(ws: axum::extract::ws::WebSocket, state: AppSt
8385
}
8486
}
8587
}
86-
}
88+
}

engine/playground-server/src/handlers/websocket_ws.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,11 @@ use futures::{SinkExt, StreamExt};
66

77
use crate::server::AppState;
88

9-
pub async fn ws_handler(ws: WebSocketUpgrade, State(state): State<AppState>) -> impl IntoResponse
10-
{
9+
pub async fn ws_handler(ws: WebSocketUpgrade, State(state): State<AppState>) -> impl IntoResponse {
1110
ws.on_upgrade(|ws| async move { start_client_connection(ws, state).await })
1211
}
1312

14-
pub async fn start_client_connection(ws: axum::extract::ws::WebSocket, state: AppState)
15-
{
13+
pub async fn start_client_connection(ws: axum::extract::ws::WebSocket, state: AppState) {
1614
tracing::info!("axum listening on /ws");
1715
let (mut ws_tx, mut ws_rx) = ws.split();
1816
let mut rx = state.broadcast_rx;
@@ -51,4 +49,4 @@ pub async fn start_client_connection(ws: axum::extract::ws::WebSocket, state: Ap
5149
}
5250
}
5351
});
54-
}
52+
}

engine/playground-server/src/port_picker.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ pub async fn pick_ports(config: PortConfiguration) -> anyhow::Result<PortPicks>
3333
"Failed to find an available port after {} attempts",
3434
config.max_attempts
3535
))
36-
}
36+
}

engine/playground-server/src/server.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use anyhow::Context;
12
use axum::{routing::get, Router};
23
use flate2::read::GzDecoder;
34
use sha2::{Digest, Sha256};
@@ -7,10 +8,8 @@ use std::time::Duration;
78
use tar::Archive;
89
use tokio::{net::TcpListener, sync::broadcast};
910
use tower_http::services::ServeDir;
10-
use anyhow::Context;
11-
12-
use crate::definitions::{PreLangServerToWasmMessage, LangServerToWasmMessage};
1311

12+
use crate::definitions::{LangServerToWasmMessage, PreLangServerToWasmMessage};
1413

1514
#[derive(Debug)]
1615
pub struct AppState {
@@ -270,4 +269,4 @@ async fn verify_sha256_checksum(
270269

271270
tracing::info!("SHA256 checksum verification passed");
272271
Ok(())
273-
}
272+
}

engine/tools/src/bin/language-server-hot-reload.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,4 +244,4 @@ async fn main() -> Result<()> {
244244
reloader.run(args).await?;
245245

246246
Ok(())
247-
}
247+
}

0 commit comments

Comments
 (0)