Skip to content
This repository has been archived by the owner on May 22, 2024. It is now read-only.

Commit

Permalink
Fix/template cache bug (#27)
Browse files Browse the repository at this point in the history
* Fix templated route caching for passthrough api

* Remove caching for passthrough api
  • Loading branch information
paulkr authored May 17, 2024
1 parent 9e4aefe commit 765a272
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 31 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "integrationos-domain"
description = "Shared library for IntegrationOS"
license = "GPL-3.0"
version = "4.1.5"
version = "4.1.6"
edition = "2021"
repository = "https://github.com/integration-os/integrationos-domain"

Expand Down
55 changes: 25 additions & 30 deletions src/service/client/unified_destination_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1084,39 +1084,34 @@ impl UnifiedDestination {
})?
};

let config_fut = self
.connection_model_definitions_destination_cache
.try_get_with_by_ref(destination, async {
match self.get_connection_model_definition(destination).await {
let config = match self.get_connection_model_definition(destination).await {
Ok(Some(c)) => Ok(Arc::new(c)),
Ok(None) => Err(InternalError::key_not_found(
"ConnectionModelDefinition",
None,
)),
Err(e) => Err(InternalError::connection_error(e.message().as_ref(), None)),
}?;

let secret = self
.secrets_cache
.try_get_with_by_ref(&connection, async {
let secret_request = GetSecretRequest {
buildable_id: connection.ownership.id.to_string(),
id: connection.secrets_service_id.clone(),
};
match self
.secrets_client
.decrypt(&secret_request)
.map(|v| Some(v).transpose())
.await
{
Ok(Some(c)) => Ok(Arc::new(c)),
Ok(None) => Err(InternalError::key_not_found(
"ConnectionModelDefinition",
None,
)),
Ok(None) => Err(InternalError::key_not_found("Secrets", None)),
Err(e) => Err(InternalError::connection_error(e.message().as_ref(), None)),
}
});

let secret_fut = self.secrets_cache.try_get_with_by_ref(&connection, async {
let secret_request = GetSecretRequest {
buildable_id: connection.ownership.id.to_string(),
id: connection.secrets_service_id.clone(),
};
match self
.secrets_client
.decrypt(&secret_request)
.map(|v| Some(v).transpose())
.await
{
Ok(Some(c)) => Ok(Arc::new(c)),
Ok(None) => Err(InternalError::key_not_found("Secrets", None)),
Err(e) => Err(InternalError::connection_error(e.message().as_ref(), None)),
}
});

let join_result = join!(config_fut, secret_fut);
let config = join_result.0?;
let secret = join_result.1?;
})
.await?;

// Template the route for passthrough actions
let templated_config = match &destination.action {
Expand Down

0 comments on commit 765a272

Please sign in to comment.