From cc08631e8b01122ad0eabe4bbd9e6fbd9ceab092 Mon Sep 17 00:00:00 2001 From: Lance-Drane Date: Mon, 12 Aug 2024 17:44:41 -0400 Subject: [PATCH] add pre-commit config Signed-off-by: Lance-Drane --- .pre-commit-config.yaml | 33 +++++++++++++++++++++++++++++++++ README.md | 6 +++--- http-2-broker/src/main.rs | 5 ++++- 3 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..ee053db --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,33 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.5.0 + hooks: + - id: check-yaml + args: ['--unsafe'] + - id: check-toml + - id: end-of-file-fixer + - id: trailing-whitespace + - repo: local + hooks: + - id: fmt + name: fmt + description: Format files with cargo fmt. + entry: cargo fmt + language: system + types: [rust] + args: ["--"] + - id: cargo-check + name: cargo check + description: Check the package for errors. + entry: cargo check + language: system + types: [rust] + pass_filenames: false + - id: clippy + name: clippy + description: Lint rust sources + entry: cargo clippy + language: system + args: ["--", "-D", "warnings"] + types: [rust] + pass_filenames: false diff --git a/README.md b/README.md index 4f71bf1..8ce1d44 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Currently only supports AMQP 0-9-1 as the broker protocol but can potentially su The best way to install Rust is through [Rustup](https://www.rust-lang.org/tools/install). -You can format with `cargo fmt` and lint with `cargo clippy` +You can format with `cargo fmt` and lint with `cargo clippy` . There's also a pre-commit hook you can use ([installation instructions](https://pre-commit.com/#installation)) ## Application startup @@ -60,7 +60,7 @@ These instructions assume you are using the docker compose configuration and the 7) Click "publish_message". At this point the message should show up in the logs for both `http-2-broker` and `broker-2-http` . 8) On localhost:15673 `Queues and streams` section, blow up `Get messages`, set Ack mode to `Automatic ack`, click on `Get messages`, you should see your payload from step 6. -Congratulations, you have successfully simulated a publisher and a subscriber being able to talk to each other across 2 separate message brokers. +Congratulations, you have successfully simulated a publisher and a subscriber being able to talk to each other across 2 separate message brokers. ### Testing with INTERSECT-SDK directly @@ -78,4 +78,4 @@ Now it's advisable to [run some INTERSECT-SDK examples](https://github.com/INTER - one exchange for all messages (see `intersect_messaging.rs` to get name) - routing keys will match SDK naming schematics (SOS hierarchy, "." as separator, end with ".{userspace|lifecycle|events}") -- queue name will also match SDK naming schematics (might need to be careful here, there's a 128 character limit here). This can really be whatever but we need to construct the queue name as something idempotent, we don't really want to have a billion durable queues floating around. +- queue name will also match SDK naming schematics (might need to be careful here, there's a 128 character limit here). This can really be whatever but we need to construct the queue name as something idempotent, we don't really want to have a billion durable queues floating around. diff --git a/http-2-broker/src/main.rs b/http-2-broker/src/main.rs index c732c6c..35e8027 100644 --- a/http-2-broker/src/main.rs +++ b/http-2-broker/src/main.rs @@ -157,7 +157,10 @@ pub async fn main() { if exchange_result.is_err() { let err = exchange_result.unwrap_err(); tracing::error!("could not create exchange: {}", err); - connection.close().await.expect("Could not close connection after failed exchange creation"); + connection + .close() + .await + .expect("Could not close connection after failed exchange creation"); std::process::exit(1); } }