diff --git a/Cargo.lock b/Cargo.lock index 39e0a29..af9799b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -332,13 +332,13 @@ version = "0.1.0" dependencies = [ "async-trait", "env", - "errors", "futures-util", "lapin", "mockall", "opentelemetry", "serde", "serde_json", + "thiserror", "tokio", "traces", "tracing", @@ -455,19 +455,20 @@ dependencies = [ [[package]] name = "async-stream" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dad5c83079eae9969be7fadefe640a1c566901f05ff91ab221de4b6f68d9507e" +checksum = "ad445822218ce64be7a341abfb0b1ea43b5c23aa83902542a4542e78309d8e5e" dependencies = [ "async-stream-impl", "futures-core", + "pin-project-lite", ] [[package]] name = "async-stream-impl" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10f203db73a71dfa2fb6dd22763990fa26f3d2625a6da2da900d23b87d26be27" +checksum = "e4655ae1a7b0cdf149156f780c5bf3f1352bc53cbd9e0a361a7ef7b22947e965" dependencies = [ "proc-macro2", "quote", @@ -806,9 +807,9 @@ dependencies = [ [[package]] name = "axum" -version = "0.6.6" +version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e246206a63c9830e118d12c894f56a82033da1a2361f5544deeee3df85c99d9" +checksum = "2fb79c228270dcf2426e74864cabc94babb5dbab01a4314e702d2f16540e1591" dependencies = [ "async-trait", "axum-core", @@ -1123,9 +1124,9 @@ dependencies = [ [[package]] name = "cxx" -version = "1.0.90" +version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90d59d9acd2a682b4e40605a242f6670eaa58c5957471cbf85e8aa6a0b97a5e8" +checksum = "86d3488e7665a7a483b57e25bdd90d0aeb2bc7608c8d0346acf2ad3f1caf1d62" dependencies = [ "cc", "cxxbridge-flags", @@ -1135,9 +1136,9 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.90" +version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebfa40bda659dd5c864e65f4c9a2b0aff19bea56b017b9b77c73d3766a453a38" +checksum = "48fcaf066a053a41a81dfb14d57d99738b767febb8b735c3016e469fac5da690" dependencies = [ "cc", "codespan-reporting", @@ -1150,15 +1151,15 @@ dependencies = [ [[package]] name = "cxxbridge-flags" -version = "1.0.90" +version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "457ce6757c5c70dc6ecdbda6925b958aae7f959bda7d8fb9bde889e34a09dc03" +checksum = "a2ef98b8b717a829ca5603af80e1f9e2e48013ab227b68ef37872ef84ee479bf" [[package]] name = "cxxbridge-macro" -version = "1.0.90" +version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebf883b7aacd7b2aeb2a7b338648ee19f57c140d4ee8e52c68979c6b2f7f2263" +checksum = "086c685979a698443656e5cf7856c95c642295a38599f12fb1ff76fb28d19892" dependencies = [ "proc-macro2", "quote", @@ -1330,16 +1331,9 @@ version = "0.1.0" dependencies = [ "base64 0.13.1", "dotenvy", - "errors", "secrets-manager", - "tracing", -] - -[[package]] -name = "errors" -version = "0.1.0" -dependencies = [ "thiserror", + "tracing", ] [[package]] @@ -1637,10 +1631,10 @@ dependencies = [ "async-trait", "deadpool-postgres", "env", - "errors", "httpw", "lapin", "paho-mqtt", + "thiserror", "tracing", ] @@ -1676,9 +1670,9 @@ dependencies = [ [[package]] name = "http" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75f43d41e26995c17e71ee126451dd3941010b0514a81a9d11f3b341debc2399" +checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482" dependencies = [ "bytes", "fnv", @@ -2000,7 +1994,7 @@ name = "logging" version = "0.1.0" dependencies = [ "env", - "errors", + "thiserror", "tracing", "tracing-bunyan-formatter", "tracing-log", @@ -2033,7 +2027,6 @@ name = "metrics" version = "0.1.0" dependencies = [ "env", - "errors", "opentelemetry", "opentelemetry-otlp", "tokio", @@ -2049,8 +2042,8 @@ dependencies = [ "deadpool-postgres", "deadpool-sqlite", "env", - "errors", "logging", + "thiserror", "tracing", ] @@ -2087,14 +2080,14 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5d732bc30207a6423068df043e3d02e0735b155ad7ce1a6f76fe2baa5b158de" +checksum = "5b9d9a46eff5b4ff64b45a9e316a6d1e0bc719ef429cbec4dc630684212bfdf9" dependencies = [ "libc", "log", "wasi", - "windows-sys 0.42.0", + "windows-sys 0.45.0", ] [[package]] @@ -2131,13 +2124,13 @@ dependencies = [ "async-trait", "bytes", "env", - "errors", "futures-util", "mockall", "opentelemetry", "paho-mqtt", "serde", "serde_json", + "thiserror", "tokio", "traces", "tracing", @@ -2224,9 +2217,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.17.0" +version = "1.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66" +checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" [[package]] name = "openssl" @@ -3034,9 +3027,9 @@ dependencies = [ "async-trait", "aws-config", "aws-sdk-secretsmanager", - "errors", "mockall", "serde_json", + "thiserror", "tokio", "tracing", ] @@ -3170,9 +3163,9 @@ checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de" [[package]] name = "slab" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4614a76b2a8be0058caa9dbbaf66d988527d86d003c11a94fbd335d7661edcef" +checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" dependencies = [ "autocfg", ] @@ -3215,7 +3208,7 @@ dependencies = [ "deadpool-postgres", "deadpool-sqlite", "env", - "errors", + "thiserror", "tokio-postgres", "tracing", ] @@ -3326,9 +3319,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.17" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a561bf4617eebd33bca6434b988f39ed798e527f51a1e797d0ee4f61c0a38376" +checksum = "53250a3b3fed8ff8fd988587d8925d26a83ac3845d9e03b220b37f34c2b8d6c2" dependencies = [ "itoa", "serde", @@ -3344,9 +3337,9 @@ checksum = "2e153e1f1acaef8acc537e68b44906d2db6436e2b35ac2c6b42640fff91f00fd" [[package]] name = "time-macros" -version = "0.2.6" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d967f99f534ca7e495c575c62638eebc2898a8c84c119b89e250477bc4ba16b2" +checksum = "a460aeb8de6dcb0f381e1ee05f1cd56fcf5a5f6eb8187ff3d8f0b11078d38b7c" dependencies = [ "time-core", ] @@ -3453,9 +3446,9 @@ dependencies = [ [[package]] name = "tokio-stream" -version = "0.1.11" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d660770404473ccd7bc9f8b28494a811bc18542b915c0855c51e8f419d5223ce" +checksum = "8fb52b74f05dbf495a8fba459fdc331812b96aa086d9eb78101fa0d4569c3313" dependencies = [ "futures-core", "pin-project-lite", diff --git a/Cargo.toml b/Cargo.toml index 614de52..3a0b247 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,6 @@ members = [ "amqp", "env", - "errors", "health_readiness", "httpw", "logging", diff --git a/amqp/Cargo.toml b/amqp/Cargo.toml index 7b38421..0c784f9 100644 --- a/amqp/Cargo.toml +++ b/amqp/Cargo.toml @@ -7,7 +7,6 @@ edition = "2021" mocks = ["dep:mockall"] [dependencies] -errors = { path = "../errors" } env = { path = "../env" } traces = { path = "../traces" } @@ -20,6 +19,7 @@ serde_json = { version = "1.0.91" } serde = { version = "1.0.152", features = ["derive"] } tokio = { version = "1.25.0", features = ["default"] } futures-util = { version = "0.3.26"} +thiserror = { version = "1.0.38" } # Used only with feature mock mockall = { version = "0.11.3", optional = true } diff --git a/amqp/src/client.rs b/amqp/src/client.rs index bcc3ba9..d1a4b77 100644 --- a/amqp/src/client.rs +++ b/amqp/src/client.rs @@ -1,13 +1,11 @@ -use crate::types::PublishParams; - use super::{ defs, topology::ExchangeKind as MyExchangeKind, types::{AmqpPayload, AmqpTracePropagator}, }; +use crate::{errors::AmqpError, types::PublishParams}; use async_trait::async_trait; use env::{Configs, DynamicConfig}; -use errors::amqp::AmqpError; use lapin::{ message::BasicGetMessage, options::{ diff --git a/amqp/src/consumer.rs b/amqp/src/consumer.rs index e9cd87b..c7264e0 100644 --- a/amqp/src/consumer.rs +++ b/amqp/src/consumer.rs @@ -1,9 +1,9 @@ use crate::{ client::Amqp, + errors::AmqpError, topology::{ConsumerHandler, QueueDefinition}, types::{new_span, Metadata}, }; -use errors::amqp::AmqpError; use lapin::{ message::Delivery, options::{BasicAckOptions, BasicNackOptions, BasicPublishOptions}, diff --git a/amqp/src/dispatcher.rs b/amqp/src/dispatcher.rs index d39ad2d..0182955 100644 --- a/amqp/src/dispatcher.rs +++ b/amqp/src/dispatcher.rs @@ -1,9 +1,9 @@ use crate::{ client::Amqp, consumer::consume, + errors::AmqpError, topology::{ConsumerHandler, QueueDefinition}, }; -use errors::amqp::AmqpError; use futures_util::{future::join_all, StreamExt}; use opentelemetry::global; use std::sync::Arc; diff --git a/errors/src/amqp.rs b/amqp/src/errors.rs similarity index 100% rename from errors/src/amqp.rs rename to amqp/src/errors.rs diff --git a/amqp/src/lib.rs b/amqp/src/lib.rs index af737d3..3904962 100644 --- a/amqp/src/lib.rs +++ b/amqp/src/lib.rs @@ -3,6 +3,7 @@ mod consumer; pub mod client; pub mod defs; pub mod dispatcher; +pub mod errors; #[cfg(test)] pub mod mocks; #[cfg(feature = "mocks")] diff --git a/amqp/src/mocks.rs b/amqp/src/mocks.rs index 45b9328..7eedf0f 100644 --- a/amqp/src/mocks.rs +++ b/amqp/src/mocks.rs @@ -2,9 +2,8 @@ use super::{ topology::ExchangeKind as MyExchangeKind, types::{AmqpPayload, PublishParams}, }; -use crate::client::Amqp; +use crate::{client::Amqp, errors::AmqpError}; use async_trait::async_trait; -use errors::amqp::AmqpError; use lapin::{ message::BasicGetMessage, types::{AMQPValue, FieldTable, ShortString}, diff --git a/amqp/src/topology.rs b/amqp/src/topology.rs index 2d849a3..68917c7 100644 --- a/amqp/src/topology.rs +++ b/amqp/src/topology.rs @@ -1,10 +1,8 @@ -use std::{collections::BTreeMap, sync::Arc}; - -use crate::{client::Amqp, defs}; +use crate::{client::Amqp, defs, errors::AmqpError}; use async_trait::async_trait; -use errors::amqp::AmqpError; use lapin::types::{AMQPValue, FieldTable, LongInt, LongString, ShortString}; use opentelemetry::Context; +use std::{collections::BTreeMap, sync::Arc}; use tracing::debug; #[derive(Debug, Clone, Default)] diff --git a/amqp/src/types.rs b/amqp/src/types.rs index baf72d7..c9b9c16 100644 --- a/amqp/src/types.rs +++ b/amqp/src/types.rs @@ -1,5 +1,5 @@ use super::defs; -use errors::amqp::AmqpError; +use crate::errors::AmqpError; use lapin::{ protocol::basic::AMQPProperties, types::{AMQPValue, FieldTable, LongInt, ShortString}, diff --git a/auth/src/defs.rs b/auth/src/defs.rs index 06ca17f..3488f1b 100644 --- a/auth/src/defs.rs +++ b/auth/src/defs.rs @@ -1,11 +1,8 @@ pub enum UsersScopes {} -pub enum ThingsScopes {} - pub enum PlatformScopes {} pub enum Scopes { USER(UsersScopes), - THING(ThingsScopes), PLATFORM(PlatformScopes), } diff --git a/auth/src/lib.rs b/auth/src/lib.rs index 4a95d83..c242d07 100644 --- a/auth/src/lib.rs +++ b/auth/src/lib.rs @@ -2,4 +2,4 @@ mod defs; pub mod jwt_manager; mod types; -pub use defs::{PlatformScopes, Scopes, ThingsScopes, UsersScopes}; +pub use defs::{PlatformScopes, Scopes, UsersScopes}; diff --git a/env/Cargo.toml b/env/Cargo.toml index 436b313..0085dcb 100644 --- a/env/Cargo.toml +++ b/env/Cargo.toml @@ -4,9 +4,9 @@ version = "0.1.0" edition = "2021" [dependencies] -errors = { path = "../errors" } secrets-manager = { path = "../secrets_manager" } dotenvy = { version = "0.15.6" } base64 = { version = "0.13.1" } tracing = { version = "0.1.37" } +thiserror = { version = "1.0.38" } diff --git a/env/src/configs_builder.rs b/env/src/configs_builder.rs index ea4906c..cad8caa 100644 --- a/env/src/configs_builder.rs +++ b/env/src/configs_builder.rs @@ -13,10 +13,10 @@ use crate::{ POSTGRES_PORT_ENV_KEY, POSTGRES_USER_ENV_KEY, SECRET_KEY_ENV_KEY, SECRET_PREFIX, SECRET_PREFIX_TO_DECODE, SQLITE_FILE_NAME_ENV_KEY, }, + errors::ConfigsError, Environment, }; use dotenvy::from_filename; -use errors::configs::ConfigsError; use secrets_manager::{AwsSecretClientBuilder, DummyClient, SecretClient}; use std::{env, sync::Arc}; use tracing::error; diff --git a/errors/src/configs.rs b/env/src/errors.rs similarity index 86% rename from errors/src/configs.rs rename to env/src/errors.rs index 1815162..0b9bb8f 100644 --- a/errors/src/configs.rs +++ b/env/src/errors.rs @@ -6,5 +6,5 @@ pub enum ConfigsError { InternalError, #[error("error to load secrets from secret manager - `{0}`")] - SecretLoadingError(String) + SecretLoadingError(String), } diff --git a/env/src/lib.rs b/env/src/lib.rs index 134a19c..b8aea12 100644 --- a/env/src/lib.rs +++ b/env/src/lib.rs @@ -2,10 +2,11 @@ mod configs; mod configs_builder; pub mod def; mod environment; +pub mod errors; pub use configs::{ AppConfig, AwsConfig, Configs, DynamicConfig, DynamoConfig, Empty, HealthReadinessConfig, MQTTConfig, OTLPConfig, PostgresConfig, SqliteConfig, }; pub use configs_builder::ConfigBuilder; -pub use environment::Environment; \ No newline at end of file +pub use environment::Environment; diff --git a/errors/Cargo.toml b/errors/Cargo.toml deleted file mode 100644 index 715e7fd..0000000 --- a/errors/Cargo.toml +++ /dev/null @@ -1,7 +0,0 @@ -[package] -name = "errors" -version = "0.1.0" -edition = "2021" - -[dependencies] -thiserror = { version = "1.0.38" } \ No newline at end of file diff --git a/errors/README.md b/errors/README.md deleted file mode 100644 index 096d372..0000000 --- a/errors/README.md +++ /dev/null @@ -1 +0,0 @@ -# Errors Crate \ No newline at end of file diff --git a/errors/src/http_server.rs b/errors/src/http_server.rs deleted file mode 100644 index 4d91540..0000000 --- a/errors/src/http_server.rs +++ /dev/null @@ -1,7 +0,0 @@ -use thiserror::Error; - -#[derive(Error, Debug, PartialEq, Eq)] -pub enum HttpServerError { - #[error("http server error")] - ServerError, -} diff --git a/errors/src/lib.rs b/errors/src/lib.rs deleted file mode 100644 index 817d166..0000000 --- a/errors/src/lib.rs +++ /dev/null @@ -1,12 +0,0 @@ -pub mod amqp; -pub mod configs; -pub mod health_readiness; -pub mod http_server; -pub mod logging; -pub mod migrator; -pub mod mqtt; -pub mod otel; -pub mod protocol; -pub mod repositories; -pub mod secrets_manager; -pub mod sql_pool; diff --git a/errors/src/otel.rs b/errors/src/otel.rs deleted file mode 100644 index 26c29d9..0000000 --- a/errors/src/otel.rs +++ /dev/null @@ -1,13 +0,0 @@ -use thiserror::Error; - -#[derive(Error, Debug, PartialEq, Eq, Clone)] -pub enum OtelError { - #[error("mqtt internal error")] - InternalError, - - #[error("failed to read proc file")] - ProcFileError, - - #[error("failed to register metric callback")] - MetricCallbackError, -} diff --git a/errors/src/protocol.rs b/errors/src/protocol.rs deleted file mode 100644 index 7133d46..0000000 --- a/errors/src/protocol.rs +++ /dev/null @@ -1,10 +0,0 @@ -use thiserror::Error; - -#[derive(Error, Debug)] -pub enum ProtocolError { - #[error("Internal Error")] - InternalError, - - #[error("str conversion error")] - ConversionError(), -} diff --git a/errors/src/repositories.rs b/errors/src/repositories.rs deleted file mode 100644 index 6475b80..0000000 --- a/errors/src/repositories.rs +++ /dev/null @@ -1,7 +0,0 @@ -use thiserror::Error; - -#[derive(Error, Debug, PartialEq, Eq)] -pub enum RepositoriesError { - #[error("internal error")] - InternalError, -} diff --git a/health_readiness/Cargo.toml b/health_readiness/Cargo.toml index d776f59..d33dc67 100644 --- a/health_readiness/Cargo.toml +++ b/health_readiness/Cargo.toml @@ -4,7 +4,6 @@ version = "0.1.0" edition = "2021" [dependencies] -errors = { path = "../errors" } httpw = { path = "../httpw" } env = { path = "../env" } @@ -14,4 +13,5 @@ deadpool-postgres = { version = "0.10.5" } lapin = { version = "2.1.1" } paho-mqtt = { version = "0.12.0" } actix-web = { version = "4.3.0" } +thiserror = { version = "1.0.38" } diff --git a/errors/src/health_readiness.rs b/health_readiness/src/errors.rs similarity index 100% rename from errors/src/health_readiness.rs rename to health_readiness/src/errors.rs diff --git a/health_readiness/src/lib.rs b/health_readiness/src/lib.rs index 5c78d0d..c2621e0 100644 --- a/health_readiness/src/lib.rs +++ b/health_readiness/src/lib.rs @@ -1,5 +1,6 @@ mod controller; mod dynamodb; +pub mod errors; mod mqtt; mod postgres; mod rabbitmq; diff --git a/health_readiness/src/mqtt/check.rs b/health_readiness/src/mqtt/check.rs index cb5a001..180656c 100644 --- a/health_readiness/src/mqtt/check.rs +++ b/health_readiness/src/mqtt/check.rs @@ -1,5 +1,4 @@ -use crate::HealthChecker; -use errors::health_readiness::HealthReadinessError; +use crate::{errors::HealthReadinessError, HealthChecker}; use paho_mqtt::AsyncClient; use std::sync::Arc; use tracing::debug; diff --git a/health_readiness/src/postgres/check.rs b/health_readiness/src/postgres/check.rs index 94e6f39..8c81628 100644 --- a/health_readiness/src/postgres/check.rs +++ b/health_readiness/src/postgres/check.rs @@ -1,6 +1,5 @@ -use crate::HealthChecker; +use crate::{errors::HealthReadinessError, HealthChecker}; use deadpool_postgres::Pool; -use errors::health_readiness::HealthReadinessError; use std::sync::Arc; use tracing::error; diff --git a/health_readiness/src/rabbitmq/check.rs b/health_readiness/src/rabbitmq/check.rs index a212627..f77e089 100644 --- a/health_readiness/src/rabbitmq/check.rs +++ b/health_readiness/src/rabbitmq/check.rs @@ -1,5 +1,4 @@ -use crate::HealthChecker; -use errors::health_readiness::HealthReadinessError; +use crate::{errors::HealthReadinessError, HealthChecker}; use lapin::Connection; use std::sync::Arc; diff --git a/health_readiness/src/server.rs b/health_readiness/src/server.rs index de29681..7ea8a49 100644 --- a/health_readiness/src/server.rs +++ b/health_readiness/src/server.rs @@ -1,12 +1,11 @@ -use crate::controller; -use crate::postgres::PostgresHealthChecker; -use crate::rabbitmq::RabbitMqHealthChecker; -use crate::HealthReadinessImpl; -use crate::{mqtt::MqttHealthChecker, HealthChecker}; +use crate::{ + controller, errors::HealthReadinessError, mqtt::MqttHealthChecker, + postgres::PostgresHealthChecker, rabbitmq::RabbitMqHealthChecker, HealthChecker, + HealthReadinessImpl, +}; use actix_web::{middleware as actix_middleware, web, App, HttpServer}; use deadpool_postgres::Pool; use env::HealthReadinessConfig; -use errors::health_readiness::HealthReadinessError; use httpw::middlewares; use lapin::Connection; use paho_mqtt::AsyncClient; diff --git a/health_readiness/src/service.rs b/health_readiness/src/service.rs index 0ee0aeb..0a25110 100644 --- a/health_readiness/src/service.rs +++ b/health_readiness/src/service.rs @@ -1,4 +1,4 @@ -use errors::health_readiness::HealthReadinessError; +use crate::errors::HealthReadinessError; use std::sync::Arc; use tracing::error; diff --git a/logging/Cargo.toml b/logging/Cargo.toml index 11b3a4f..228d3b7 100644 --- a/logging/Cargo.toml +++ b/logging/Cargo.toml @@ -4,9 +4,10 @@ version = "0.1.0" edition = "2021" [dependencies] -errors = { path = "../errors" } env = { path = "../env" } + tracing-bunyan-formatter = { version = "0.3.6" } tracing-subscriber = { version = "0.3.16" } tracing-log = { version = "0.1.3" } -tracing = { version = "0.1.37" } \ No newline at end of file +tracing = { version = "0.1.37" } +thiserror = { version = "1.0.38" } \ No newline at end of file diff --git a/errors/src/logging.rs b/logging/src/errors.rs similarity index 100% rename from errors/src/logging.rs rename to logging/src/errors.rs diff --git a/logging/src/lib.rs b/logging/src/lib.rs index 9083675..5588ff9 100644 --- a/logging/src/lib.rs +++ b/logging/src/lib.rs @@ -1,3 +1,4 @@ +pub mod errors; mod logger; pub use logger::setup; diff --git a/logging/src/logger.rs b/logging/src/logger.rs index 7c63d06..9f419a5 100644 --- a/logging/src/logger.rs +++ b/logging/src/logger.rs @@ -1,5 +1,5 @@ +use crate::errors::LoggingError; use env::{AppConfig, Environment}; -use errors::logging::LoggingError; use tracing_bunyan_formatter::BunyanFormattingLayer; use tracing_log::LogTracer; use tracing_subscriber::{ diff --git a/metrics/Cargo.toml b/metrics/Cargo.toml index a5828c7..6f677c4 100644 --- a/metrics/Cargo.toml +++ b/metrics/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" [dependencies] env = { path = "../env" } -errors = { path = "../errors" } + opentelemetry = { version = "0.18.0", features = ["rt-tokio", "metrics"] } opentelemetry-otlp = { version = "0.11.0", features = ["tonic", "metrics", "grpc-tonic" , "tls", "tls-roots"] } tracing = { version = "0.1.37" } diff --git a/migrator/Cargo.toml b/migrator/Cargo.toml index 8b59fe0..ad3f52e 100644 --- a/migrator/Cargo.toml +++ b/migrator/Cargo.toml @@ -10,10 +10,10 @@ sqlite = ["dep:deadpool-sqlite"] [dependencies] env = { path = "../env" } logging = { path = "../logging" } -errors = { path = "../errors" } async-trait = { version = "0.1.64" } tracing = { version = "0.1.37" } +thiserror = { version = "1.0.38" } deadpool-postgres = { version = "0.10.2", optional = true } deadpool-sqlite = { version = "0.5.0", optional = true } \ No newline at end of file diff --git a/errors/src/migrator.rs b/migrator/src/errors.rs similarity index 100% rename from errors/src/migrator.rs rename to migrator/src/errors.rs diff --git a/migrator/src/lib.rs b/migrator/src/lib.rs index b776c3f..64ff91d 100644 --- a/migrator/src/lib.rs +++ b/migrator/src/lib.rs @@ -1,3 +1,4 @@ +pub mod errors; #[cfg(feature = "postgres")] mod postgres; mod service; diff --git a/migrator/src/postgres.rs b/migrator/src/postgres.rs index 340dc33..d092923 100644 --- a/migrator/src/postgres.rs +++ b/migrator/src/postgres.rs @@ -1,7 +1,6 @@ -use crate::service::MigratorDriver; +use crate::{errors::MigrationError, service::MigratorDriver}; use async_trait::async_trait; use deadpool_postgres::{tokio_postgres::error::SqlState, Object, Pool}; -use errors::migrator::MigrationError; use std::{fs, sync::Arc}; use tracing::{debug, error}; diff --git a/migrator/src/service.rs b/migrator/src/service.rs index 7446e60..22aa5a1 100644 --- a/migrator/src/service.rs +++ b/migrator/src/service.rs @@ -1,5 +1,5 @@ +use crate::errors::MigrationError; use async_trait::async_trait; -use errors::migrator::MigrationError; use std::sync::Arc; #[async_trait] diff --git a/migrator/src/sqlite.rs b/migrator/src/sqlite.rs index f947e8d..fe8fb64 100644 --- a/migrator/src/sqlite.rs +++ b/migrator/src/sqlite.rs @@ -1,7 +1,6 @@ -use crate::service::MigratorDriver; +use crate::{errors::MigrationError, service::MigratorDriver}; use async_trait::async_trait; use deadpool_sqlite::{rusqlite::ErrorCode, Object, Pool}; -use errors::migrator::MigrationError; use std::{fs, sync::Arc}; use tracing::{debug, error, warn}; diff --git a/mqtt/Cargo.toml b/mqtt/Cargo.toml index 36c251d..258e481 100644 --- a/mqtt/Cargo.toml +++ b/mqtt/Cargo.toml @@ -7,7 +7,6 @@ edition = "2021" mocks = ["dep:mockall"] [dependencies] -errors = { path = "../errors" } env = { path = "../env" } traces = { path = "../traces" } @@ -19,6 +18,7 @@ paho-mqtt = { version = "0.12.0" } serde = { version = "1.0.152", features = ["derive"] } serde_json = { version = "1.0.93" } futures-util = { version = "0.3.26" } +thiserror = { version = "1.0.38" } # Used only with feature mock mockall = { version = "0.11.3", optional = true } diff --git a/mqtt/src/builder.rs b/mqtt/src/builder.rs index b4fd4c9..02b5e9c 100644 --- a/mqtt/src/builder.rs +++ b/mqtt/src/builder.rs @@ -1,6 +1,5 @@ -use crate::{types::BrokerKind, MqttClientImpl}; +use crate::{errors::MqttError, types::BrokerKind, MqttClientImpl}; use env::{AppConfig, Configs, DynamicConfig, MQTTConfig}; -use errors::mqtt::MqttError; use paho_mqtt::{ AsyncClient, ConnectOptions, ConnectOptionsBuilder, CreateOptions, CreateOptionsBuilder, SslOptionsBuilder, SslVersion, diff --git a/mqtt/src/client.rs b/mqtt/src/client.rs index 6c5c798..0802791 100644 --- a/mqtt/src/client.rs +++ b/mqtt/src/client.rs @@ -1,6 +1,5 @@ -use crate::types::MqttPayload; +use crate::{errors::MqttError, types::MqttPayload}; use async_trait::async_trait; -use errors::mqtt::MqttError; use paho_mqtt::{AsyncClient, AsyncReceiver, Message, MessageBuilder}; use std::sync::Arc; use tracing::{debug, error}; diff --git a/mqtt/src/dispatcher.rs b/mqtt/src/dispatcher.rs index 84946bc..0d2b2d2 100644 --- a/mqtt/src/dispatcher.rs +++ b/mqtt/src/dispatcher.rs @@ -1,8 +1,8 @@ use crate::{ client::MqttClient, + errors::MqttError, types::{Controller, TopicMessage}, }; -use errors::mqtt::MqttError; use futures_util::StreamExt; use opentelemetry::{ global::{self, BoxedTracer}, @@ -165,8 +165,8 @@ mod tests { use std::vec; use super::*; + use crate::errors::MqttError; use async_trait::async_trait; - use errors::mqtt::MqttError; #[test] fn test_new() { diff --git a/errors/src/mqtt.rs b/mqtt/src/errors.rs similarity index 100% rename from errors/src/mqtt.rs rename to mqtt/src/errors.rs diff --git a/mqtt/src/lib.rs b/mqtt/src/lib.rs index a9f3da1..c7f386d 100644 --- a/mqtt/src/lib.rs +++ b/mqtt/src/lib.rs @@ -1,12 +1,13 @@ -mod client; mod builder; +mod client; pub mod dispatcher; +pub mod errors; #[cfg(test)] pub mod mocks; #[cfg(feature = "mocks")] pub mod mocks; pub mod types; +pub use builder::MqttClientBuilder; pub use client::{MqttClient, MqttClientImpl}; -pub use builder::{MqttClientBuilder}; diff --git a/mqtt/src/mocks.rs b/mqtt/src/mocks.rs index d930ce9..1bfaf04 100644 --- a/mqtt/src/mocks.rs +++ b/mqtt/src/mocks.rs @@ -1,10 +1,8 @@ -use std::sync::Arc; - -use crate::{client::MqttClient, types::MqttPayload}; +use crate::{client::MqttClient, errors::MqttError, types::MqttPayload}; use async_trait::async_trait; -use errors::mqtt::MqttError; use mockall::*; use paho_mqtt::{AsyncClient, AsyncReceiver, Message}; +use std::sync::Arc; mock! { pub MqttClientImpl{} diff --git a/mqtt/src/types.rs b/mqtt/src/types.rs index d7b7d43..2d67b88 100644 --- a/mqtt/src/types.rs +++ b/mqtt/src/types.rs @@ -1,5 +1,5 @@ +use crate::errors::MqttError; use async_trait::async_trait; -use errors::mqtt::MqttError; use opentelemetry::Context; use serde::{Deserialize, Serialize}; use tracing::error; diff --git a/secrets_manager/Cargo.toml b/secrets_manager/Cargo.toml index 72b668c..51709eb 100644 --- a/secrets_manager/Cargo.toml +++ b/secrets_manager/Cargo.toml @@ -7,13 +7,12 @@ edition = "2021" mocks = ["dep:mockall"] [dependencies] -errors = { path = "../errors" } - async-trait = { version = "0.1.64" } tracing = { version = "0.1.37" } aws-config = { version = "0.51.0" } aws-sdk-secretsmanager = { version = "0.21.0" } serde_json = { version = "1.0.91" } +thiserror = { version = "1.0.38" } # Used only with feature mock mockall = { version = "0.11.3", optional = true } diff --git a/secrets_manager/src/aws_client.rs b/secrets_manager/src/aws_client.rs index 72789be..2dbda0e 100644 --- a/secrets_manager/src/aws_client.rs +++ b/secrets_manager/src/aws_client.rs @@ -1,5 +1,4 @@ -use crate::SecretClient; -use errors::secrets_manager::SecretsManagerError; +use crate::{errors::SecretsManagerError, SecretClient}; use serde_json::Value; use tracing::error; diff --git a/secrets_manager/src/aws_client_builder.rs b/secrets_manager/src/aws_client_builder.rs index 1413a0d..f65696e 100644 --- a/secrets_manager/src/aws_client_builder.rs +++ b/secrets_manager/src/aws_client_builder.rs @@ -1,6 +1,5 @@ -use crate::AwsSecretClient; +use crate::{errors::SecretsManagerError, AwsSecretClient}; use aws_sdk_secretsmanager as secretsmanager; -use errors::secrets_manager::SecretsManagerError; use secretsmanager::Client; use serde_json::Value; use tracing::error; diff --git a/secrets_manager/src/dummy_client.rs b/secrets_manager/src/dummy_client.rs index 1e7d2c2..db467b6 100644 --- a/secrets_manager/src/dummy_client.rs +++ b/secrets_manager/src/dummy_client.rs @@ -1,5 +1,4 @@ -use crate::SecretClient; -use errors::secrets_manager::SecretsManagerError; +use crate::{errors::SecretsManagerError, SecretClient}; pub struct DummyClient; diff --git a/errors/src/secrets_manager.rs b/secrets_manager/src/errors.rs similarity index 100% rename from errors/src/secrets_manager.rs rename to secrets_manager/src/errors.rs diff --git a/secrets_manager/src/lib.rs b/secrets_manager/src/lib.rs index 3e924fd..13c752c 100644 --- a/secrets_manager/src/lib.rs +++ b/secrets_manager/src/lib.rs @@ -2,6 +2,7 @@ mod aws_client; mod aws_client_builder; mod dummy_client; +pub mod errors; #[cfg(test)] pub mod mocks; #[cfg(feature = "mocks")] diff --git a/secrets_manager/src/mocks.rs b/secrets_manager/src/mocks.rs index e74bfc7..7c25b68 100644 --- a/secrets_manager/src/mocks.rs +++ b/secrets_manager/src/mocks.rs @@ -1,6 +1,5 @@ -use crate::SecretClient; +use crate::{errors::SecretsManagerError, SecretClient}; use async_trait::async_trait; -use errors::secrets_manager::SecretsManagerError; use mockall::*; mock! { diff --git a/secrets_manager/src/types.rs b/secrets_manager/src/types.rs index a0ec3d4..d745c33 100644 --- a/secrets_manager/src/types.rs +++ b/secrets_manager/src/types.rs @@ -1,5 +1,5 @@ +use crate::errors::SecretsManagerError; use async_trait::async_trait; -use errors::secrets_manager::SecretsManagerError; #[async_trait] pub trait SecretClient { diff --git a/sql_pool/Cargo.toml b/sql_pool/Cargo.toml index 060f295..33fcb4c 100644 --- a/sql_pool/Cargo.toml +++ b/sql_pool/Cargo.toml @@ -9,12 +9,13 @@ sqlite = ["dep:deadpool-sqlite"] [dependencies] env = { path = "../env" } -errors = { path = "../errors" } + +tracing = { version = "0.1.37" } +thiserror = { version = "1.0.38" } + ## -deadpool-postgres = { version = "0.10.2", optional = true } +deadpool-postgres = { version = "0.10.5", optional = true } tokio-postgres = { version = "0.7.7", features = ["with-chrono-0_4", "with-uuid-0_8"], optional = true } ## -deadpool-sqlite = { version = "0.5.0", optional = true } - -tracing = { version = "0.1.37" } \ No newline at end of file +deadpool-sqlite = { version = "0.5.0", optional = true } \ No newline at end of file diff --git a/errors/src/sql_pool.rs b/sql_pool/src/errors.rs similarity index 100% rename from errors/src/sql_pool.rs rename to sql_pool/src/errors.rs diff --git a/sql_pool/src/lib.rs b/sql_pool/src/lib.rs index 34efed9..5ec0822 100644 --- a/sql_pool/src/lib.rs +++ b/sql_pool/src/lib.rs @@ -1,3 +1,4 @@ +pub mod errors; #[cfg(feature = "postgres")] pub mod postgres; #[cfg(feature = "sqlite")] diff --git a/sql_pool/src/postgres.rs b/sql_pool/src/postgres.rs index d982f52..073c6f4 100644 --- a/sql_pool/src/postgres.rs +++ b/sql_pool/src/postgres.rs @@ -1,6 +1,6 @@ +use crate::errors::SqlPoolError; use deadpool_postgres::{Manager, ManagerConfig, Pool, RecyclingMethod}; use env::PostgresConfig; -use errors::sql_pool::SqlPoolError; use tokio_postgres::NoTls; use tracing::error; diff --git a/sql_pool/src/sqlite.rs b/sql_pool/src/sqlite.rs index 1720905..bf8ddbc 100644 --- a/sql_pool/src/sqlite.rs +++ b/sql_pool/src/sqlite.rs @@ -1,6 +1,6 @@ +use crate::errors::SqlPoolError; use deadpool_sqlite::{Config, Pool, Runtime}; use env::SqliteConfig; -use errors::sql_pool::SqlPoolError; use tracing::error; pub fn conn_pool(cfg: &SqliteConfig) -> Result { diff --git a/traces/Cargo.toml b/traces/Cargo.toml index 0046443..fe6abcb 100644 --- a/traces/Cargo.toml +++ b/traces/Cargo.toml @@ -5,6 +5,7 @@ edition = "2021" [dependencies] env = { path = "../env" } + opentelemetry = { version = "0.18.0", features = ["rt-tokio"] } opentelemetry-otlp = { version = "0.11.0", features = ["tonic", "tls", "tls-roots"] } tracing = { version = "0.1.37" }