#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RegisterPeerRequest {
#[prost(message, optional, tag = "1")]
pub download: ::core::option::Option<super::common::Download>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RegisterSeedPeerRequest {
#[prost(message, optional, tag = "1")]
pub download: ::core::option::Option<super::common::Download>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DownloadPeerStartedRequest {}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DownloadPeerBackToSourceStartedRequest {
#[prost(string, tag = "1")]
pub description: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DownloadPeerFinishedRequest {
#[prost(int64, tag = "1")]
pub content_length: i64,
#[prost(int32, tag = "2")]
pub piece_count: i32,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DownloadPeerBackToSourceFinishedRequest {
#[prost(int64, tag = "1")]
pub content_length: i64,
#[prost(int32, tag = "2")]
pub piece_count: i32,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DownloadPeerFailedRequest {
#[prost(string, tag = "1")]
pub description: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DownloadPeerBackToSourceFailedRequest {
#[prost(string, tag = "1")]
pub description: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DownloadPieceFinishedRequest {
#[prost(message, optional, tag = "1")]
pub piece: ::core::option::Option<super::common::Piece>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DownloadPieceBackToSourceFinishedRequest {
#[prost(message, optional, tag = "1")]
pub piece: ::core::option::Option<super::common::Piece>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DownloadPieceFailedRequest {
#[prost(message, optional, tag = "1")]
pub piece: ::core::option::Option<super::common::Piece>,
#[prost(bool, tag = "2")]
pub temporary: bool,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct HttpResponse {
#[prost(map = "string, string", tag = "1")]
pub header: ::std::collections::HashMap<
::prost::alloc::string::String,
::prost::alloc::string::String,
>,
#[prost(int32, tag = "2")]
pub status_code: i32,
#[prost(string, tag = "3")]
pub status: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct HdfsResponse {}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct S3Response {}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct OssResponse {}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DownloadPieceBackToSourceFailedRequest {
#[prost(message, optional, tag = "1")]
pub piece: ::core::option::Option<super::common::Piece>,
#[prost(
oneof = "download_piece_back_to_source_failed_request::Response",
tags = "2, 3, 4, 5"
)]
pub response: ::core::option::Option<
download_piece_back_to_source_failed_request::Response,
>,
}
pub mod download_piece_back_to_source_failed_request {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Response {
#[prost(message, tag = "2")]
HttpResponse(super::HttpResponse),
#[prost(message, tag = "3")]
HdfsResponse(super::HdfsResponse),
#[prost(message, tag = "4")]
S3Response(super::S3Response),
#[prost(message, tag = "5")]
OssResponse(super::OssResponse),
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SyncPiecesFailedRequest {
#[prost(string, tag = "1")]
pub parent_id: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub description: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct AnnouncePeerRequest {
#[prost(string, tag = "1")]
pub host_id: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub task_id: ::prost::alloc::string::String,
#[prost(string, tag = "3")]
pub peer_id: ::prost::alloc::string::String,
#[prost(
oneof = "announce_peer_request::Request",
tags = "4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16"
)]
pub request: ::core::option::Option<announce_peer_request::Request>,
}
pub mod announce_peer_request {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Request {
#[prost(message, tag = "4")]
RegisterPeerRequest(super::RegisterPeerRequest),
#[prost(message, tag = "5")]
RegisterSeedPeerRequest(super::RegisterSeedPeerRequest),
#[prost(message, tag = "6")]
DownloadPeerStartedRequest(super::DownloadPeerStartedRequest),
#[prost(message, tag = "7")]
DownloadPeerBackToSourceStartedRequest(
super::DownloadPeerBackToSourceStartedRequest,
),
#[prost(message, tag = "8")]
DownloadPeerFinishedRequest(super::DownloadPeerFinishedRequest),
#[prost(message, tag = "9")]
DownloadPeerBackToSourceFinishedRequest(
super::DownloadPeerBackToSourceFinishedRequest,
),
#[prost(message, tag = "10")]
DownloadPeerFailedRequest(super::DownloadPeerFailedRequest),
#[prost(message, tag = "11")]
DownloadPeerBackToSourceFailedRequest(
super::DownloadPeerBackToSourceFailedRequest,
),
#[prost(message, tag = "12")]
DownloadPieceFinishedRequest(super::DownloadPieceFinishedRequest),
#[prost(message, tag = "13")]
DownloadPieceBackToSourceFinishedRequest(
super::DownloadPieceBackToSourceFinishedRequest,
),
#[prost(message, tag = "14")]
DownloadPieceFailedRequest(super::DownloadPieceFailedRequest),
#[prost(message, tag = "15")]
DownloadPieceBackToSourceFailedRequest(
super::DownloadPieceBackToSourceFailedRequest,
),
#[prost(message, tag = "16")]
SyncPiecesFailedRequest(super::SyncPiecesFailedRequest),
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct EmptyTaskResponse {}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TinyTaskResponse {
#[prost(bytes = "vec", tag = "1")]
pub content: ::prost::alloc::vec::Vec<u8>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SmallTaskResponse {}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct NormalTaskResponse {
#[prost(message, repeated, tag = "1")]
pub candidate_parents: ::prost::alloc::vec::Vec<super::common::Peer>,
#[prost(int32, tag = "2")]
pub concurrent_piece_count: i32,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct NeedBackToSourceResponse {
#[prost(string, tag = "1")]
pub description: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct AnnouncePeerResponse {
#[prost(oneof = "announce_peer_response::Response", tags = "1, 2, 3, 4, 5")]
pub response: ::core::option::Option<announce_peer_response::Response>,
}
pub mod announce_peer_response {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Response {
#[prost(message, tag = "1")]
EmptyTaskResponse(super::EmptyTaskResponse),
#[prost(message, tag = "2")]
TinyTaskResponse(super::TinyTaskResponse),
#[prost(message, tag = "3")]
SmallTaskResponse(super::SmallTaskResponse),
#[prost(message, tag = "4")]
NormalTaskResponse(super::NormalTaskResponse),
#[prost(message, tag = "5")]
NeedBackToSourceResponse(super::NeedBackToSourceResponse),
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct StatPeerRequest {
#[prost(string, tag = "1")]
pub host_id: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub task_id: ::prost::alloc::string::String,
#[prost(string, tag = "3")]
pub peer_id: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ExchangePeerRequest {
#[prost(string, tag = "1")]
pub host_id: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub task_id: ::prost::alloc::string::String,
#[prost(string, tag = "3")]
pub peer_id: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ExchangePeerResponse {}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct LeavePeerRequest {
#[prost(string, tag = "1")]
pub host_id: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub task_id: ::prost::alloc::string::String,
#[prost(string, tag = "3")]
pub peer_id: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct StatTaskRequest {
#[prost(string, tag = "1")]
pub id: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct AnnounceHostRequest {
#[prost(message, optional, tag = "1")]
pub host: ::core::option::Option<super::common::Host>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct LeaveHostRequest {
#[prost(string, tag = "1")]
pub id: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ProbeStartedRequest {}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Probe {
#[prost(message, optional, tag = "1")]
pub host: ::core::option::Option<super::common::Host>,
#[prost(message, optional, tag = "2")]
pub rtt: ::core::option::Option<::prost_types::Duration>,
#[prost(message, optional, tag = "3")]
pub created_at: ::core::option::Option<::prost_types::Timestamp>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ProbeFinishedRequest {
#[prost(message, repeated, tag = "1")]
pub probes: ::prost::alloc::vec::Vec<Probe>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct FailedProbe {
#[prost(message, optional, tag = "1")]
pub host: ::core::option::Option<super::common::Host>,
#[prost(string, tag = "2")]
pub description: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ProbeFailedRequest {
#[prost(message, repeated, tag = "1")]
pub probes: ::prost::alloc::vec::Vec<FailedProbe>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SyncProbesRequest {
#[prost(message, optional, tag = "1")]
pub host: ::core::option::Option<super::common::Host>,
#[prost(oneof = "sync_probes_request::Request", tags = "2, 3, 4")]
pub request: ::core::option::Option<sync_probes_request::Request>,
}
pub mod sync_probes_request {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Request {
#[prost(message, tag = "2")]
ProbeStartedRequest(super::ProbeStartedRequest),
#[prost(message, tag = "3")]
ProbeFinishedRequest(super::ProbeFinishedRequest),
#[prost(message, tag = "4")]
ProbeFailedRequest(super::ProbeFailedRequest),
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SyncProbesResponse {
#[prost(message, repeated, tag = "1")]
pub hosts: ::prost::alloc::vec::Vec<super::common::Host>,
}
pub mod scheduler_client {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
#[derive(Debug, Clone)]
pub struct SchedulerClient<T> {
inner: tonic::client::Grpc<T>,
}
impl SchedulerClient<tonic::transport::Channel> {
pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
where
D: TryInto<tonic::transport::Endpoint>,
D::Error: Into<StdError>,
{
let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
Ok(Self::new(conn))
}
}
impl<T> SchedulerClient<T>
where
T: tonic::client::GrpcService<tonic::body::BoxBody>,
T::Error: Into<StdError>,
T::ResponseBody: Body<Data = Bytes> + Send + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + Send,
{
pub fn new(inner: T) -> Self {
let inner = tonic::client::Grpc::new(inner);
Self { inner }
}
pub fn with_origin(inner: T, origin: Uri) -> Self {
let inner = tonic::client::Grpc::with_origin(inner, origin);
Self { inner }
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> SchedulerClient<InterceptedService<T, F>>
where
F: tonic::service::Interceptor,
T::ResponseBody: Default,
T: tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
Response = http::Response<
<T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
>,
>,
<T as tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
>>::Error: Into<StdError> + Send + Sync,
{
SchedulerClient::new(InterceptedService::new(inner, interceptor))
}
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.send_compressed(encoding);
self
}
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.accept_compressed(encoding);
self
}
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_decoding_message_size(limit);
self
}
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_encoding_message_size(limit);
self
}
pub async fn announce_peer(
&mut self,
request: impl tonic::IntoStreamingRequest<
Message = super::AnnouncePeerRequest,
>,
) -> std::result::Result<
tonic::Response<tonic::codec::Streaming<super::AnnouncePeerResponse>>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/scheduler.Scheduler/AnnouncePeer",
);
let mut req = request.into_streaming_request();
req.extensions_mut()
.insert(GrpcMethod::new("scheduler.Scheduler", "AnnouncePeer"));
self.inner.streaming(req, path, codec).await
}
pub async fn stat_peer(
&mut self,
request: impl tonic::IntoRequest<super::StatPeerRequest>,
) -> std::result::Result<
tonic::Response<super::super::common::Peer>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/scheduler.Scheduler/StatPeer",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("scheduler.Scheduler", "StatPeer"));
self.inner.unary(req, path, codec).await
}
pub async fn leave_peer(
&mut self,
request: impl tonic::IntoRequest<super::LeavePeerRequest>,
) -> std::result::Result<tonic::Response<()>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/scheduler.Scheduler/LeavePeer",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("scheduler.Scheduler", "LeavePeer"));
self.inner.unary(req, path, codec).await
}
pub async fn exchange_peer(
&mut self,
request: impl tonic::IntoRequest<super::ExchangePeerRequest>,
) -> std::result::Result<
tonic::Response<super::ExchangePeerResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/scheduler.Scheduler/ExchangePeer",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("scheduler.Scheduler", "ExchangePeer"));
self.inner.unary(req, path, codec).await
}
pub async fn stat_task(
&mut self,
request: impl tonic::IntoRequest<super::StatTaskRequest>,
) -> std::result::Result<
tonic::Response<super::super::common::Task>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/scheduler.Scheduler/StatTask",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("scheduler.Scheduler", "StatTask"));
self.inner.unary(req, path, codec).await
}
pub async fn announce_host(
&mut self,
request: impl tonic::IntoRequest<super::AnnounceHostRequest>,
) -> std::result::Result<tonic::Response<()>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/scheduler.Scheduler/AnnounceHost",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("scheduler.Scheduler", "AnnounceHost"));
self.inner.unary(req, path, codec).await
}
pub async fn leave_host(
&mut self,
request: impl tonic::IntoRequest<super::LeaveHostRequest>,
) -> std::result::Result<tonic::Response<()>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/scheduler.Scheduler/LeaveHost",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("scheduler.Scheduler", "LeaveHost"));
self.inner.unary(req, path, codec).await
}
pub async fn sync_probes(
&mut self,
request: impl tonic::IntoStreamingRequest<Message = super::SyncProbesRequest>,
) -> std::result::Result<
tonic::Response<tonic::codec::Streaming<super::SyncProbesResponse>>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/scheduler.Scheduler/SyncProbes",
);
let mut req = request.into_streaming_request();
req.extensions_mut()
.insert(GrpcMethod::new("scheduler.Scheduler", "SyncProbes"));
self.inner.streaming(req, path, codec).await
}
}
}
pub mod scheduler_server {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
use tonic::codegen::*;
#[async_trait]
pub trait Scheduler: Send + Sync + 'static {
type AnnouncePeerStream: futures_core::Stream<
Item = std::result::Result<super::AnnouncePeerResponse, tonic::Status>,
>
+ Send
+ 'static;
async fn announce_peer(
&self,
request: tonic::Request<tonic::Streaming<super::AnnouncePeerRequest>>,
) -> std::result::Result<
tonic::Response<Self::AnnouncePeerStream>,
tonic::Status,
>;
async fn stat_peer(
&self,
request: tonic::Request<super::StatPeerRequest>,
) -> std::result::Result<
tonic::Response<super::super::common::Peer>,
tonic::Status,
>;
async fn leave_peer(
&self,
request: tonic::Request<super::LeavePeerRequest>,
) -> std::result::Result<tonic::Response<()>, tonic::Status>;
async fn exchange_peer(
&self,
request: tonic::Request<super::ExchangePeerRequest>,
) -> std::result::Result<
tonic::Response<super::ExchangePeerResponse>,
tonic::Status,
>;
async fn stat_task(
&self,
request: tonic::Request<super::StatTaskRequest>,
) -> std::result::Result<
tonic::Response<super::super::common::Task>,
tonic::Status,
>;
async fn announce_host(
&self,
request: tonic::Request<super::AnnounceHostRequest>,
) -> std::result::Result<tonic::Response<()>, tonic::Status>;
async fn leave_host(
&self,
request: tonic::Request<super::LeaveHostRequest>,
) -> std::result::Result<tonic::Response<()>, tonic::Status>;
type SyncProbesStream: futures_core::Stream<
Item = std::result::Result<super::SyncProbesResponse, tonic::Status>,
>
+ Send
+ 'static;
async fn sync_probes(
&self,
request: tonic::Request<tonic::Streaming<super::SyncProbesRequest>>,
) -> std::result::Result<tonic::Response<Self::SyncProbesStream>, tonic::Status>;
}
#[derive(Debug)]
pub struct SchedulerServer<T: Scheduler> {
inner: _Inner<T>,
accept_compression_encodings: EnabledCompressionEncodings,
send_compression_encodings: EnabledCompressionEncodings,
max_decoding_message_size: Option<usize>,
max_encoding_message_size: Option<usize>,
}
struct _Inner<T>(Arc<T>);
impl<T: Scheduler> SchedulerServer<T> {
pub fn new(inner: T) -> Self {
Self::from_arc(Arc::new(inner))
}
pub fn from_arc(inner: Arc<T>) -> Self {
let inner = _Inner(inner);
Self {
inner,
accept_compression_encodings: Default::default(),
send_compression_encodings: Default::default(),
max_decoding_message_size: None,
max_encoding_message_size: None,
}
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> InterceptedService<Self, F>
where
F: tonic::service::Interceptor,
{
InterceptedService::new(Self::new(inner), interceptor)
}
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.accept_compression_encodings.enable(encoding);
self
}
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.send_compression_encodings.enable(encoding);
self
}
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.max_decoding_message_size = Some(limit);
self
}
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.max_encoding_message_size = Some(limit);
self
}
}
impl<T, B> tonic::codegen::Service<http::Request<B>> for SchedulerServer<T>
where
T: Scheduler,
B: Body + Send + 'static,
B::Error: Into<StdError> + Send + 'static,
{
type Response = http::Response<tonic::body::BoxBody>;
type Error = std::convert::Infallible;
type Future = BoxFuture<Self::Response, Self::Error>;
fn poll_ready(
&mut self,
_cx: &mut Context<'_>,
) -> Poll<std::result::Result<(), Self::Error>> {
Poll::Ready(Ok(()))
}
fn call(&mut self, req: http::Request<B>) -> Self::Future {
let inner = self.inner.clone();
match req.uri().path() {
"/scheduler.Scheduler/AnnouncePeer" => {
#[allow(non_camel_case_types)]
struct AnnouncePeerSvc<T: Scheduler>(pub Arc<T>);
impl<
T: Scheduler,
> tonic::server::StreamingService<super::AnnouncePeerRequest>
for AnnouncePeerSvc<T> {
type Response = super::AnnouncePeerResponse;
type ResponseStream = T::AnnouncePeerStream;
type Future = BoxFuture<
tonic::Response<Self::ResponseStream>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<
tonic::Streaming<super::AnnouncePeerRequest>,
>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
(*inner).announce_peer(request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let inner = inner.0;
let method = AnnouncePeerSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.streaming(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/scheduler.Scheduler/StatPeer" => {
#[allow(non_camel_case_types)]
struct StatPeerSvc<T: Scheduler>(pub Arc<T>);
impl<
T: Scheduler,
> tonic::server::UnaryService<super::StatPeerRequest>
for StatPeerSvc<T> {
type Response = super::super::common::Peer;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::StatPeerRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move { (*inner).stat_peer(request).await };
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let inner = inner.0;
let method = StatPeerSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/scheduler.Scheduler/LeavePeer" => {
#[allow(non_camel_case_types)]
struct LeavePeerSvc<T: Scheduler>(pub Arc<T>);
impl<
T: Scheduler,
> tonic::server::UnaryService<super::LeavePeerRequest>
for LeavePeerSvc<T> {
type Response = ();
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::LeavePeerRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move { (*inner).leave_peer(request).await };
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let inner = inner.0;
let method = LeavePeerSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/scheduler.Scheduler/ExchangePeer" => {
#[allow(non_camel_case_types)]
struct ExchangePeerSvc<T: Scheduler>(pub Arc<T>);
impl<
T: Scheduler,
> tonic::server::UnaryService<super::ExchangePeerRequest>
for ExchangePeerSvc<T> {
type Response = super::ExchangePeerResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::ExchangePeerRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
(*inner).exchange_peer(request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let inner = inner.0;
let method = ExchangePeerSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/scheduler.Scheduler/StatTask" => {
#[allow(non_camel_case_types)]
struct StatTaskSvc<T: Scheduler>(pub Arc<T>);
impl<
T: Scheduler,
> tonic::server::UnaryService<super::StatTaskRequest>
for StatTaskSvc<T> {
type Response = super::super::common::Task;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::StatTaskRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move { (*inner).stat_task(request).await };
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let inner = inner.0;
let method = StatTaskSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/scheduler.Scheduler/AnnounceHost" => {
#[allow(non_camel_case_types)]
struct AnnounceHostSvc<T: Scheduler>(pub Arc<T>);
impl<
T: Scheduler,
> tonic::server::UnaryService<super::AnnounceHostRequest>
for AnnounceHostSvc<T> {
type Response = ();
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::AnnounceHostRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
(*inner).announce_host(request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let inner = inner.0;
let method = AnnounceHostSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/scheduler.Scheduler/LeaveHost" => {
#[allow(non_camel_case_types)]
struct LeaveHostSvc<T: Scheduler>(pub Arc<T>);
impl<
T: Scheduler,
> tonic::server::UnaryService<super::LeaveHostRequest>
for LeaveHostSvc<T> {
type Response = ();
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::LeaveHostRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move { (*inner).leave_host(request).await };
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let inner = inner.0;
let method = LeaveHostSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/scheduler.Scheduler/SyncProbes" => {
#[allow(non_camel_case_types)]
struct SyncProbesSvc<T: Scheduler>(pub Arc<T>);
impl<
T: Scheduler,
> tonic::server::StreamingService<super::SyncProbesRequest>
for SyncProbesSvc<T> {
type Response = super::SyncProbesResponse;
type ResponseStream = T::SyncProbesStream;
type Future = BoxFuture<
tonic::Response<Self::ResponseStream>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<
tonic::Streaming<super::SyncProbesRequest>,
>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move { (*inner).sync_probes(request).await };
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let inner = inner.0;
let method = SyncProbesSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.streaming(method, req).await;
Ok(res)
};
Box::pin(fut)
}
_ => {
Box::pin(async move {
Ok(
http::Response::builder()
.status(200)
.header("grpc-status", "12")
.header("content-type", "application/grpc")
.body(empty_body())
.unwrap(),
)
})
}
}
}
}
impl<T: Scheduler> Clone for SchedulerServer<T> {
fn clone(&self) -> Self {
let inner = self.inner.clone();
Self {
inner,
accept_compression_encodings: self.accept_compression_encodings,
send_compression_encodings: self.send_compression_encodings,
max_decoding_message_size: self.max_decoding_message_size,
max_encoding_message_size: self.max_encoding_message_size,
}
}
}
impl<T: Scheduler> Clone for _Inner<T> {
fn clone(&self) -> Self {
Self(Arc::clone(&self.0))
}
}
impl<T: std::fmt::Debug> std::fmt::Debug for _Inner<T> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{:?}", self.0)
}
}
impl<T: Scheduler> tonic::server::NamedService for SchedulerServer<T> {
const NAME: &'static str = "scheduler.Scheduler";
}
}