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