diff --git a/.env.sample b/.env.sample index c111ace9..43760dff 100644 --- a/.env.sample +++ b/.env.sample @@ -9,6 +9,7 @@ AWS_ENDPOINT_URL=http://localhost:4566 AWS_REGION=us-east-1 AWS_S3_ENABLED=false AWS_S3_BUCKET_NAME=fuel-streams-local +STORAGE_MAX_RETRIES=5 # NATS Configuration NATS_URL=nats://localhost:4222 diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 89f4fd0e..7245f0fa 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -247,16 +247,16 @@ jobs: tool: cargo-nextest locked: true - - name: Start Nats + - name: Start Docker run: | - make start-nats + make start-docker - name: Run tests run: make test PACKAGE=${{ matrix.package }} PROFILE=ci - - name: Stop Nats + - name: Stop Docker if: always() - run: make stop-nats + run: make stop-docker build: needs: install-deps diff --git a/Cargo.lock b/Cargo.lock index 2b4ed8ef..0cbb7f53 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4164,6 +4164,7 @@ version = "0.0.13" dependencies = [ "anyhow", "displaydoc", + "dotenvy", "fuel-core", "fuel-data-parser", "fuel-streams-core", diff --git a/crates/fuel-streams-executors/Cargo.toml b/crates/fuel-streams-executors/Cargo.toml index 988ea1df..98c0f71b 100644 --- a/crates/fuel-streams-executors/Cargo.toml +++ b/crates/fuel-streams-executors/Cargo.toml @@ -14,6 +14,7 @@ publish = false [dependencies] anyhow = { workspace = true } displaydoc = { workspace = true } +dotenvy = { workspace = true } fuel-core = { workspace = true } fuel-data-parser = { workspace = true, features = ["test-helpers"] } fuel-streams-core = { workspace = true, features = ["test-helpers"] } diff --git a/crates/fuel-streams-executors/src/lib.rs b/crates/fuel-streams-executors/src/lib.rs index 38620909..d5fa6a36 100644 --- a/crates/fuel-streams-executors/src/lib.rs +++ b/crates/fuel-streams-executors/src/lib.rs @@ -7,7 +7,6 @@ pub mod transactions; pub mod utxos; use std::{ - env, marker::PhantomData, sync::{Arc, LazyLock}, }; @@ -21,7 +20,7 @@ use tokio::task::JoinHandle; pub static PUBLISHER_MAX_THREADS: LazyLock = LazyLock::new(|| { let available_cpus = num_cpus::get(); - env::var("PUBLISHER_MAX_THREADS") + dotenvy::var("PUBLISHER_MAX_THREADS") .ok() .and_then(|val| val.parse().ok()) .unwrap_or(available_cpus) diff --git a/crates/fuel-streams-storage/src/retry.rs b/crates/fuel-streams-storage/src/retry.rs index 814aa4f4..f50f25fb 100644 --- a/crates/fuel-streams-storage/src/retry.rs +++ b/crates/fuel-streams-storage/src/retry.rs @@ -1,7 +1,14 @@ -use std::{future::Future, time::Duration}; +use std::{future::Future, sync::LazyLock, time::Duration}; use tracing; +pub static STORAGE_MAX_RETRIES: LazyLock = LazyLock::new(|| { + dotenvy::var("STORAGE_MAX_RETRIES") + .ok() + .and_then(|val| val.parse().ok()) + .unwrap_or(5) +}); + #[derive(Debug, Clone)] pub struct RetryConfig { pub max_retries: u32, @@ -11,7 +18,7 @@ pub struct RetryConfig { impl Default for RetryConfig { fn default() -> Self { Self { - max_retries: 3, + max_retries: *STORAGE_MAX_RETRIES as u32, initial_backoff: Duration::from_millis(100), } } diff --git a/crates/sv-consumer/src/main.rs b/crates/sv-consumer/src/main.rs index 163e9408..5c5f0653 100644 --- a/crates/sv-consumer/src/main.rs +++ b/crates/sv-consumer/src/main.rs @@ -132,7 +132,7 @@ async fn setup_nats( pub static CONSUMER_MAX_THREADS: LazyLock = LazyLock::new(|| { let available_cpus = num_cpus::get(); - env::var("CONSUMER_MAX_THREADS") + dotenvy::var("CONSUMER_MAX_THREADS") .ok() .and_then(|val| val.parse().ok()) .unwrap_or(available_cpus)