Skip to content

Commit a2863ff

Browse files
James Rayclaude
andcommitted
Apply rustfmt across runtime, channels, and tests
Pure formatting — `cargo fmt --all` reflowed long imports, async function signatures with multi-line return types, and a few expression-level chains that exceeded the 100-column wrap. No behavioral changes; `cargo test --workspace` still 169/0/0 and clippy stays clean with -D warnings. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent acbb2dc commit a2863ff

5 files changed

Lines changed: 87 additions & 46 deletions

File tree

crates/mx20022-channels/mx20022-channel-http/src/lib.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,10 @@ mod tests {
340340
use mx20022_channels::{InboundChannel, OutboundChannel, OutboundMessage};
341341
use tokio::sync::{mpsc, RwLock};
342342

343-
use super::{handle_post, HttpInboundChannel, HttpInboundConfig, HttpOutboundChannel, HttpOutboundConfig, InboundState};
343+
use super::{
344+
handle_post, HttpInboundChannel, HttpInboundConfig, HttpOutboundChannel,
345+
HttpOutboundConfig, InboundState,
346+
};
344347

345348
#[tokio::test]
346349
async fn inbound_handler_enqueues_message() {
@@ -399,7 +402,10 @@ mod tests {
399402
assert_eq!(resp.status(), StatusCode::ACCEPTED);
400403

401404
// Verify the message was queued.
402-
let msg = rx.recv().await.expect("should receive pre-shutdown message");
405+
let msg = rx
406+
.recv()
407+
.await
408+
.expect("should receive pre-shutdown message");
403409
assert_eq!(msg.raw, "<Document/>");
404410

405411
// Trigger graceful shutdown.

crates/mx20022-runtime/src/app.rs

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,10 @@ impl ParticipantRegistry {
790790
#[cfg(test)]
791791
registry.register("correlation-key-setter", build_correlation_key_setter);
792792
#[cfg(test)]
793-
registry.register("correlation-expectation-setter", build_correlation_expectation_setter);
793+
registry.register(
794+
"correlation-expectation-setter",
795+
build_correlation_expectation_setter,
796+
);
794797
registry
795798
}
796799

@@ -1089,7 +1092,13 @@ impl Participant for SlowParticipant {
10891092
fn name(&self) -> &str {
10901093
"slow"
10911094
}
1092-
async fn prepare(&self, _ctx: &mut Context) -> Result<mx20022_runtime_core::participant::Action, mx20022_runtime_core::participant::ParticipantError> {
1095+
async fn prepare(
1096+
&self,
1097+
_ctx: &mut Context,
1098+
) -> Result<
1099+
mx20022_runtime_core::participant::Action,
1100+
mx20022_runtime_core::participant::ParticipantError,
1101+
> {
10931102
tokio::time::sleep(Duration::from_millis(self.sleep_ms)).await;
10941103
Ok(mx20022_runtime_core::participant::Action::Prepared)
10951104
}
@@ -1124,8 +1133,10 @@ impl Participant for CorrelationKeySetter {
11241133
async fn prepare(
11251134
&self,
11261135
ctx: &mut Context,
1127-
) -> Result<mx20022_runtime_core::participant::Action, mx20022_runtime_core::participant::ParticipantError>
1128-
{
1136+
) -> Result<
1137+
mx20022_runtime_core::participant::Action,
1138+
mx20022_runtime_core::participant::ParticipantError,
1139+
> {
11291140
ctx.put(
11301141
"correlation.lookup_key",
11311142
CorrelationLookupKey {
@@ -1177,8 +1188,10 @@ impl Participant for CorrelationExpectationSetter {
11771188
async fn prepare(
11781189
&self,
11791190
ctx: &mut Context,
1180-
) -> Result<mx20022_runtime_core::participant::Action, mx20022_runtime_core::participant::ParticipantError>
1181-
{
1191+
) -> Result<
1192+
mx20022_runtime_core::participant::Action,
1193+
mx20022_runtime_core::participant::ParticipantError,
1194+
> {
11821195
ctx.put(
11831196
"correlation.expectation",
11841197
mx20022_store::Expectation {
@@ -1605,7 +1618,13 @@ participants = [
16051618
.expect("app should build");
16061619

16071620
let err = app
1608-
.process("timeout-pipeline", "TX-TO-1", "http-in", "pacs.008", "<Document/>")
1621+
.process(
1622+
"timeout-pipeline",
1623+
"TX-TO-1",
1624+
"http-in",
1625+
"pacs.008",
1626+
"<Document/>",
1627+
)
16091628
.await
16101629
.expect_err("should timeout");
16111630

@@ -1648,8 +1667,7 @@ participants = [
16481667

16491668
#[tokio::test]
16501669
async fn correlation_match_response_invoked_for_committed_transaction() {
1651-
let config =
1652-
RuntimeConfig::parse(CORRELATION_MATCH_CONFIG).expect("config should parse");
1670+
let config = RuntimeConfig::parse(CORRELATION_MATCH_CONFIG).expect("config should parse");
16531671
let app = RuntimeApp::from_config(&config)
16541672
.await
16551673
.expect("app should build");
@@ -1789,8 +1807,7 @@ participants = [
17891807
#[tokio::test]
17901808
async fn build_business_rule_validator_extracts_scheme() {
17911809
for scheme in &["fednow", "sepa", "cbpr"] {
1792-
let toml =
1793-
builder_config!("business-rule-validator", format!("scheme = '{}'", scheme));
1810+
let toml = builder_config!("business-rule-validator", format!("scheme = '{}'", scheme));
17941811
let config = RuntimeConfig::parse(&toml).expect("config should parse");
17951812
let app = RuntimeApp::from_config(&config).await;
17961813
assert!(
@@ -1828,10 +1845,7 @@ participants = [
18281845
for scope in &["global", "message_type", "source_channel"] {
18291846
let toml = builder_config!(
18301847
"rate-limiter",
1831-
format!(
1832-
"rate_per_second = 50.0, burst = 100.0, scope = '{}'",
1833-
scope
1834-
)
1848+
format!("rate_per_second = 50.0, burst = 100.0, scope = '{}'", scope)
18351849
);
18361850
let config = RuntimeConfig::parse(&toml).expect("config should parse");
18371851
let app = RuntimeApp::from_config(&config).await;
@@ -1918,10 +1932,7 @@ participants = [
19181932

19191933
#[tokio::test]
19201934
async fn build_routing_engine_rejects_rule_without_destination() {
1921-
let toml = builder_config!(
1922-
"routing-engine",
1923-
"rules = [{message_type = 'pacs.008'}]"
1924-
);
1935+
let toml = builder_config!("routing-engine", "rules = [{message_type = 'pacs.008'}]");
19251936
let config = RuntimeConfig::parse(&toml).expect("config should parse");
19261937
let err = match RuntimeApp::from_config(&config).await {
19271938
Ok(_) => panic!("rule without destination should fail"),
@@ -2116,8 +2127,7 @@ participants = [
21162127

21172128
#[tokio::test]
21182129
async fn unknown_participant_name_returns_error() {
2119-
let config =
2120-
RuntimeConfig::parse(UNKNOWN_PARTICIPANT_CONFIG).expect("config should parse");
2130+
let config = RuntimeConfig::parse(UNKNOWN_PARTICIPANT_CONFIG).expect("config should parse");
21212131
match RuntimeApp::from_config(&config).await {
21222132
Err(RuntimeBuildError::UnknownParticipant(name)) => {
21232133
assert_eq!(name, "nonexistent-participant");

crates/mx20022-runtime/src/engine.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -681,10 +681,7 @@ auth_bearer_token = "secret"
681681
fn pick_free_port() -> u16 {
682682
let listener =
683683
std::net::TcpListener::bind("127.0.0.1:0").expect("must bind ephemeral port");
684-
listener
685-
.local_addr()
686-
.expect("must read local addr")
687-
.port()
684+
listener.local_addr().expect("must read local addr").port()
688685
}
689686

690687
#[cfg(feature = "channel-http")]
@@ -721,8 +718,8 @@ participants = [{{ name = "message-logger" }}]
721718
async fn run_pipelines_returns_ok_when_shutdown_signals_immediately() {
722719
use std::sync::Arc;
723720

724-
use crate::app::RuntimeApp;
725721
use super::run_pipelines;
722+
use crate::app::RuntimeApp;
726723

727724
let port = pick_free_port();
728725
let config = runnable_config(port);
@@ -733,10 +730,12 @@ participants = [{{ name = "message-logger" }}]
733730
);
734731
// Already-resolved future = signal the engine to drain on first poll.
735732
let shutdown = async {};
736-
let result =
737-
tokio::time::timeout(std::time::Duration::from_secs(5), run_pipelines(app, config, shutdown))
738-
.await
739-
.expect("engine should exit before timeout");
733+
let result = tokio::time::timeout(
734+
std::time::Duration::from_secs(5),
735+
run_pipelines(app, config, shutdown),
736+
)
737+
.await
738+
.expect("engine should exit before timeout");
740739
assert!(result.is_ok(), "engine returned error: {:?}", result.err());
741740
}
742741

@@ -745,8 +744,8 @@ participants = [{{ name = "message-logger" }}]
745744
async fn run_pipelines_returns_no_supported_pipelines_when_no_inbound_starts() {
746745
use std::sync::Arc;
747746

748-
use crate::app::RuntimeApp;
749747
use super::{run_pipelines, EngineError};
748+
use crate::app::RuntimeApp;
750749

751750
let port = pick_free_port();
752751
let mut config = runnable_config(port);

crates/mx20022-runtime/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use mx20022_runtime::engine;
2121
use sha2::{Digest, Sha256};
2222
use tokio::sync::RwLock;
2323
use tracing_subscriber::reload::Handle;
24-
use tracing_subscriber::{EnvFilter, layer::SubscriberExt, util::SubscriberInitExt};
24+
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt, EnvFilter};
2525

2626
#[tokio::main]
2727
async fn main() {
@@ -220,7 +220,7 @@ async fn run(
220220
async fn shutdown_signal() {
221221
#[cfg(unix)]
222222
{
223-
use tokio::signal::unix::{SignalKind, signal};
223+
use tokio::signal::unix::{signal, SignalKind};
224224
let mut sigterm = match signal(SignalKind::terminate()) {
225225
Ok(stream) => stream,
226226
Err(error) => {

crates/mx20022-runtime/tests/e2e_pipeline.rs

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,13 @@ async fn e2e_process_pacs008_commits_and_persists_context() {
159159
.expect("app should build");
160160

161161
let report = app
162-
.process("e2e", "TX-E2E-1", "http-in", "pacs.008", pacs008_xml("MSG-E2E-1"))
162+
.process(
163+
"e2e",
164+
"TX-E2E-1",
165+
"http-in",
166+
"pacs.008",
167+
pacs008_xml("MSG-E2E-1"),
168+
)
163169
.await
164170
.expect("process should succeed");
165171

@@ -218,7 +224,12 @@ async fn e2e_multi_participant_commits_with_context_entries() {
218224
);
219225
// Neither participant should have errored
220226
for pr in &report.participant_results {
221-
assert!(pr.error.is_none(), "{} errored: {:?}", pr.participant, pr.error);
227+
assert!(
228+
pr.error.is_none(),
229+
"{} errored: {:?}",
230+
pr.participant,
231+
pr.error
232+
);
222233
}
223234

224235
let store = app.store_handle();
@@ -377,7 +388,13 @@ async fn e2e_unknown_pipeline_returns_error() {
377388
.expect("app should build");
378389

379390
let err = app
380-
.process("nonexistent", "TX-ERR-1", "http-in", "pacs.008", "<Document/>")
391+
.process(
392+
"nonexistent",
393+
"TX-ERR-1",
394+
"http-in",
395+
"pacs.008",
396+
"<Document/>",
397+
)
381398
.await
382399
.expect_err("should fail for unknown pipeline");
383400

@@ -400,10 +417,7 @@ async fn e2e_rejected_message_type_returns_error() {
400417
.expect_err("should fail for unsupported message type");
401418

402419
let msg = err.to_string();
403-
assert!(
404-
msg.contains("not accepted"),
405-
"unexpected error: {msg}"
406-
);
420+
assert!(msg.contains("not accepted"), "unexpected error: {msg}");
407421
}
408422

409423
#[tokio::test]
@@ -414,10 +428,22 @@ async fn e2e_multi_pipeline_routing() {
414428
.expect("app should build");
415429

416430
assert_eq!(app.pipeline_count().await, 2);
417-
assert!(app.accepts_message_type("pacs008-pipeline", "pacs.008").await);
418-
assert!(app.accepts_message_type("pacs002-pipeline", "pacs.002").await);
419-
assert!(!app.accepts_message_type("pacs008-pipeline", "pacs.002").await);
420-
assert!(!app.accepts_message_type("pacs002-pipeline", "pacs.008").await);
431+
assert!(
432+
app.accepts_message_type("pacs008-pipeline", "pacs.008")
433+
.await
434+
);
435+
assert!(
436+
app.accepts_message_type("pacs002-pipeline", "pacs.002")
437+
.await
438+
);
439+
assert!(
440+
!app.accepts_message_type("pacs008-pipeline", "pacs.002")
441+
.await
442+
);
443+
assert!(
444+
!app.accepts_message_type("pacs002-pipeline", "pacs.008")
445+
.await
446+
);
421447

422448
// Process through pipeline 1
423449
let report1 = app

0 commit comments

Comments
 (0)