Skip to content

Commit

Permalink
Merge pull request #6 from tointernet/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
ralvescosta authored Jun 23, 2024
2 parents 0e899a3 + 09b3806 commit d40bc02
Show file tree
Hide file tree
Showing 49 changed files with 500 additions and 437 deletions.
556 changes: 296 additions & 260 deletions Cargo.lock

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ resolver = "2"

exclude = [
"examples/http_api",
"examples/rmq-consumer"
"examples/rmq-consumer",
"examples/rmq-consumer-prom"
]

members = [
Expand All @@ -27,12 +28,12 @@ members = [
]

[workspace.dependencies]
thiserror = { version = "1.0.60" }
serde = { version = "1.0.202" }
thiserror = { version = "1.0.61" }
serde = { version = "1.0.203" }
serde_json = { version = "1.0.117" }
tokio = { version = "1.37.0" }
tokio = { version = "1.38.0" }
async-trait = { version = "0.1.80" }
tracing = { version = "0.1.40" }
tonic = { version = "0.11" }
opentelemetry = { version = "0.22.0" }
opentelemetry_sdk = { version = "0.22.1" }
opentelemetry = { version = "0.23.0" }
opentelemetry_sdk = { version = "0.23.0" }
2 changes: 1 addition & 1 deletion auth/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ async-trait = { workspace = true }
opentelemetry = { workspace = true }
thiserror = { workspace = true }
tokio = { workspace = true, features = ["sync"] }
reqwest = { version = "0.12.3", features = ["json"] }
reqwest = { version = "0.12.4", features = ["json"] }
moka = { version = "0.12.7", features = ["future"] }
jsonwebtoken = { version = "9.3.0" }

Expand Down
4 changes: 2 additions & 2 deletions configs/src/mqtt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub enum MQTTBrokerKind {
impl From<&str> for MQTTBrokerKind {
fn from(value: &str) -> Self {
match value.to_uppercase().as_str() {
"AWSIOTCORE" => MQTTBrokerKind::AWSIoTCore,
"AWSIoTCore" => MQTTBrokerKind::AWSIoTCore,
_ => MQTTBrokerKind::Default,
}
}
Expand All @@ -19,7 +19,7 @@ impl From<&str> for MQTTBrokerKind {
impl From<&String> for MQTTBrokerKind {
fn from(value: &String) -> Self {
match value.to_uppercase().as_str() {
"AWSIOTCORE" => MQTTBrokerKind::AWSIoTCore,
"AWSIoTCore" => MQTTBrokerKind::AWSIoTCore,
_ => MQTTBrokerKind::Default,
}
}
Expand Down
12 changes: 11 additions & 1 deletion configs/src/sqlite.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#[derive(Debug, Clone, Default)]
#[derive(Debug, Clone)]
pub struct SqliteConfigs {
///Default: local.db
pub file: String,
Expand All @@ -7,3 +7,13 @@ pub struct SqliteConfigs {
/// Default: postgres
pub password: String,
}

impl Default for SqliteConfigs {
fn default() -> Self {
Self {
file: Default::default(),
user: Default::default(),
password: Default::default(),
}
}
}
11 changes: 5 additions & 6 deletions configs_builder/src/configs_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,15 +189,14 @@ impl ConfigBuilder {
app_cfg: &AppConfigs,
) -> Result<Option<Arc<dyn SecretClient>>, ConfigsError> {
match app_cfg.secret_manager {
SecretsManagerKind::None => Ok(Some(Arc::new(FakeSecretClient::new()))),
SecretsManagerKind::None => {
return Ok(Some(Arc::new(FakeSecretClient::new())));
}

SecretsManagerKind::AWSSecretManager => {
let secret_key = env::var(SECRET_KEY_ENV_KEY).unwrap_or_default();

match AWSSecretClientBuilder::new(app_cfg.env.to_string(), secret_key)
.build()
.await
{
match AWSSecretClientBuilder::new(secret_key).build().await {
Ok(c) => Ok(Some(Arc::new(c))),
Err(err) => {
error!(error = err.to_string(), "error to create aws secret client");
Expand Down Expand Up @@ -647,7 +646,7 @@ impl ConfigBuilder {

v.parse().unwrap_or_else(|_| {
error!(key = key, value = v, "parse went wrong");
default
return default;
})
}

Expand Down
8 changes: 4 additions & 4 deletions examples/http_api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ sql-pool = {git = "ssh://git@github.com/tointernet/ruskit.git", rev = "v0.3.0",
migrator = {git = "ssh://git@github.com/tointernet/ruskit.git", rev = "v0.3.0", features = ["postgres"] }
health-readiness = {git = "ssh://git@github.com/tointernet/ruskit.git", rev = "v0.3.0"}

actix-web = { version = "4.5.1" }
serde = { version = "1.0.202" }
actix-web = { version = "4.6.0" }
serde = { version = "1.0.203" }
serde_json = { version = "1.0.117" }
opentelemetry = { version = "0.22" }
opentelemetry = { version = "0.23" }
async-trait = { version = "0.1.80" }
tracing = { version = "0.1.40" }
tokio = { version = "1.37.0", features = ["default", "rt-multi-thread", "macros", "signal"]}
tokio = { version = "1.38.0", features = ["default", "rt-multi-thread", "macros", "signal"]}
utoipa = { version = "4.2.3" }
validator = { version = "0.18.1" }
10 changes: 5 additions & 5 deletions examples/rmq-consumer-prom/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ migrator = {git = "ssh://git@github.com/tointernet/ruskit.git", rev = "v0.4.0",
health-http-server = {git = "ssh://git@github.com/tointernet/ruskit.git", rev = "v0.4.0", features = ["prometheus"]}
health-readiness = {git = "ssh://git@github.com/tointernet/ruskit.git", rev = "v0.4.0", features=["rabbitmq"]}

serde = { version = "1.0.200" }
serde_json = { version = "1.0.116" }
opentelemetry = { version = "0.22" }
async-trait = { version = "0.1.77" }
serde = { version = "1.0.203" }
serde_json = { version = "1.0.117" }
opentelemetry = { version = "0.23" }
async-trait = { version = "0.1.80" }
tracing = { version = "0.1.40" }
tokio = { version = "1.37.0", features = ["default", "rt-multi-thread", "macros", "signal"]}
tokio = { version = "1.38.0", features = ["default", "rt-multi-thread", "macros", "signal"]}
lapin = { version = "2.3.4" }
37 changes: 37 additions & 0 deletions examples/rmq-consumer-prom/a.drawio
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<mxfile host="65bd71144e">
<diagram id="UFXtG8m6ZOe-1FoDh3VJ" name="Page-1">
<mxGraphModel dx="983" dy="439" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
<root>
<mxCell id="0"/>
<mxCell id="1" parent="0"/>
<mxCell id="2" value="filters-single-messages" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="70" y="190" width="150" height="60" as="geometry"/>
</mxCell>
<mxCell id="3" value="filters-multiple-messages" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="80" y="340" width="150" height="60" as="geometry"/>
</mxCell>
<mxCell id="4" value="HTTP /metrics" style="rhombus;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="210" y="150" width="100" height="90" as="geometry"/>
</mxCell>
<mxCell id="5" value="HTTP /metrics" style="rhombus;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="220" y="310" width="100" height="90" as="geometry"/>
</mxCell>
<mxCell id="7" style="edgeStyle=none;html=1;entryX=1;entryY=0.5;entryDx=0;entryDy=0;" edge="1" parent="1" source="6" target="4">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="8" style="edgeStyle=none;html=1;entryX=1;entryY=0.5;entryDx=0;entryDy=0;" edge="1" parent="1" source="6" target="5">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="6" value="Prometheus" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="460" y="150" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="10" value="PromSQL" style="edgeStyle=none;html=1;entryX=1;entryY=0.5;entryDx=0;entryDy=0;" edge="1" parent="1" source="9" target="6">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="9" value="Grafana" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="690" y="150" width="120" height="60" as="geometry"/>
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>
10 changes: 5 additions & 5 deletions examples/rmq-consumer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ migrator = {git = "ssh://git@github.com/tointernet/ruskit.git", rev = "v0.4.0",
health-http-server = {git = "ssh://git@github.com/tointernet/ruskit.git", rev = "v0.4.0"}
health-readiness = {git = "ssh://git@github.com/tointernet/ruskit.git", rev = "v0.4.0", features=["rabbitmq"]}

serde = { version = "1.0.200" }
serde_json = { version = "1.0.116" }
opentelemetry = { version = "0.22" }
async-trait = { version = "0.1.77" }
serde = { version = "1.0.203" }
serde_json = { version = "1.0.117" }
opentelemetry = { version = "0.23" }
async-trait = { version = "0.1.80" }
tracing = { version = "0.1.40" }
tokio = { version = "1.37.0", features = ["default", "rt-multi-thread", "macros", "signal"]}
tokio = { version = "1.38.0", features = ["default", "rt-multi-thread", "macros", "signal"]}
lapin = { version = "2.3.4" }
4 changes: 2 additions & 2 deletions health_http_server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ health-readiness = { path = '../health_readiness' }
thiserror = { workspace = true }
tracing = { workspace = true }
opentelemetry = { workspace = true }
actix-web = { version = "4.5.1" }
actix-web = { version = "4.8.0" }

prometheus = { version = "0.13.3", optional = true }
prometheus = { version = "0.13.4", optional = true }


4 changes: 2 additions & 2 deletions health_http_server/src/server/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
mod tiny_server;
mod server;

pub use tiny_server::TinyHTTPServer;
pub use server::TinyHTTPServer;
File renamed without changes.
6 changes: 3 additions & 3 deletions health_readiness/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ tracing = { workspace = true }
thiserror = { workspace = true }

# mqtt
paho-mqtt = { version = "0.12.3", optional = true }
paho-mqtt = { version = "0.12.5", optional = true }

# rabbitmq
lapin = { version = "2.3.3", optional = true }
lapin = { version = "2.3.4", optional = true }

# postgres
deadpool-postgres = { version = "0.13.2", optional = true }
deadpool-postgres = { version = "0.14.0", optional = true }

4 changes: 2 additions & 2 deletions health_readiness/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ pub struct HealthReadinessServiceImpl {

impl HealthReadinessServiceImpl {
pub fn empty() -> Arc<HealthReadinessServiceImpl> {
Arc::new(HealthReadinessServiceImpl { checkers: vec![] })
return Arc::new(HealthReadinessServiceImpl { checkers: vec![] });
}

pub fn new(checkers: Vec<Arc<dyn HealthChecker>>) -> Arc<HealthReadinessServiceImpl> {
Arc::new(HealthReadinessServiceImpl { checkers })
return Arc::new(HealthReadinessServiceImpl { checkers });
}

#[cfg(feature = "mqtt")]
Expand Down
8 changes: 4 additions & 4 deletions http_components/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ validator = ["dep:validator"]
health = ["dep:health-readiness"]

[dependencies]
actix-web = { version = "4.5.1" }
actix-http = { version = "3.6.0" }
actix-web = { version = "4.8.0" }
actix-http = { version = "3.8.0" }
actix-cors = { version = "0.7.0" }
futures-util = { version = "0.3.30" }
serde = { workspace = true, features = ["derive"] }
Expand All @@ -38,8 +38,8 @@ auth = { path = "../auth", optional = true }
otel = { path = "../otel", optional = true }

# metrics
opentelemetry-semantic-conventions = { version = "0.14", optional = true }
opentelemetry-prometheus = { version = "0.15", optional = true }
opentelemetry-semantic-conventions = { version = "0.15", optional = true }
opentelemetry-prometheus = { version = "0.16", optional = true }
prometheus = { version = "0.13.4", optional = true }

# health
Expand Down
1 change: 0 additions & 1 deletion http_components/README.md

This file was deleted.

3 changes: 2 additions & 1 deletion http_components/src/handlers/health.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use crate::viewmodels::HTTPError;
use actix_web::{error::HttpError, get, web, HttpResponse};
use health_readiness::HealthReadinessService;
use std::sync::Arc;

#[get("/health")]
pub async fn health_handler(
service: web::Data<dyn HealthReadinessService>,
service: web::Data<Arc<dyn HealthReadinessService>>,
) -> Result<HttpResponse, HttpError> {
match service.validate().await {
Ok(_) => Ok(HttpResponse::Ok().finish()),
Expand Down
2 changes: 1 addition & 1 deletion http_components/src/middlewares/deserializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub fn handler() -> JsonConfig {
format!("JSON error: {:?}", err),
HttpResponse::BadRequest().json(HTTPError::bad_request(
"unformatted body",
format!("{}", err),
&format!("{}", err),
)),
)
.into()
Expand Down
6 changes: 0 additions & 6 deletions http_components/src/middlewares/otel/http_metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,6 @@ impl HTTPOtelMetrics {
}
}

impl Default for HTTPOtelMetrics {
fn default() -> Self {
Self::new()
}
}

impl<S, B> dev::Transform<S, dev::ServiceRequest> for HTTPOtelMetrics
where
S: dev::Service<
Expand Down
4 changes: 2 additions & 2 deletions http_server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ http-components = { path = '../http_components', features = ["tracing", "metrics
health-readiness = { path = '../health_readiness' }
auth = { path = "../auth" }

actix-web = { version = "4.5.1" }
actix-web = { version = "4.8.0" }
thiserror = { workspace = true }
serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true }
Expand All @@ -21,4 +21,4 @@ opentelemetry = { workspace = true }

# Swagger
utoipa = { version = "4.2.3", features = ["actix_extras"], optional = true }
utoipa-swagger-ui = { version = "7.0.1", features = ["actix-web"], optional = true }
utoipa-swagger-ui = { version = "7.1.0", features = ["actix-web"], optional = true }
4 changes: 2 additions & 2 deletions http_server/src/server/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
mod http_server;
mod server;

pub use http_server::HTTPServer;
pub use server::HTTPServer;
File renamed without changes.
1 change: 0 additions & 1 deletion kafka/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@ async-trait = { workspace = true }
opentelemetry = { workspace = true }
tracing = { workspace = true }
tokio = { workspace = true, features = ["default"] }
thiserror = { workspace = true }
1 change: 0 additions & 1 deletion kafka/README.md

This file was deleted.

7 changes: 0 additions & 7 deletions kafka/src/errors.rs

This file was deleted.

1 change: 0 additions & 1 deletion kafka/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
pub mod connection;
pub mod dispatcher;
pub mod errors;
pub mod otel;
pub mod publisher;
Loading

0 comments on commit d40bc02

Please sign in to comment.