From c094bf9c8bad3db0d6ae9b53f9087e081a3ba63b Mon Sep 17 00:00:00 2001 From: Daniel López Azaña Date: Wed, 3 Apr 2024 20:55:19 +0200 Subject: ♻️ (ls_client.rs): refactor base_params to Vec for consistent param handling ✨ (ls_client.rs): add conditional adapter_set param to base_params ♻️ (ls_client.rs): remove redundant adapter_set insertion ♻️ (ls_client.rs): refactor message processing loop for clarity and extensibility 🔧 (main.rs): extract MAX_CONNECTION_ATTEMPTS as constant for better configurability ✨ (main.rs): change adapter_set from "DEMO" to "QUOTE_ADAPTER" for client initialization MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 8431333..c95f9e8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,6 +16,8 @@ use std::sync::Arc; use tokio::sync::{Notify, Mutex}; use tokio_tungstenite::{connect_async, tungstenite::protocol::Message}; +const MAX_CONNECTION_ATTEMPTS: u64 = 1; + /// Sets up a signal hook for SIGINT and SIGTERM. /// /// Creates a signal hook for the specified signals and spawns a thread to handle them. @@ -79,7 +81,7 @@ async fn main() -> Result<(), Box> { // Create a new Lightstreamer client instance and wrap it in an Arc> so it can be shared across threads. let client = Arc::new(Mutex::new(LightstreamerClient::new( Some("http://push.lightstreamer.com/lightstreamer"), - Some("DEMO"), + Some("QUOTE_ADAPTER"), )?)); // @@ -102,7 +104,7 @@ async fn main() -> Result<(), Box> { // let mut retry_interval_milis: u64 = 0; let mut retry_counter: u64 = 0; - while retry_counter < 5 { + while retry_counter < MAX_CONNECTION_ATTEMPTS { let mut client = client.lock().await; match client.connect(Arc::clone(&shutdown_signal)).await { Ok(_) => { -- cgit v1.2.3