Skip to content

Commit

Permalink
fix: unable to refresh the connection due to serde (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
sagojez authored May 24, 2024
1 parent b1dff41 commit 2c49579
Show file tree
Hide file tree
Showing 8 changed files with 660 additions and 743 deletions.
1,368 changes: 639 additions & 729 deletions Cargo.lock

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@ dotenvy = "0.15.7"
envconfig = "0.10.0"
futures = "0.3.30"
handlebars = "5.1.1"
integrationos-domain = { version = "2.1.0", features = ["dummy", "actix-error"] }
integrationos-domain = { version = "4.1.6", features = ["dummy", "actix-error"] }
jsonwebtoken = "9.2.0"
moka = { version = "0.12.5", features = ["future"] }
mongodb = "2.8.0"
reqwest = "0.11.24"
reqwest = { version = "0.12.3", features = [
"json",
"rustls-tls",
], default-features = false }
serde = { version = "1.0.196", features = ["derive"] }
serde_json = "1.0.113"
tokio = { version = "1.35.1", features = ["macros", "rt-multi-thread"] }
Expand All @@ -41,7 +44,7 @@ name = "oauth-api"
path = "src/main.rs"

[dev-dependencies]
fake = { version = "=2.9.1", features = ["dummy"] }
fake = { version = "=2.9.2", features = ["dummy"] }
mark-flaky-tests = { version = "1.0.2", features = ["tokio"] }
once_cell = "1.19.0"
rand = "0.8.5"
Expand Down
7 changes: 6 additions & 1 deletion src/algebra/refresh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,14 @@ impl Handler<Refresh> for RefreshActor {
let state = self.state.clone();

Box::pin(async move {
tracing::info!("Searching for connections to refresh");
let connections = connections_store
.get_by(&refresh_before, &refresh_after)
.await?;
.await
.map_err(|e| {
tracing::error!("Failed to get connections to refresh: {:?}", e);
e
})?;

tracing::info!("Found {} connections to refresh", connections.len());

Expand Down
4 changes: 2 additions & 2 deletions src/algebra/storage.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use async_trait::async_trait;
use chrono::{DateTime, Utc};
use integrationos_domain::{Connection, Id, IntegrationOSError, MongoStore, StoreExt};
use integrationos_domain::{Connection, Id, IntegrationOSError, MongoStore};
use mongodb::bson::doc;

#[async_trait]
Expand All @@ -24,7 +24,7 @@ impl StorageExt for MongoStore<Connection> {
self.get_many(
Some(doc! {
"oauth.enabled.expires_at": doc! {
"$gt": refresh_before.timestamp(),
"$gte": refresh_before.timestamp(),
"$lte": refresh_after.timestamp(),
},
}),
Expand Down
5 changes: 2 additions & 3 deletions src/algebra/trigger.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use crate::domain::{Outcome, Trigger};

use super::ParameterExt;
use crate::domain::{Outcome, Trigger};
use actix::prelude::*;
use chrono::Duration;
use integrationos_domain::{
algebra::{MongoStore, StoreExt},
algebra::MongoStore,
api_model_config::ContentType,
client::secrets_client::SecretsClient,
connection_oauth_definition::{Computation, ConnectionOAuthDefinition, OAuthResponse},
Expand Down
5 changes: 2 additions & 3 deletions src/service/http/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@ use actix_web::{
web::Data,
Error as ActixWebError, HttpMessage,
};
use actix_web::{HttpResponse, HttpResponseBuilder};
use actix_web::{http::StatusCode, HttpResponse, HttpResponseBuilder};
use actix_web_lab::middleware::Next;
use integrationos_domain::{algebra::StoreExt, event_access::EventAccess, Claims};
use integrationos_domain::{event_access::EventAccess, Claims};
use jsonwebtoken::{decode, DecodingKey, Validation};
use mongodb::bson::doc;
use reqwest::StatusCode;
use std::sync::Arc;

#[derive(serde::Serialize, serde::Deserialize, Debug, Eq, PartialEq)]
Expand Down
2 changes: 1 addition & 1 deletion src/service/http/private/trigger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pub async fn trigger_refresh(

let status: StatusCode = match outcome {
Outcome::Success { .. } => StatusCode::OK,
Outcome::Failure { error, .. } => error.into(),
Outcome::Failure { error, .. } => (&error).into(),
};

Ok(ServerResponse::from(
Expand Down
3 changes: 2 additions & 1 deletion src/service/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ pub use http::*;

use crate::algebra::RefreshActor;
use actix::{Addr, Supervisor};
use actix_web::http::header::HeaderValue;
use integrationos_domain::{
algebra::MongoStore, client::secrets_client::SecretsClient,
connection_oauth_definition::ConnectionOAuthDefinition, error::IntegrationOSError as Error,
event_access::EventAccess, Connection, InternalError, Store,
};
use moka::future::Cache;
use mongodb::options::FindOptions;
use reqwest::{header::HeaderValue, Client};
use reqwest::Client;
use std::{sync::Arc, time::Duration};
use tokio::time::timeout;

Expand Down

0 comments on commit 2c49579

Please sign in to comment.