-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* reset ml feed * reset ml feed * test * inc tick * add more tick * test print * test print * test print * final push * review changes
- Loading branch information
1 parent
54692ec
commit c373684
Showing
13 changed files
with
461 additions
and
16 deletions.
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
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
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
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
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
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
27 changes: 27 additions & 0 deletions
27
...nister/platform_orchestrator/src/api/canister_management/reset_canisters_ml_feed_cache.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,27 @@ | ||
use ic_cdk::{api::call::CallResult, call}; | ||
use ic_cdk_macros::update; | ||
|
||
use crate::{guard::is_caller::is_caller_global_admin_or_controller, CANISTER_DATA}; | ||
|
||
#[update(guard = "is_caller_global_admin_or_controller")] | ||
async fn reset_canisters_ml_feed_cache() -> Result<String, String> { | ||
let subnet_orchestrator_list = CANISTER_DATA | ||
.with_borrow(|canister_data| canister_data.all_subnet_orchestrator_canisters_list.clone()); | ||
|
||
for subnet_orchestrator in subnet_orchestrator_list { | ||
let result: CallResult<()> = call( | ||
subnet_orchestrator, | ||
"reset_user_canisters_ml_feed_cache", | ||
(), | ||
) | ||
.await; | ||
result.map_err(|e| { | ||
format!( | ||
"failed to call reset_user_canisters_ml_feed_cache for {} {}", | ||
subnet_orchestrator, e.1 | ||
) | ||
})?; | ||
} | ||
|
||
Ok("Success".into()) | ||
} |
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
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
30 changes: 30 additions & 0 deletions
30
src/canister/user_index/src/api/canister_management/reset_user_canister_ml_feed_cache.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,30 @@ | ||
use futures::StreamExt; | ||
use ic_cdk::api::call::CallResult; | ||
use ic_cdk_macros::update; | ||
|
||
use crate::CANISTER_DATA; | ||
use shared_utils::common::utils::permissions::is_caller_controller; | ||
|
||
#[update(guard = "is_caller_controller")] | ||
async fn reset_user_canisters_ml_feed_cache() -> String { | ||
ic_cdk::spawn(reset_user_canisters_ml_feed_cache_impl()); | ||
"Success".to_string() | ||
} | ||
|
||
async fn reset_user_canisters_ml_feed_cache_impl() { | ||
let canisters = CANISTER_DATA.with_borrow_mut(|canister_data| { | ||
canister_data | ||
.user_principal_id_to_canister_id_map | ||
.values() | ||
.cloned() | ||
.collect::<Vec<_>>() | ||
}); | ||
|
||
let futures = canisters.iter().map(|canister_id| async { | ||
let _: CallResult<()> = ic_cdk::call(*canister_id, "reset_ml_feed_cache", ()).await; | ||
}); | ||
|
||
let stream = futures::stream::iter(futures).boxed().buffer_unordered(25); | ||
|
||
let _ = stream.collect::<Vec<()>>().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
Oops, something went wrong.