-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8e16eb8
commit f260c85
Showing
3 changed files
with
73 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
pub mod iam_kv_client; | ||
pub mod iam_log_client; | ||
pub mod iam_search_client; | ||
pub mod mail_client; | ||
|
66 changes: 66 additions & 0 deletions
66
backend/supports/iam/src/basic/serv/clients/iam_kv_client.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
use bios_basic::rbum::rbum_enumeration::RbumScopeLevelKind; | ||
use bios_sdk_invoke::clients::spi_kv_client::SpiKvClient; | ||
use tardis::tokio; | ||
use tardis::{ | ||
basic::{dto::TardisContext, result::TardisResult}, | ||
serde_json::Value, | ||
TardisFunsInst, | ||
}; | ||
|
||
use crate::iam_constants; | ||
|
||
pub struct IamKvClient; | ||
|
||
impl IamKvClient { | ||
pub async fn async_add_or_modify_item( | ||
key: String, | ||
value: Value, | ||
info: Option<String>, | ||
scope_level: Option<RbumScopeLevelKind>, | ||
_funs: &TardisFunsInst, | ||
ctx: &TardisContext, | ||
) -> TardisResult<()> { | ||
let ctx_clone = ctx.clone(); | ||
ctx.add_async_task(Box::new(|| { | ||
Box::pin(async move { | ||
let task_handle = tokio::spawn(async move { | ||
let funs = iam_constants::get_tardis_inst(); | ||
let _ = Self::add_or_modify_item(&key, &value, info, scope_level, &funs, &ctx_clone).await; | ||
}); | ||
task_handle.await.unwrap(); | ||
Ok(()) | ||
}) | ||
})) | ||
.await | ||
} | ||
|
||
pub async fn async_delete_item(key: String, _funs: &TardisFunsInst, ctx: &TardisContext) -> TardisResult<()> { | ||
let ctx_clone = ctx.clone(); | ||
ctx.add_async_task(Box::new(|| { | ||
Box::pin(async move { | ||
let task_handle = tokio::spawn(async move { | ||
let funs = iam_constants::get_tardis_inst(); | ||
let _ = Self::delete_item(&key, &funs, &ctx_clone).await; | ||
}); | ||
task_handle.await.unwrap(); | ||
Ok(()) | ||
}) | ||
})) | ||
.await | ||
} | ||
|
||
pub async fn add_or_modify_item( | ||
key: &str, | ||
value: &Value, | ||
info: Option<String>, | ||
scope_level: Option<RbumScopeLevelKind>, | ||
funs: &TardisFunsInst, | ||
ctx: &TardisContext, | ||
) -> TardisResult<()> { | ||
SpiKvClient::add_or_modify_item(key, value, info, scope_level.map(|kind| kind.to_int()), funs, ctx).await | ||
} | ||
|
||
pub async fn delete_item(key: &str, funs: &TardisFunsInst, ctx: &TardisContext) -> TardisResult<()> { | ||
SpiKvClient::delete_item(key, funs, ctx).await | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters