diff --git a/src/libs/protocols/src/agent_ttrpc_async.rs b/src/libs/protocols/src/agent_ttrpc_async.rs deleted file mode 100644 index fd8979907d..0000000000 --- a/src/libs/protocols/src/agent_ttrpc_async.rs +++ /dev/null @@ -1,816 +0,0 @@ -// This file is generated by ttrpc-compiler 0.4.1. Do not edit -// @generated - -// https://github.com/Manishearth/rust-clippy/issues/702 -#![allow(unknown_lints)] -#![allow(clipto_camel_casepy)] - -#![cfg_attr(rustfmt, rustfmt_skip)] - -#![allow(box_pointers)] -#![allow(dead_code)] -#![allow(missing_docs)] -#![allow(non_camel_case_types)] -#![allow(non_snake_case)] -#![allow(non_upper_case_globals)] -#![allow(trivial_casts)] -#![allow(unsafe_code)] -#![allow(unused_imports)] -#![allow(unused_results)] -use protobuf::{CodedInputStream, CodedOutputStream, Message}; -use std::collections::HashMap; -use std::sync::Arc; -use async_trait::async_trait; - -#[derive(Clone)] -pub struct AgentServiceClient { - client: ::ttrpc::r#async::Client, -} - -impl AgentServiceClient { - pub fn new(client: ::ttrpc::r#async::Client) -> Self { - AgentServiceClient { - client: client, - } - } - - pub async fn create_container(&mut self, ctx: ttrpc::context::Context, req: &super::agent::CreateContainerRequest) -> ::ttrpc::Result { - let mut cres = super::empty::Empty::new(); - ::ttrpc::async_client_request!(self, ctx, req, "grpc.AgentService", "CreateContainer", cres); - } - - pub async fn start_container(&mut self, ctx: ttrpc::context::Context, req: &super::agent::StartContainerRequest) -> ::ttrpc::Result { - let mut cres = super::empty::Empty::new(); - ::ttrpc::async_client_request!(self, ctx, req, "grpc.AgentService", "StartContainer", cres); - } - - pub async fn remove_container(&mut self, ctx: ttrpc::context::Context, req: &super::agent::RemoveContainerRequest) -> ::ttrpc::Result { - let mut cres = super::empty::Empty::new(); - ::ttrpc::async_client_request!(self, ctx, req, "grpc.AgentService", "RemoveContainer", cres); - } - - pub async fn exec_process(&mut self, ctx: ttrpc::context::Context, req: &super::agent::ExecProcessRequest) -> ::ttrpc::Result { - let mut cres = super::empty::Empty::new(); - ::ttrpc::async_client_request!(self, ctx, req, "grpc.AgentService", "ExecProcess", cres); - } - - pub async fn signal_process(&mut self, ctx: ttrpc::context::Context, req: &super::agent::SignalProcessRequest) -> ::ttrpc::Result { - let mut cres = super::empty::Empty::new(); - ::ttrpc::async_client_request!(self, ctx, req, "grpc.AgentService", "SignalProcess", cres); - } - - pub async fn wait_process(&mut self, ctx: ttrpc::context::Context, req: &super::agent::WaitProcessRequest) -> ::ttrpc::Result { - let mut cres = super::agent::WaitProcessResponse::new(); - ::ttrpc::async_client_request!(self, ctx, req, "grpc.AgentService", "WaitProcess", cres); - } - - pub async fn update_container(&mut self, ctx: ttrpc::context::Context, req: &super::agent::UpdateContainerRequest) -> ::ttrpc::Result { - let mut cres = super::empty::Empty::new(); - ::ttrpc::async_client_request!(self, ctx, req, "grpc.AgentService", "UpdateContainer", cres); - } - - pub async fn stats_container(&mut self, ctx: ttrpc::context::Context, req: &super::agent::StatsContainerRequest) -> ::ttrpc::Result { - let mut cres = super::agent::StatsContainerResponse::new(); - ::ttrpc::async_client_request!(self, ctx, req, "grpc.AgentService", "StatsContainer", cres); - } - - pub async fn pause_container(&mut self, ctx: ttrpc::context::Context, req: &super::agent::PauseContainerRequest) -> ::ttrpc::Result { - let mut cres = super::empty::Empty::new(); - ::ttrpc::async_client_request!(self, ctx, req, "grpc.AgentService", "PauseContainer", cres); - } - - pub async fn resume_container(&mut self, ctx: ttrpc::context::Context, req: &super::agent::ResumeContainerRequest) -> ::ttrpc::Result { - let mut cres = super::empty::Empty::new(); - ::ttrpc::async_client_request!(self, ctx, req, "grpc.AgentService", "ResumeContainer", cres); - } - - pub async fn write_stdin(&mut self, ctx: ttrpc::context::Context, req: &super::agent::WriteStreamRequest) -> ::ttrpc::Result { - let mut cres = super::agent::WriteStreamResponse::new(); - ::ttrpc::async_client_request!(self, ctx, req, "grpc.AgentService", "WriteStdin", cres); - } - - pub async fn read_stdout(&mut self, ctx: ttrpc::context::Context, req: &super::agent::ReadStreamRequest) -> ::ttrpc::Result { - let mut cres = super::agent::ReadStreamResponse::new(); - ::ttrpc::async_client_request!(self, ctx, req, "grpc.AgentService", "ReadStdout", cres); - } - - pub async fn read_stderr(&mut self, ctx: ttrpc::context::Context, req: &super::agent::ReadStreamRequest) -> ::ttrpc::Result { - let mut cres = super::agent::ReadStreamResponse::new(); - ::ttrpc::async_client_request!(self, ctx, req, "grpc.AgentService", "ReadStderr", cres); - } - - pub async fn close_stdin(&mut self, ctx: ttrpc::context::Context, req: &super::agent::CloseStdinRequest) -> ::ttrpc::Result { - let mut cres = super::empty::Empty::new(); - ::ttrpc::async_client_request!(self, ctx, req, "grpc.AgentService", "CloseStdin", cres); - } - - pub async fn tty_win_resize(&mut self, ctx: ttrpc::context::Context, req: &super::agent::TtyWinResizeRequest) -> ::ttrpc::Result { - let mut cres = super::empty::Empty::new(); - ::ttrpc::async_client_request!(self, ctx, req, "grpc.AgentService", "TtyWinResize", cres); - } - - pub async fn update_interface(&mut self, ctx: ttrpc::context::Context, req: &super::agent::UpdateInterfaceRequest) -> ::ttrpc::Result { - let mut cres = super::types::Interface::new(); - ::ttrpc::async_client_request!(self, ctx, req, "grpc.AgentService", "UpdateInterface", cres); - } - - pub async fn update_routes(&mut self, ctx: ttrpc::context::Context, req: &super::agent::UpdateRoutesRequest) -> ::ttrpc::Result { - let mut cres = super::agent::Routes::new(); - ::ttrpc::async_client_request!(self, ctx, req, "grpc.AgentService", "UpdateRoutes", cres); - } - - pub async fn list_interfaces(&mut self, ctx: ttrpc::context::Context, req: &super::agent::ListInterfacesRequest) -> ::ttrpc::Result { - let mut cres = super::agent::Interfaces::new(); - ::ttrpc::async_client_request!(self, ctx, req, "grpc.AgentService", "ListInterfaces", cres); - } - - pub async fn list_routes(&mut self, ctx: ttrpc::context::Context, req: &super::agent::ListRoutesRequest) -> ::ttrpc::Result { - let mut cres = super::agent::Routes::new(); - ::ttrpc::async_client_request!(self, ctx, req, "grpc.AgentService", "ListRoutes", cres); - } - - pub async fn add_arp_neighbors(&mut self, ctx: ttrpc::context::Context, req: &super::agent::AddARPNeighborsRequest) -> ::ttrpc::Result { - let mut cres = super::empty::Empty::new(); - ::ttrpc::async_client_request!(self, ctx, req, "grpc.AgentService", "AddARPNeighbors", cres); - } - - pub async fn get_ip_tables(&mut self, ctx: ttrpc::context::Context, req: &super::agent::GetIPTablesRequest) -> ::ttrpc::Result { - let mut cres = super::agent::GetIPTablesResponse::new(); - ::ttrpc::async_client_request!(self, ctx, req, "grpc.AgentService", "GetIPTables", cres); - } - - pub async fn set_ip_tables(&mut self, ctx: ttrpc::context::Context, req: &super::agent::SetIPTablesRequest) -> ::ttrpc::Result { - let mut cres = super::agent::SetIPTablesResponse::new(); - ::ttrpc::async_client_request!(self, ctx, req, "grpc.AgentService", "SetIPTables", cres); - } - - pub async fn get_metrics(&mut self, ctx: ttrpc::context::Context, req: &super::agent::GetMetricsRequest) -> ::ttrpc::Result { - let mut cres = super::agent::Metrics::new(); - ::ttrpc::async_client_request!(self, ctx, req, "grpc.AgentService", "GetMetrics", cres); - } - - pub async fn create_sandbox(&mut self, ctx: ttrpc::context::Context, req: &super::agent::CreateSandboxRequest) -> ::ttrpc::Result { - let mut cres = super::empty::Empty::new(); - ::ttrpc::async_client_request!(self, ctx, req, "grpc.AgentService", "CreateSandbox", cres); - } - - pub async fn destroy_sandbox(&mut self, ctx: ttrpc::context::Context, req: &super::agent::DestroySandboxRequest) -> ::ttrpc::Result { - let mut cres = super::empty::Empty::new(); - ::ttrpc::async_client_request!(self, ctx, req, "grpc.AgentService", "DestroySandbox", cres); - } - - pub async fn online_cpu_mem(&mut self, ctx: ttrpc::context::Context, req: &super::agent::OnlineCPUMemRequest) -> ::ttrpc::Result { - let mut cres = super::empty::Empty::new(); - ::ttrpc::async_client_request!(self, ctx, req, "grpc.AgentService", "OnlineCPUMem", cres); - } - - pub async fn reseed_random_dev(&mut self, ctx: ttrpc::context::Context, req: &super::agent::ReseedRandomDevRequest) -> ::ttrpc::Result { - let mut cres = super::empty::Empty::new(); - ::ttrpc::async_client_request!(self, ctx, req, "grpc.AgentService", "ReseedRandomDev", cres); - } - - pub async fn get_guest_details(&mut self, ctx: ttrpc::context::Context, req: &super::agent::GuestDetailsRequest) -> ::ttrpc::Result { - let mut cres = super::agent::GuestDetailsResponse::new(); - ::ttrpc::async_client_request!(self, ctx, req, "grpc.AgentService", "GetGuestDetails", cres); - } - - pub async fn mem_hotplug_by_probe(&mut self, ctx: ttrpc::context::Context, req: &super::agent::MemHotplugByProbeRequest) -> ::ttrpc::Result { - let mut cres = super::empty::Empty::new(); - ::ttrpc::async_client_request!(self, ctx, req, "grpc.AgentService", "MemHotplugByProbe", cres); - } - - pub async fn set_guest_date_time(&mut self, ctx: ttrpc::context::Context, req: &super::agent::SetGuestDateTimeRequest) -> ::ttrpc::Result { - let mut cres = super::empty::Empty::new(); - ::ttrpc::async_client_request!(self, ctx, req, "grpc.AgentService", "SetGuestDateTime", cres); - } - - pub async fn copy_file(&mut self, ctx: ttrpc::context::Context, req: &super::agent::CopyFileRequest) -> ::ttrpc::Result { - let mut cres = super::empty::Empty::new(); - ::ttrpc::async_client_request!(self, ctx, req, "grpc.AgentService", "CopyFile", cres); - } - - pub async fn get_oom_event(&mut self, ctx: ttrpc::context::Context, req: &super::agent::GetOOMEventRequest) -> ::ttrpc::Result { - let mut cres = super::agent::OOMEvent::new(); - ::ttrpc::async_client_request!(self, ctx, req, "grpc.AgentService", "GetOOMEvent", cres); - } - - pub async fn add_swap(&mut self, ctx: ttrpc::context::Context, req: &super::agent::AddSwapRequest) -> ::ttrpc::Result { - let mut cres = super::empty::Empty::new(); - ::ttrpc::async_client_request!(self, ctx, req, "grpc.AgentService", "AddSwap", cres); - } - - pub async fn get_volume_stats(&mut self, ctx: ttrpc::context::Context, req: &super::agent::VolumeStatsRequest) -> ::ttrpc::Result { - let mut cres = super::csi::VolumeStatsResponse::new(); - ::ttrpc::async_client_request!(self, ctx, req, "grpc.AgentService", "GetVolumeStats", cres); - } - - pub async fn resize_volume(&mut self, ctx: ttrpc::context::Context, req: &super::agent::ResizeVolumeRequest) -> ::ttrpc::Result { - let mut cres = super::empty::Empty::new(); - ::ttrpc::async_client_request!(self, ctx, req, "grpc.AgentService", "ResizeVolume", cres); - } -} - -struct CreateContainerMethod { - service: Arc>, -} - -#[async_trait] -impl ::ttrpc::r#async::MethodHandler for CreateContainerMethod { - async fn handler(&self, ctx: ::ttrpc::r#async::TtrpcContext, req: ::ttrpc::Request) -> ::ttrpc::Result<(u32, Vec)> { - ::ttrpc::async_request_handler!(self, ctx, req, agent, CreateContainerRequest, create_container); - } -} - -struct StartContainerMethod { - service: Arc>, -} - -#[async_trait] -impl ::ttrpc::r#async::MethodHandler for StartContainerMethod { - async fn handler(&self, ctx: ::ttrpc::r#async::TtrpcContext, req: ::ttrpc::Request) -> ::ttrpc::Result<(u32, Vec)> { - ::ttrpc::async_request_handler!(self, ctx, req, agent, StartContainerRequest, start_container); - } -} - -struct RemoveContainerMethod { - service: Arc>, -} - -#[async_trait] -impl ::ttrpc::r#async::MethodHandler for RemoveContainerMethod { - async fn handler(&self, ctx: ::ttrpc::r#async::TtrpcContext, req: ::ttrpc::Request) -> ::ttrpc::Result<(u32, Vec)> { - ::ttrpc::async_request_handler!(self, ctx, req, agent, RemoveContainerRequest, remove_container); - } -} - -struct ExecProcessMethod { - service: Arc>, -} - -#[async_trait] -impl ::ttrpc::r#async::MethodHandler for ExecProcessMethod { - async fn handler(&self, ctx: ::ttrpc::r#async::TtrpcContext, req: ::ttrpc::Request) -> ::ttrpc::Result<(u32, Vec)> { - ::ttrpc::async_request_handler!(self, ctx, req, agent, ExecProcessRequest, exec_process); - } -} - -struct SignalProcessMethod { - service: Arc>, -} - -#[async_trait] -impl ::ttrpc::r#async::MethodHandler for SignalProcessMethod { - async fn handler(&self, ctx: ::ttrpc::r#async::TtrpcContext, req: ::ttrpc::Request) -> ::ttrpc::Result<(u32, Vec)> { - ::ttrpc::async_request_handler!(self, ctx, req, agent, SignalProcessRequest, signal_process); - } -} - -struct WaitProcessMethod { - service: Arc>, -} - -#[async_trait] -impl ::ttrpc::r#async::MethodHandler for WaitProcessMethod { - async fn handler(&self, ctx: ::ttrpc::r#async::TtrpcContext, req: ::ttrpc::Request) -> ::ttrpc::Result<(u32, Vec)> { - ::ttrpc::async_request_handler!(self, ctx, req, agent, WaitProcessRequest, wait_process); - } -} - -struct UpdateContainerMethod { - service: Arc>, -} - -#[async_trait] -impl ::ttrpc::r#async::MethodHandler for UpdateContainerMethod { - async fn handler(&self, ctx: ::ttrpc::r#async::TtrpcContext, req: ::ttrpc::Request) -> ::ttrpc::Result<(u32, Vec)> { - ::ttrpc::async_request_handler!(self, ctx, req, agent, UpdateContainerRequest, update_container); - } -} - -struct StatsContainerMethod { - service: Arc>, -} - -#[async_trait] -impl ::ttrpc::r#async::MethodHandler for StatsContainerMethod { - async fn handler(&self, ctx: ::ttrpc::r#async::TtrpcContext, req: ::ttrpc::Request) -> ::ttrpc::Result<(u32, Vec)> { - ::ttrpc::async_request_handler!(self, ctx, req, agent, StatsContainerRequest, stats_container); - } -} - -struct PauseContainerMethod { - service: Arc>, -} - -#[async_trait] -impl ::ttrpc::r#async::MethodHandler for PauseContainerMethod { - async fn handler(&self, ctx: ::ttrpc::r#async::TtrpcContext, req: ::ttrpc::Request) -> ::ttrpc::Result<(u32, Vec)> { - ::ttrpc::async_request_handler!(self, ctx, req, agent, PauseContainerRequest, pause_container); - } -} - -struct ResumeContainerMethod { - service: Arc>, -} - -#[async_trait] -impl ::ttrpc::r#async::MethodHandler for ResumeContainerMethod { - async fn handler(&self, ctx: ::ttrpc::r#async::TtrpcContext, req: ::ttrpc::Request) -> ::ttrpc::Result<(u32, Vec)> { - ::ttrpc::async_request_handler!(self, ctx, req, agent, ResumeContainerRequest, resume_container); - } -} - -struct WriteStdinMethod { - service: Arc>, -} - -#[async_trait] -impl ::ttrpc::r#async::MethodHandler for WriteStdinMethod { - async fn handler(&self, ctx: ::ttrpc::r#async::TtrpcContext, req: ::ttrpc::Request) -> ::ttrpc::Result<(u32, Vec)> { - ::ttrpc::async_request_handler!(self, ctx, req, agent, WriteStreamRequest, write_stdin); - } -} - -struct ReadStdoutMethod { - service: Arc>, -} - -#[async_trait] -impl ::ttrpc::r#async::MethodHandler for ReadStdoutMethod { - async fn handler(&self, ctx: ::ttrpc::r#async::TtrpcContext, req: ::ttrpc::Request) -> ::ttrpc::Result<(u32, Vec)> { - ::ttrpc::async_request_handler!(self, ctx, req, agent, ReadStreamRequest, read_stdout); - } -} - -struct ReadStderrMethod { - service: Arc>, -} - -#[async_trait] -impl ::ttrpc::r#async::MethodHandler for ReadStderrMethod { - async fn handler(&self, ctx: ::ttrpc::r#async::TtrpcContext, req: ::ttrpc::Request) -> ::ttrpc::Result<(u32, Vec)> { - ::ttrpc::async_request_handler!(self, ctx, req, agent, ReadStreamRequest, read_stderr); - } -} - -struct CloseStdinMethod { - service: Arc>, -} - -#[async_trait] -impl ::ttrpc::r#async::MethodHandler for CloseStdinMethod { - async fn handler(&self, ctx: ::ttrpc::r#async::TtrpcContext, req: ::ttrpc::Request) -> ::ttrpc::Result<(u32, Vec)> { - ::ttrpc::async_request_handler!(self, ctx, req, agent, CloseStdinRequest, close_stdin); - } -} - -struct TtyWinResizeMethod { - service: Arc>, -} - -#[async_trait] -impl ::ttrpc::r#async::MethodHandler for TtyWinResizeMethod { - async fn handler(&self, ctx: ::ttrpc::r#async::TtrpcContext, req: ::ttrpc::Request) -> ::ttrpc::Result<(u32, Vec)> { - ::ttrpc::async_request_handler!(self, ctx, req, agent, TtyWinResizeRequest, tty_win_resize); - } -} - -struct UpdateInterfaceMethod { - service: Arc>, -} - -#[async_trait] -impl ::ttrpc::r#async::MethodHandler for UpdateInterfaceMethod { - async fn handler(&self, ctx: ::ttrpc::r#async::TtrpcContext, req: ::ttrpc::Request) -> ::ttrpc::Result<(u32, Vec)> { - ::ttrpc::async_request_handler!(self, ctx, req, agent, UpdateInterfaceRequest, update_interface); - } -} - -struct UpdateRoutesMethod { - service: Arc>, -} - -#[async_trait] -impl ::ttrpc::r#async::MethodHandler for UpdateRoutesMethod { - async fn handler(&self, ctx: ::ttrpc::r#async::TtrpcContext, req: ::ttrpc::Request) -> ::ttrpc::Result<(u32, Vec)> { - ::ttrpc::async_request_handler!(self, ctx, req, agent, UpdateRoutesRequest, update_routes); - } -} - -struct ListInterfacesMethod { - service: Arc>, -} - -#[async_trait] -impl ::ttrpc::r#async::MethodHandler for ListInterfacesMethod { - async fn handler(&self, ctx: ::ttrpc::r#async::TtrpcContext, req: ::ttrpc::Request) -> ::ttrpc::Result<(u32, Vec)> { - ::ttrpc::async_request_handler!(self, ctx, req, agent, ListInterfacesRequest, list_interfaces); - } -} - -struct ListRoutesMethod { - service: Arc>, -} - -#[async_trait] -impl ::ttrpc::r#async::MethodHandler for ListRoutesMethod { - async fn handler(&self, ctx: ::ttrpc::r#async::TtrpcContext, req: ::ttrpc::Request) -> ::ttrpc::Result<(u32, Vec)> { - ::ttrpc::async_request_handler!(self, ctx, req, agent, ListRoutesRequest, list_routes); - } -} - -struct AddArpNeighborsMethod { - service: Arc>, -} - -#[async_trait] -impl ::ttrpc::r#async::MethodHandler for AddArpNeighborsMethod { - async fn handler(&self, ctx: ::ttrpc::r#async::TtrpcContext, req: ::ttrpc::Request) -> ::ttrpc::Result<(u32, Vec)> { - ::ttrpc::async_request_handler!(self, ctx, req, agent, AddARPNeighborsRequest, add_arp_neighbors); - } -} - -struct GetIpTablesMethod { - service: Arc>, -} - -#[async_trait] -impl ::ttrpc::r#async::MethodHandler for GetIpTablesMethod { - async fn handler(&self, ctx: ::ttrpc::r#async::TtrpcContext, req: ::ttrpc::Request) -> ::ttrpc::Result<(u32, Vec)> { - ::ttrpc::async_request_handler!(self, ctx, req, agent, GetIPTablesRequest, get_ip_tables); - } -} - -struct SetIpTablesMethod { - service: Arc>, -} - -#[async_trait] -impl ::ttrpc::r#async::MethodHandler for SetIpTablesMethod { - async fn handler(&self, ctx: ::ttrpc::r#async::TtrpcContext, req: ::ttrpc::Request) -> ::ttrpc::Result<(u32, Vec)> { - ::ttrpc::async_request_handler!(self, ctx, req, agent, SetIPTablesRequest, set_ip_tables); - } -} - -struct GetMetricsMethod { - service: Arc>, -} - -#[async_trait] -impl ::ttrpc::r#async::MethodHandler for GetMetricsMethod { - async fn handler(&self, ctx: ::ttrpc::r#async::TtrpcContext, req: ::ttrpc::Request) -> ::ttrpc::Result<(u32, Vec)> { - ::ttrpc::async_request_handler!(self, ctx, req, agent, GetMetricsRequest, get_metrics); - } -} - -struct CreateSandboxMethod { - service: Arc>, -} - -#[async_trait] -impl ::ttrpc::r#async::MethodHandler for CreateSandboxMethod { - async fn handler(&self, ctx: ::ttrpc::r#async::TtrpcContext, req: ::ttrpc::Request) -> ::ttrpc::Result<(u32, Vec)> { - ::ttrpc::async_request_handler!(self, ctx, req, agent, CreateSandboxRequest, create_sandbox); - } -} - -struct DestroySandboxMethod { - service: Arc>, -} - -#[async_trait] -impl ::ttrpc::r#async::MethodHandler for DestroySandboxMethod { - async fn handler(&self, ctx: ::ttrpc::r#async::TtrpcContext, req: ::ttrpc::Request) -> ::ttrpc::Result<(u32, Vec)> { - ::ttrpc::async_request_handler!(self, ctx, req, agent, DestroySandboxRequest, destroy_sandbox); - } -} - -struct OnlineCpuMemMethod { - service: Arc>, -} - -#[async_trait] -impl ::ttrpc::r#async::MethodHandler for OnlineCpuMemMethod { - async fn handler(&self, ctx: ::ttrpc::r#async::TtrpcContext, req: ::ttrpc::Request) -> ::ttrpc::Result<(u32, Vec)> { - ::ttrpc::async_request_handler!(self, ctx, req, agent, OnlineCPUMemRequest, online_cpu_mem); - } -} - -struct ReseedRandomDevMethod { - service: Arc>, -} - -#[async_trait] -impl ::ttrpc::r#async::MethodHandler for ReseedRandomDevMethod { - async fn handler(&self, ctx: ::ttrpc::r#async::TtrpcContext, req: ::ttrpc::Request) -> ::ttrpc::Result<(u32, Vec)> { - ::ttrpc::async_request_handler!(self, ctx, req, agent, ReseedRandomDevRequest, reseed_random_dev); - } -} - -struct GetGuestDetailsMethod { - service: Arc>, -} - -#[async_trait] -impl ::ttrpc::r#async::MethodHandler for GetGuestDetailsMethod { - async fn handler(&self, ctx: ::ttrpc::r#async::TtrpcContext, req: ::ttrpc::Request) -> ::ttrpc::Result<(u32, Vec)> { - ::ttrpc::async_request_handler!(self, ctx, req, agent, GuestDetailsRequest, get_guest_details); - } -} - -struct MemHotplugByProbeMethod { - service: Arc>, -} - -#[async_trait] -impl ::ttrpc::r#async::MethodHandler for MemHotplugByProbeMethod { - async fn handler(&self, ctx: ::ttrpc::r#async::TtrpcContext, req: ::ttrpc::Request) -> ::ttrpc::Result<(u32, Vec)> { - ::ttrpc::async_request_handler!(self, ctx, req, agent, MemHotplugByProbeRequest, mem_hotplug_by_probe); - } -} - -struct SetGuestDateTimeMethod { - service: Arc>, -} - -#[async_trait] -impl ::ttrpc::r#async::MethodHandler for SetGuestDateTimeMethod { - async fn handler(&self, ctx: ::ttrpc::r#async::TtrpcContext, req: ::ttrpc::Request) -> ::ttrpc::Result<(u32, Vec)> { - ::ttrpc::async_request_handler!(self, ctx, req, agent, SetGuestDateTimeRequest, set_guest_date_time); - } -} - -struct CopyFileMethod { - service: Arc>, -} - -#[async_trait] -impl ::ttrpc::r#async::MethodHandler for CopyFileMethod { - async fn handler(&self, ctx: ::ttrpc::r#async::TtrpcContext, req: ::ttrpc::Request) -> ::ttrpc::Result<(u32, Vec)> { - ::ttrpc::async_request_handler!(self, ctx, req, agent, CopyFileRequest, copy_file); - } -} - -struct GetOomEventMethod { - service: Arc>, -} - -#[async_trait] -impl ::ttrpc::r#async::MethodHandler for GetOomEventMethod { - async fn handler(&self, ctx: ::ttrpc::r#async::TtrpcContext, req: ::ttrpc::Request) -> ::ttrpc::Result<(u32, Vec)> { - ::ttrpc::async_request_handler!(self, ctx, req, agent, GetOOMEventRequest, get_oom_event); - } -} - -struct AddSwapMethod { - service: Arc>, -} - -#[async_trait] -impl ::ttrpc::r#async::MethodHandler for AddSwapMethod { - async fn handler(&self, ctx: ::ttrpc::r#async::TtrpcContext, req: ::ttrpc::Request) -> ::ttrpc::Result<(u32, Vec)> { - ::ttrpc::async_request_handler!(self, ctx, req, agent, AddSwapRequest, add_swap); - } -} - -struct GetVolumeStatsMethod { - service: Arc>, -} - -#[async_trait] -impl ::ttrpc::r#async::MethodHandler for GetVolumeStatsMethod { - async fn handler(&self, ctx: ::ttrpc::r#async::TtrpcContext, req: ::ttrpc::Request) -> ::ttrpc::Result<(u32, Vec)> { - ::ttrpc::async_request_handler!(self, ctx, req, agent, VolumeStatsRequest, get_volume_stats); - } -} - -struct ResizeVolumeMethod { - service: Arc>, -} - -#[async_trait] -impl ::ttrpc::r#async::MethodHandler for ResizeVolumeMethod { - async fn handler(&self, ctx: ::ttrpc::r#async::TtrpcContext, req: ::ttrpc::Request) -> ::ttrpc::Result<(u32, Vec)> { - ::ttrpc::async_request_handler!(self, ctx, req, agent, ResizeVolumeRequest, resize_volume); - } -} - -#[async_trait] -pub trait AgentService: Sync { - async fn create_container(&self, _ctx: &::ttrpc::r#async::TtrpcContext, _req: super::agent::CreateContainerRequest) -> ::ttrpc::Result { - Err(::ttrpc::Error::RpcStatus(::ttrpc::get_status(::ttrpc::Code::NOT_FOUND, "/grpc.AgentService/CreateContainer is not supported".to_string()))) - } - async fn start_container(&self, _ctx: &::ttrpc::r#async::TtrpcContext, _req: super::agent::StartContainerRequest) -> ::ttrpc::Result { - Err(::ttrpc::Error::RpcStatus(::ttrpc::get_status(::ttrpc::Code::NOT_FOUND, "/grpc.AgentService/StartContainer is not supported".to_string()))) - } - async fn remove_container(&self, _ctx: &::ttrpc::r#async::TtrpcContext, _req: super::agent::RemoveContainerRequest) -> ::ttrpc::Result { - Err(::ttrpc::Error::RpcStatus(::ttrpc::get_status(::ttrpc::Code::NOT_FOUND, "/grpc.AgentService/RemoveContainer is not supported".to_string()))) - } - async fn exec_process(&self, _ctx: &::ttrpc::r#async::TtrpcContext, _req: super::agent::ExecProcessRequest) -> ::ttrpc::Result { - Err(::ttrpc::Error::RpcStatus(::ttrpc::get_status(::ttrpc::Code::NOT_FOUND, "/grpc.AgentService/ExecProcess is not supported".to_string()))) - } - async fn signal_process(&self, _ctx: &::ttrpc::r#async::TtrpcContext, _req: super::agent::SignalProcessRequest) -> ::ttrpc::Result { - Err(::ttrpc::Error::RpcStatus(::ttrpc::get_status(::ttrpc::Code::NOT_FOUND, "/grpc.AgentService/SignalProcess is not supported".to_string()))) - } - async fn wait_process(&self, _ctx: &::ttrpc::r#async::TtrpcContext, _req: super::agent::WaitProcessRequest) -> ::ttrpc::Result { - Err(::ttrpc::Error::RpcStatus(::ttrpc::get_status(::ttrpc::Code::NOT_FOUND, "/grpc.AgentService/WaitProcess is not supported".to_string()))) - } - async fn update_container(&self, _ctx: &::ttrpc::r#async::TtrpcContext, _req: super::agent::UpdateContainerRequest) -> ::ttrpc::Result { - Err(::ttrpc::Error::RpcStatus(::ttrpc::get_status(::ttrpc::Code::NOT_FOUND, "/grpc.AgentService/UpdateContainer is not supported".to_string()))) - } - async fn stats_container(&self, _ctx: &::ttrpc::r#async::TtrpcContext, _req: super::agent::StatsContainerRequest) -> ::ttrpc::Result { - Err(::ttrpc::Error::RpcStatus(::ttrpc::get_status(::ttrpc::Code::NOT_FOUND, "/grpc.AgentService/StatsContainer is not supported".to_string()))) - } - async fn pause_container(&self, _ctx: &::ttrpc::r#async::TtrpcContext, _req: super::agent::PauseContainerRequest) -> ::ttrpc::Result { - Err(::ttrpc::Error::RpcStatus(::ttrpc::get_status(::ttrpc::Code::NOT_FOUND, "/grpc.AgentService/PauseContainer is not supported".to_string()))) - } - async fn resume_container(&self, _ctx: &::ttrpc::r#async::TtrpcContext, _req: super::agent::ResumeContainerRequest) -> ::ttrpc::Result { - Err(::ttrpc::Error::RpcStatus(::ttrpc::get_status(::ttrpc::Code::NOT_FOUND, "/grpc.AgentService/ResumeContainer is not supported".to_string()))) - } - async fn write_stdin(&self, _ctx: &::ttrpc::r#async::TtrpcContext, _req: super::agent::WriteStreamRequest) -> ::ttrpc::Result { - Err(::ttrpc::Error::RpcStatus(::ttrpc::get_status(::ttrpc::Code::NOT_FOUND, "/grpc.AgentService/WriteStdin is not supported".to_string()))) - } - async fn read_stdout(&self, _ctx: &::ttrpc::r#async::TtrpcContext, _req: super::agent::ReadStreamRequest) -> ::ttrpc::Result { - Err(::ttrpc::Error::RpcStatus(::ttrpc::get_status(::ttrpc::Code::NOT_FOUND, "/grpc.AgentService/ReadStdout is not supported".to_string()))) - } - async fn read_stderr(&self, _ctx: &::ttrpc::r#async::TtrpcContext, _req: super::agent::ReadStreamRequest) -> ::ttrpc::Result { - Err(::ttrpc::Error::RpcStatus(::ttrpc::get_status(::ttrpc::Code::NOT_FOUND, "/grpc.AgentService/ReadStderr is not supported".to_string()))) - } - async fn close_stdin(&self, _ctx: &::ttrpc::r#async::TtrpcContext, _req: super::agent::CloseStdinRequest) -> ::ttrpc::Result { - Err(::ttrpc::Error::RpcStatus(::ttrpc::get_status(::ttrpc::Code::NOT_FOUND, "/grpc.AgentService/CloseStdin is not supported".to_string()))) - } - async fn tty_win_resize(&self, _ctx: &::ttrpc::r#async::TtrpcContext, _req: super::agent::TtyWinResizeRequest) -> ::ttrpc::Result { - Err(::ttrpc::Error::RpcStatus(::ttrpc::get_status(::ttrpc::Code::NOT_FOUND, "/grpc.AgentService/TtyWinResize is not supported".to_string()))) - } - async fn update_interface(&self, _ctx: &::ttrpc::r#async::TtrpcContext, _req: super::agent::UpdateInterfaceRequest) -> ::ttrpc::Result { - Err(::ttrpc::Error::RpcStatus(::ttrpc::get_status(::ttrpc::Code::NOT_FOUND, "/grpc.AgentService/UpdateInterface is not supported".to_string()))) - } - async fn update_routes(&self, _ctx: &::ttrpc::r#async::TtrpcContext, _req: super::agent::UpdateRoutesRequest) -> ::ttrpc::Result { - Err(::ttrpc::Error::RpcStatus(::ttrpc::get_status(::ttrpc::Code::NOT_FOUND, "/grpc.AgentService/UpdateRoutes is not supported".to_string()))) - } - async fn list_interfaces(&self, _ctx: &::ttrpc::r#async::TtrpcContext, _req: super::agent::ListInterfacesRequest) -> ::ttrpc::Result { - Err(::ttrpc::Error::RpcStatus(::ttrpc::get_status(::ttrpc::Code::NOT_FOUND, "/grpc.AgentService/ListInterfaces is not supported".to_string()))) - } - async fn list_routes(&self, _ctx: &::ttrpc::r#async::TtrpcContext, _req: super::agent::ListRoutesRequest) -> ::ttrpc::Result { - Err(::ttrpc::Error::RpcStatus(::ttrpc::get_status(::ttrpc::Code::NOT_FOUND, "/grpc.AgentService/ListRoutes is not supported".to_string()))) - } - async fn add_arp_neighbors(&self, _ctx: &::ttrpc::r#async::TtrpcContext, _req: super::agent::AddARPNeighborsRequest) -> ::ttrpc::Result { - Err(::ttrpc::Error::RpcStatus(::ttrpc::get_status(::ttrpc::Code::NOT_FOUND, "/grpc.AgentService/AddARPNeighbors is not supported".to_string()))) - } - async fn get_ip_tables(&self, _ctx: &::ttrpc::r#async::TtrpcContext, _req: super::agent::GetIPTablesRequest) -> ::ttrpc::Result { - Err(::ttrpc::Error::RpcStatus(::ttrpc::get_status(::ttrpc::Code::NOT_FOUND, "/grpc.AgentService/GetIPTables is not supported".to_string()))) - } - async fn set_ip_tables(&self, _ctx: &::ttrpc::r#async::TtrpcContext, _req: super::agent::SetIPTablesRequest) -> ::ttrpc::Result { - Err(::ttrpc::Error::RpcStatus(::ttrpc::get_status(::ttrpc::Code::NOT_FOUND, "/grpc.AgentService/SetIPTables is not supported".to_string()))) - } - async fn get_metrics(&self, _ctx: &::ttrpc::r#async::TtrpcContext, _req: super::agent::GetMetricsRequest) -> ::ttrpc::Result { - Err(::ttrpc::Error::RpcStatus(::ttrpc::get_status(::ttrpc::Code::NOT_FOUND, "/grpc.AgentService/GetMetrics is not supported".to_string()))) - } - async fn create_sandbox(&self, _ctx: &::ttrpc::r#async::TtrpcContext, _req: super::agent::CreateSandboxRequest) -> ::ttrpc::Result { - Err(::ttrpc::Error::RpcStatus(::ttrpc::get_status(::ttrpc::Code::NOT_FOUND, "/grpc.AgentService/CreateSandbox is not supported".to_string()))) - } - async fn destroy_sandbox(&self, _ctx: &::ttrpc::r#async::TtrpcContext, _req: super::agent::DestroySandboxRequest) -> ::ttrpc::Result { - Err(::ttrpc::Error::RpcStatus(::ttrpc::get_status(::ttrpc::Code::NOT_FOUND, "/grpc.AgentService/DestroySandbox is not supported".to_string()))) - } - async fn online_cpu_mem(&self, _ctx: &::ttrpc::r#async::TtrpcContext, _req: super::agent::OnlineCPUMemRequest) -> ::ttrpc::Result { - Err(::ttrpc::Error::RpcStatus(::ttrpc::get_status(::ttrpc::Code::NOT_FOUND, "/grpc.AgentService/OnlineCPUMem is not supported".to_string()))) - } - async fn reseed_random_dev(&self, _ctx: &::ttrpc::r#async::TtrpcContext, _req: super::agent::ReseedRandomDevRequest) -> ::ttrpc::Result { - Err(::ttrpc::Error::RpcStatus(::ttrpc::get_status(::ttrpc::Code::NOT_FOUND, "/grpc.AgentService/ReseedRandomDev is not supported".to_string()))) - } - async fn get_guest_details(&self, _ctx: &::ttrpc::r#async::TtrpcContext, _req: super::agent::GuestDetailsRequest) -> ::ttrpc::Result { - Err(::ttrpc::Error::RpcStatus(::ttrpc::get_status(::ttrpc::Code::NOT_FOUND, "/grpc.AgentService/GetGuestDetails is not supported".to_string()))) - } - async fn mem_hotplug_by_probe(&self, _ctx: &::ttrpc::r#async::TtrpcContext, _req: super::agent::MemHotplugByProbeRequest) -> ::ttrpc::Result { - Err(::ttrpc::Error::RpcStatus(::ttrpc::get_status(::ttrpc::Code::NOT_FOUND, "/grpc.AgentService/MemHotplugByProbe is not supported".to_string()))) - } - async fn set_guest_date_time(&self, _ctx: &::ttrpc::r#async::TtrpcContext, _req: super::agent::SetGuestDateTimeRequest) -> ::ttrpc::Result { - Err(::ttrpc::Error::RpcStatus(::ttrpc::get_status(::ttrpc::Code::NOT_FOUND, "/grpc.AgentService/SetGuestDateTime is not supported".to_string()))) - } - async fn copy_file(&self, _ctx: &::ttrpc::r#async::TtrpcContext, _req: super::agent::CopyFileRequest) -> ::ttrpc::Result { - Err(::ttrpc::Error::RpcStatus(::ttrpc::get_status(::ttrpc::Code::NOT_FOUND, "/grpc.AgentService/CopyFile is not supported".to_string()))) - } - async fn get_oom_event(&self, _ctx: &::ttrpc::r#async::TtrpcContext, _req: super::agent::GetOOMEventRequest) -> ::ttrpc::Result { - Err(::ttrpc::Error::RpcStatus(::ttrpc::get_status(::ttrpc::Code::NOT_FOUND, "/grpc.AgentService/GetOOMEvent is not supported".to_string()))) - } - async fn add_swap(&self, _ctx: &::ttrpc::r#async::TtrpcContext, _req: super::agent::AddSwapRequest) -> ::ttrpc::Result { - Err(::ttrpc::Error::RpcStatus(::ttrpc::get_status(::ttrpc::Code::NOT_FOUND, "/grpc.AgentService/AddSwap is not supported".to_string()))) - } - async fn get_volume_stats(&self, _ctx: &::ttrpc::r#async::TtrpcContext, _req: super::agent::VolumeStatsRequest) -> ::ttrpc::Result { - Err(::ttrpc::Error::RpcStatus(::ttrpc::get_status(::ttrpc::Code::NOT_FOUND, "/grpc.AgentService/GetVolumeStats is not supported".to_string()))) - } - async fn resize_volume(&self, _ctx: &::ttrpc::r#async::TtrpcContext, _req: super::agent::ResizeVolumeRequest) -> ::ttrpc::Result { - Err(::ttrpc::Error::RpcStatus(::ttrpc::get_status(::ttrpc::Code::NOT_FOUND, "/grpc.AgentService/ResizeVolume is not supported".to_string()))) - } -} - -pub fn create_agent_service(service: Arc>) -> HashMap > { - let mut methods = HashMap::new(); - - methods.insert("/grpc.AgentService/CreateContainer".to_string(), - std::boxed::Box::new(CreateContainerMethod{service: service.clone()}) as std::boxed::Box); - - methods.insert("/grpc.AgentService/StartContainer".to_string(), - std::boxed::Box::new(StartContainerMethod{service: service.clone()}) as std::boxed::Box); - - methods.insert("/grpc.AgentService/RemoveContainer".to_string(), - std::boxed::Box::new(RemoveContainerMethod{service: service.clone()}) as std::boxed::Box); - - methods.insert("/grpc.AgentService/ExecProcess".to_string(), - std::boxed::Box::new(ExecProcessMethod{service: service.clone()}) as std::boxed::Box); - - methods.insert("/grpc.AgentService/SignalProcess".to_string(), - std::boxed::Box::new(SignalProcessMethod{service: service.clone()}) as std::boxed::Box); - - methods.insert("/grpc.AgentService/WaitProcess".to_string(), - std::boxed::Box::new(WaitProcessMethod{service: service.clone()}) as std::boxed::Box); - - methods.insert("/grpc.AgentService/UpdateContainer".to_string(), - std::boxed::Box::new(UpdateContainerMethod{service: service.clone()}) as std::boxed::Box); - - methods.insert("/grpc.AgentService/StatsContainer".to_string(), - std::boxed::Box::new(StatsContainerMethod{service: service.clone()}) as std::boxed::Box); - - methods.insert("/grpc.AgentService/PauseContainer".to_string(), - std::boxed::Box::new(PauseContainerMethod{service: service.clone()}) as std::boxed::Box); - - methods.insert("/grpc.AgentService/ResumeContainer".to_string(), - std::boxed::Box::new(ResumeContainerMethod{service: service.clone()}) as std::boxed::Box); - - methods.insert("/grpc.AgentService/WriteStdin".to_string(), - std::boxed::Box::new(WriteStdinMethod{service: service.clone()}) as std::boxed::Box); - - methods.insert("/grpc.AgentService/ReadStdout".to_string(), - std::boxed::Box::new(ReadStdoutMethod{service: service.clone()}) as std::boxed::Box); - - methods.insert("/grpc.AgentService/ReadStderr".to_string(), - std::boxed::Box::new(ReadStderrMethod{service: service.clone()}) as std::boxed::Box); - - methods.insert("/grpc.AgentService/CloseStdin".to_string(), - std::boxed::Box::new(CloseStdinMethod{service: service.clone()}) as std::boxed::Box); - - methods.insert("/grpc.AgentService/TtyWinResize".to_string(), - std::boxed::Box::new(TtyWinResizeMethod{service: service.clone()}) as std::boxed::Box); - - methods.insert("/grpc.AgentService/UpdateInterface".to_string(), - std::boxed::Box::new(UpdateInterfaceMethod{service: service.clone()}) as std::boxed::Box); - - methods.insert("/grpc.AgentService/UpdateRoutes".to_string(), - std::boxed::Box::new(UpdateRoutesMethod{service: service.clone()}) as std::boxed::Box); - - methods.insert("/grpc.AgentService/ListInterfaces".to_string(), - std::boxed::Box::new(ListInterfacesMethod{service: service.clone()}) as std::boxed::Box); - - methods.insert("/grpc.AgentService/ListRoutes".to_string(), - std::boxed::Box::new(ListRoutesMethod{service: service.clone()}) as std::boxed::Box); - - methods.insert("/grpc.AgentService/AddARPNeighbors".to_string(), - std::boxed::Box::new(AddArpNeighborsMethod{service: service.clone()}) as std::boxed::Box); - - methods.insert("/grpc.AgentService/GetIPTables".to_string(), - std::boxed::Box::new(GetIpTablesMethod{service: service.clone()}) as std::boxed::Box); - - methods.insert("/grpc.AgentService/SetIPTables".to_string(), - std::boxed::Box::new(SetIpTablesMethod{service: service.clone()}) as std::boxed::Box); - - methods.insert("/grpc.AgentService/GetMetrics".to_string(), - std::boxed::Box::new(GetMetricsMethod{service: service.clone()}) as std::boxed::Box); - - methods.insert("/grpc.AgentService/CreateSandbox".to_string(), - std::boxed::Box::new(CreateSandboxMethod{service: service.clone()}) as std::boxed::Box); - - methods.insert("/grpc.AgentService/DestroySandbox".to_string(), - std::boxed::Box::new(DestroySandboxMethod{service: service.clone()}) as std::boxed::Box); - - methods.insert("/grpc.AgentService/OnlineCPUMem".to_string(), - std::boxed::Box::new(OnlineCpuMemMethod{service: service.clone()}) as std::boxed::Box); - - methods.insert("/grpc.AgentService/ReseedRandomDev".to_string(), - std::boxed::Box::new(ReseedRandomDevMethod{service: service.clone()}) as std::boxed::Box); - - methods.insert("/grpc.AgentService/GetGuestDetails".to_string(), - std::boxed::Box::new(GetGuestDetailsMethod{service: service.clone()}) as std::boxed::Box); - - methods.insert("/grpc.AgentService/MemHotplugByProbe".to_string(), - std::boxed::Box::new(MemHotplugByProbeMethod{service: service.clone()}) as std::boxed::Box); - - methods.insert("/grpc.AgentService/SetGuestDateTime".to_string(), - std::boxed::Box::new(SetGuestDateTimeMethod{service: service.clone()}) as std::boxed::Box); - - methods.insert("/grpc.AgentService/CopyFile".to_string(), - std::boxed::Box::new(CopyFileMethod{service: service.clone()}) as std::boxed::Box); - - methods.insert("/grpc.AgentService/GetOOMEvent".to_string(), - std::boxed::Box::new(GetOomEventMethod{service: service.clone()}) as std::boxed::Box); - - methods.insert("/grpc.AgentService/AddSwap".to_string(), - std::boxed::Box::new(AddSwapMethod{service: service.clone()}) as std::boxed::Box); - - methods.insert("/grpc.AgentService/GetVolumeStats".to_string(), - std::boxed::Box::new(GetVolumeStatsMethod{service: service.clone()}) as std::boxed::Box); - - methods.insert("/grpc.AgentService/ResizeVolume".to_string(), - std::boxed::Box::new(ResizeVolumeMethod{service: service.clone()}) as std::boxed::Box); - - methods -} diff --git a/src/libs/protocols/src/health_ttrpc_async.rs b/src/libs/protocols/src/health_ttrpc_async.rs deleted file mode 100644 index 5f77b30e75..0000000000 --- a/src/libs/protocols/src/health_ttrpc_async.rs +++ /dev/null @@ -1,90 +0,0 @@ -// This file is generated by ttrpc-compiler 0.4.1. Do not edit -// @generated - -// https://github.com/Manishearth/rust-clippy/issues/702 -#![allow(unknown_lints)] -#![allow(clipto_camel_casepy)] - -#![cfg_attr(rustfmt, rustfmt_skip)] - -#![allow(box_pointers)] -#![allow(dead_code)] -#![allow(missing_docs)] -#![allow(non_camel_case_types)] -#![allow(non_snake_case)] -#![allow(non_upper_case_globals)] -#![allow(trivial_casts)] -#![allow(unsafe_code)] -#![allow(unused_imports)] -#![allow(unused_results)] -use protobuf::{CodedInputStream, CodedOutputStream, Message}; -use std::collections::HashMap; -use std::sync::Arc; -use async_trait::async_trait; - -#[derive(Clone)] -pub struct HealthClient { - client: ::ttrpc::r#async::Client, -} - -impl HealthClient { - pub fn new(client: ::ttrpc::r#async::Client) -> Self { - HealthClient { - client: client, - } - } - - pub async fn check(&mut self, ctx: ttrpc::context::Context, req: &super::health::CheckRequest) -> ::ttrpc::Result { - let mut cres = super::health::HealthCheckResponse::new(); - ::ttrpc::async_client_request!(self, ctx, req, "grpc.Health", "Check", cres); - } - - pub async fn version(&mut self, ctx: ttrpc::context::Context, req: &super::health::CheckRequest) -> ::ttrpc::Result { - let mut cres = super::health::VersionCheckResponse::new(); - ::ttrpc::async_client_request!(self, ctx, req, "grpc.Health", "Version", cres); - } -} - -struct CheckMethod { - service: Arc>, -} - -#[async_trait] -impl ::ttrpc::r#async::MethodHandler for CheckMethod { - async fn handler(&self, ctx: ::ttrpc::r#async::TtrpcContext, req: ::ttrpc::Request) -> ::ttrpc::Result<(u32, Vec)> { - ::ttrpc::async_request_handler!(self, ctx, req, health, CheckRequest, check); - } -} - -struct VersionMethod { - service: Arc>, -} - -#[async_trait] -impl ::ttrpc::r#async::MethodHandler for VersionMethod { - async fn handler(&self, ctx: ::ttrpc::r#async::TtrpcContext, req: ::ttrpc::Request) -> ::ttrpc::Result<(u32, Vec)> { - ::ttrpc::async_request_handler!(self, ctx, req, health, CheckRequest, version); - } -} - -#[async_trait] -pub trait Health: Sync { - async fn check(&self, _ctx: &::ttrpc::r#async::TtrpcContext, _req: super::health::CheckRequest) -> ::ttrpc::Result { - Err(::ttrpc::Error::RpcStatus(::ttrpc::get_status(::ttrpc::Code::NOT_FOUND, "/grpc.Health/Check is not supported".to_string()))) - } - async fn version(&self, _ctx: &::ttrpc::r#async::TtrpcContext, _req: super::health::CheckRequest) -> ::ttrpc::Result { - Err(::ttrpc::Error::RpcStatus(::ttrpc::get_status(::ttrpc::Code::NOT_FOUND, "/grpc.Health/Version is not supported".to_string()))) - } -} - -pub fn create_health(service: Arc>) -> HashMap > { - let mut methods = HashMap::new(); - - methods.insert("/grpc.Health/Check".to_string(), - std::boxed::Box::new(CheckMethod{service: service.clone()}) as std::boxed::Box); - - methods.insert("/grpc.Health/Version".to_string(), - std::boxed::Box::new(VersionMethod{service: service.clone()}) as std::boxed::Box); - - methods -}