agent: Remove casting and fix Arc declaration

Removed unnecessary dynamic dispatch for services. Properly dereferenced
service Box values and stored in Arc.

Co-authored-by: Ruoqing He <heruoqing@iscas.ac.cn>
Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
Signed-Off-By: Ryan Savino <ryan.savino@amd.com>
This commit is contained in:
Ryan Savino 2025-06-04 01:09:44 +00:00 committed by Ruoqing He
parent 0471f01074
commit 1e686dbca7
2 changed files with 6 additions and 7 deletions

View File

@ -270,9 +270,8 @@ mod tests {
fn start_ttrpc_server(cdh_socket_uri: String) {
tokio::spawn(async move {
let ss = Box::new(TestService {})
as Box<dyn confidential_data_hub_ttrpc_async::SealedSecretService + Send + Sync>;
let ss = Arc::new(ss);
let ss = Box::new(TestService {});
let ss = Arc::new(*ss);
let ss_service = confidential_data_hub_ttrpc_async::create_sealed_secret_service(ss);
remove_if_sock_exist(&cdh_socket_uri).unwrap();

View File

@ -1796,11 +1796,11 @@ pub async fn start(
sandbox: s,
init_mode,
oma,
}) as Box<dyn agent_ttrpc::AgentService + Send + Sync>;
let aservice = agent_ttrpc::create_agent_service(Arc::new(agent_service));
});
let aservice = agent_ttrpc::create_agent_service(Arc::new(*agent_service));
let health_service = Box::new(HealthService {}) as Box<dyn health_ttrpc::Health + Send + Sync>;
let hservice = health_ttrpc::create_health(Arc::new(health_service));
let health_service = Box::new(HealthService {});
let hservice = health_ttrpc::create_health(Arc::new(*health_service));
let server = TtrpcServer::new()
.bind(server_address)?