Skip to content

Commit 25ffb54

Browse files
committed
cargo fmt
1 parent 1ed624d commit 25ffb54

File tree

8 files changed

+49
-55
lines changed

8 files changed

+49
-55
lines changed

service/src/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ pub struct AppState {
3232
}
3333

3434
impl AppState {
35-
pub fn new(app_config: Config, db: &Arc<DatabaseConnection>, sse_manager: Arc<sse::Manager>) -> Self {
35+
pub fn new(
36+
app_config: Config,
37+
db: &Arc<DatabaseConnection>,
38+
sse_manager: Arc<sse::Manager>,
39+
) -> Self {
3640
Self {
3741
database_connection: Arc::clone(db),
3842
config: app_config,

sse-test-client/src/api_client.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,7 @@ impl ApiClient {
5757
})
5858
}
5959

60-
async fn get_user_organizations(
61-
&self,
62-
session_cookie: &str,
63-
user_id: &str,
64-
) -> Result<Value> {
60+
async fn get_user_organizations(&self, session_cookie: &str, user_id: &str) -> Result<Value> {
6561
let url = format!("{}/users/{}/organizations", self.base_url, user_id);
6662

6763
let response = self
@@ -75,8 +71,15 @@ impl ApiClient {
7571

7672
if !response.status().is_success() {
7773
let status = response.status();
78-
let body = response.text().await.unwrap_or_else(|_| "Unable to read response body".to_string());
79-
anyhow::bail!("Failed to get organizations: {} - Response: {}", status, body);
74+
let body = response
75+
.text()
76+
.await
77+
.unwrap_or_else(|_| "Unable to read response body".to_string());
78+
anyhow::bail!(
79+
"Failed to get organizations: {} - Response: {}",
80+
status,
81+
body
82+
);
8083
}
8184

8285
let api_response: Value = response.json().await.context("Failed to parse response")?;

sse-test-client/src/auth.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,10 @@ pub async fn login(
6363

6464
if !response.status().is_success() {
6565
let status = response.status();
66-
let body = response.text().await.unwrap_or_else(|_| "Unable to read response body".to_string());
66+
let body = response
67+
.text()
68+
.await
69+
.unwrap_or_else(|_| "Unable to read response body".to_string());
6770
anyhow::bail!("Login failed: {} - Response: {}", status, body);
6871
}
6972

sse-test-client/src/main.rs

Lines changed: 18 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -151,30 +151,18 @@ async fn main() -> Result<()> {
151151

152152
match cli.scenario {
153153
ScenarioChoice::ConnectionTest => {
154-
results.push(
155-
scenarios::test_connection(
156-
&user1,
157-
&user2,
158-
&mut sse1,
159-
&mut sse2,
160-
)
161-
.await?,
162-
);
154+
results.push(scenarios::test_connection(&user1, &user2, &mut sse1, &mut sse2).await?);
163155
}
164156
ScenarioChoice::ForceLogoutTest => {
165157
results.push(
166-
scenarios::test_force_logout(
167-
&user1,
168-
&user2,
169-
&api_client,
170-
&mut sse1,
171-
&mut sse2,
172-
)
173-
.await?,
158+
scenarios::test_force_logout(&user1, &user2, &api_client, &mut sse1, &mut sse2)
159+
.await?,
174160
);
175161
}
176162
ScenarioChoice::ActionCreate => {
177-
let env = test_env.as_ref().expect("Test environment required for ActionCreate");
163+
let env = test_env
164+
.as_ref()
165+
.expect("Test environment required for ActionCreate");
178166
results.push(
179167
scenarios::test_action_create(
180168
&user1,
@@ -188,7 +176,9 @@ async fn main() -> Result<()> {
188176
);
189177
}
190178
ScenarioChoice::ActionUpdate => {
191-
let env = test_env.as_ref().expect("Test environment required for ActionUpdate");
179+
let env = test_env
180+
.as_ref()
181+
.expect("Test environment required for ActionUpdate");
192182
results.push(
193183
scenarios::test_action_update(
194184
&user1,
@@ -202,7 +192,9 @@ async fn main() -> Result<()> {
202192
);
203193
}
204194
ScenarioChoice::ActionDelete => {
205-
let env = test_env.as_ref().expect("Test environment required for ActionDelete");
195+
let env = test_env
196+
.as_ref()
197+
.expect("Test environment required for ActionDelete");
206198
results.push(
207199
scenarios::test_action_delete(
208200
&user1,
@@ -216,26 +208,14 @@ async fn main() -> Result<()> {
216208
);
217209
}
218210
ScenarioChoice::All => {
211+
results.push(scenarios::test_connection(&user1, &user2, &mut sse1, &mut sse2).await?);
219212
results.push(
220-
scenarios::test_connection(
221-
&user1,
222-
&user2,
223-
&mut sse1,
224-
&mut sse2,
225-
)
226-
.await?,
227-
);
228-
results.push(
229-
scenarios::test_force_logout(
230-
&user1,
231-
&user2,
232-
&api_client,
233-
&mut sse1,
234-
&mut sse2,
235-
)
236-
.await?,
213+
scenarios::test_force_logout(&user1, &user2, &api_client, &mut sse1, &mut sse2)
214+
.await?,
237215
);
238-
let env = test_env.as_ref().expect("Test environment required for All scenarios");
216+
let env = test_env
217+
.as_ref()
218+
.expect("Test environment required for All scenarios");
239219
results.push(
240220
scenarios::test_action_create(
241221
&user1,

sse-test-client/src/scenarios.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,10 @@ pub async fn test_connection(
300300
);
301301

302302
// Wait a bit to ensure connections are stable
303-
println!("{} Waiting 2 seconds to verify connections stay alive...", "→".blue());
303+
println!(
304+
"{} Waiting 2 seconds to verify connections stay alive...",
305+
"→".blue()
306+
);
304307
tokio::time::sleep(Duration::from_secs(2)).await;
305308

306309
println!("{} Connections remain stable", "✓".green());
@@ -313,4 +316,3 @@ pub async fn test_connection(
313316
duration: start.elapsed(),
314317
})
315318
}
316-

sse/src/connection.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,10 @@ impl ConnectionRegistry {
6363
// Insert into primary storage
6464
self.connections.insert(
6565
connection_id.clone(),
66-
ConnectionInfo { user_id: user_id.clone(), sender },
66+
ConnectionInfo {
67+
user_id: user_id.clone(),
68+
sender,
69+
},
6770
);
6871

6972
// Update secondary index

sse/src/manager.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,7 @@ impl Manager {
3232

3333
/// Unregister a connection by ID
3434
pub fn unregister_connection(&self, connection_id: &ConnectionId) {
35-
debug!(
36-
"Unregistering SSE connection {}",
37-
connection_id.as_str()
38-
);
35+
debug!("Unregistering SSE connection {}", connection_id.as_str());
3936
self.registry.unregister(connection_id);
4037
}
4138

web/src/sse/handler.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ pub(crate) async fn sse_handler(
1919
let (tx, mut rx) = mpsc::unbounded_channel();
2020

2121
// Register returns the connection_id (convert domain::Id to String)
22-
let connection_id = app_state.sse_manager.register_connection(user.id.to_string(), tx);
22+
let connection_id = app_state
23+
.sse_manager
24+
.register_connection(user.id.to_string(), tx);
2325

2426
let manager = app_state.sse_manager.clone();
2527
let user_id = user.id;

0 commit comments

Comments
 (0)