Skip to content

Commit

Permalink
feat(repo): Added web-utils crate and added telemetry to all svc (#373)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xterminator authored Jan 12, 2025
1 parent 5cc0c08 commit 7e3c343
Show file tree
Hide file tree
Showing 47 changed files with 1,250 additions and 453 deletions.
68 changes: 51 additions & 17 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ thiserror = "2.0"

fuel-streams = { version = "0.0.16", path = "crates/fuel-streams" }
fuel-data-parser = { version = "0.0.16", path = "crates/fuel-data-parser" }
fuel-web-utils = { version = "0.0.16", path = "crates/fuel-web-utils" }
fuel-streams-core = { version = "0.0.16", path = "crates/fuel-streams-core" }
fuel-streams-macros = { version = "0.0.16", path = "crates/fuel-streams-macros" }
fuel-streams-nats = { version = "0.0.16", path = "crates/fuel-streams-nats" }
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,11 @@ run-publisher-testnet-profiling:

run-consumer: NATS_CORE_URL="localhost:4222"
run-consumer: NATS_PUBLISHER_URL="localhost:4223"
run-consumer: PORT="9003"
run-consumer:
cargo run --package sv-consumer --profile dev -- \
--nats-core-url $(NATS_CORE_URL) \
--port $(PORT) \
--nats-publisher-url $(NATS_PUBLISHER_URL)

# ------------------------------------------------------------
Expand All @@ -241,9 +243,11 @@ run-consumer:

run-consumer: NATS_URL="localhost:4222"
run-consumer: NATS_PUBLISHER_URL="localhost:4333"
run-consumer: PORT="9003"
run-consumer:
cargo run --package sv-consumer --profile dev -- \
--nats-url $(NATS_URL) \
--port $(PORT) \
--nats-publisher-url $(NATS_PUBLISHER_URL)

# ------------------------------------------------------------
Expand Down
55 changes: 55 additions & 0 deletions crates/fuel-web-utils/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
[package]
name = "fuel-web-utils"
description = "Fuel library for web utils"
authors = { workspace = true }
keywords = { workspace = true }
edition = { workspace = true }
homepage = { workspace = true }
license = { workspace = true }
repository = { workspace = true }
version = { workspace = true }
rust-version = { workspace = true }

[dependencies]
actix-cors = { workspace = true }
actix-server = { workspace = true }
actix-service = "2.0.2"
actix-web = { workspace = true }
anyhow = { workspace = true }
async-trait = { workspace = true }
chrono = { workspace = true }
derive_more = { version = "1.0", features = ["full"] }
displaydoc = { workspace = true }
dotenvy = { workspace = true }
elasticsearch = "8.15.0-alpha.1"
fuel-data-parser = { workspace = true }
fuel-streams-nats = { workspace = true, features = ["test-helpers"] }
futures = { workspace = true }
futures-util = { workspace = true }
jsonwebtoken = "9.3.0"
num_cpus = { workspace = true }
parking_lot = { version = "0.12", features = ["serde"] }
prometheus = { version = "0.13", features = ["process"] }
rand = { workspace = true }
rust_decimal = { version = "1.13" }
serde = { workspace = true }
serde_json = { workspace = true }
serde_prometheus = { version = "0.2" }
sysinfo = { version = "0.29" }
thiserror = "2.0"
time = { version = "0.3", features = ["serde"] }
tokio = { workspace = true }
tokio-util = "0.7.13"
tracing = { workspace = true }
tracing-actix-web = { workspace = true }
url = "2.5"
urlencoding = "2.1"
uuid = { version = "1.11.0", features = ["serde", "v4"] }

# in an individual package Cargo.toml
[package.metadata.cargo-machete]
ignored = ["fuel-data-parser"]

[features]
default = []
test-helpers = []
15 changes: 15 additions & 0 deletions crates/fuel-web-utils/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
pub mod server;
pub mod shutdown;
pub mod telemetry;

use std::sync::LazyLock;

pub static MAX_WORKERS: LazyLock<usize> = LazyLock::new(|| {
let available_cpus = num_cpus::get();
let default_threads = 2 * available_cpus;

dotenvy::var("MAX_WORKERS")
.ok()
.and_then(|val| val.parse().ok())
.unwrap_or(default_threads)
});
Loading

0 comments on commit 7e3c343

Please sign in to comment.