Mountain/RPC/CocoonService/Initialization/
CancelOperation.rs1#![allow(non_snake_case)]
2
3use tonic::{Response, Status};
7
8use crate::{
9 RPC::CocoonService::CocoonServiceImpl,
10 Vine::Generated::{CancelOperationRequest, Empty},
11 dev_log,
12};
13
14pub async fn Fn(Service:&CocoonServiceImpl, Request:CancelOperationRequest) -> Result<Response<Empty>, Status> {
15 dev_log!(
16 "cocoon",
17 "[CocoonService] Cancel operation request: {}",
18 Request.request_identifier_to_cancel
19 );
20
21 if let Some(Token) = Service.ActiveOperations.read().await.get(&Request.request_identifier_to_cancel) {
22 dev_log!(
23 "cocoon",
24 "[CocoonService] Triggering cancellation token for operation {}",
25 Request.request_identifier_to_cancel
26 );
27 Token.cancel();
28 } else {
29 dev_log!(
30 "cocoon",
31 "warn: [CocoonService] No active operation found for cancellation: {}",
32 Request.request_identifier_to_cancel
33 );
34 }
35
36 Ok(Response::new(Empty {}))
37}