Skip to content

Commit

Permalink
feat: remove AnnouncePeers api in scheduler
Browse files Browse the repository at this point in the history
Signed-off-by: Gaius <[email protected]>
  • Loading branch information
gaius-qi committed Sep 25, 2024
1 parent dbf4bba commit f1676bd
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 110 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "dragonfly-api"
version = "2.0.158"
version = "2.0.159"
authors = ["Gaius <[email protected]>"]
edition = "2021"
license = "Apache-2.0"
Expand Down
9 changes: 0 additions & 9 deletions proto/scheduler.proto
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,6 @@ message DeletePeerRequest {
string peer_id = 3;
}

// AnnouncePeersRequest represents request of AnnouncePeers.
message AnnouncePeersRequest{
// Peers information.
repeated common.v2.Peer peers = 1;
}

// StatTaskRequest represents request of StatTask.
message StatTaskRequest {
// Host id.
Expand Down Expand Up @@ -444,9 +438,6 @@ service Scheduler{
// DeletePeer releases peer in scheduler.
rpc DeletePeer(DeletePeerRequest)returns(google.protobuf.Empty);

// A host announces that it has the announced peers to scheduler at startup.
rpc AnnouncePeers(stream AnnouncePeersRequest) returns(stream google.protobuf.Empty);

// Checks information of task.
rpc StatTask(StatTaskRequest)returns(common.v2.Task);

Expand Down
Binary file modified src/descriptor.bin
Binary file not shown.
99 changes: 0 additions & 99 deletions src/scheduler.v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,15 +273,6 @@ pub struct DeletePeerRequest {
#[prost(string, tag = "3")]
pub peer_id: ::prost::alloc::string::String,
}
/// AnnouncePeersRequest represents request of AnnouncePeers.
#[derive(serde::Serialize, serde::Deserialize)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct AnnouncePeersRequest {
/// Peers information.
#[prost(message, repeated, tag = "1")]
pub peers: ::prost::alloc::vec::Vec<super::super::common::v2::Peer>,
}
/// StatTaskRequest represents request of StatTask.
#[derive(serde::Serialize, serde::Deserialize)]
#[allow(clippy::derive_partial_eq_without_eq)]
Expand Down Expand Up @@ -843,34 +834,6 @@ pub mod scheduler_client {
.insert(GrpcMethod::new("scheduler.v2.Scheduler", "DeletePeer"));
self.inner.unary(req, path, codec).await
}
/// A host announces that it has the announced peers to scheduler at startup.
pub async fn announce_peers(
&mut self,
request: impl tonic::IntoStreamingRequest<
Message = super::AnnouncePeersRequest,
>,
) -> std::result::Result<
tonic::Response<tonic::codec::Streaming<()>>,
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.v2.Scheduler/AnnouncePeers",
);
let mut req = request.into_streaming_request();
req.extensions_mut()
.insert(GrpcMethod::new("scheduler.v2.Scheduler", "AnnouncePeers"));
self.inner.streaming(req, path, codec).await
}
/// Checks information of task.
pub async fn stat_task(
&mut self,
Expand Down Expand Up @@ -1258,20 +1221,6 @@ pub mod scheduler_server {
&self,
request: tonic::Request<super::DeletePeerRequest>,
) -> std::result::Result<tonic::Response<()>, tonic::Status>;
/// Server streaming response type for the AnnouncePeers method.
type AnnouncePeersStream: tonic::codegen::tokio_stream::Stream<
Item = std::result::Result<(), tonic::Status>,
>
+ std::marker::Send
+ 'static;
/// A host announces that it has the announced peers to scheduler at startup.
async fn announce_peers(
&self,
request: tonic::Request<tonic::Streaming<super::AnnouncePeersRequest>>,
) -> std::result::Result<
tonic::Response<Self::AnnouncePeersStream>,
tonic::Status,
>;
/// Checks information of task.
async fn stat_task(
&self,
Expand Down Expand Up @@ -1591,54 +1540,6 @@ pub mod scheduler_server {
};
Box::pin(fut)
}
"/scheduler.v2.Scheduler/AnnouncePeers" => {
#[allow(non_camel_case_types)]
struct AnnouncePeersSvc<T: Scheduler>(pub Arc<T>);
impl<
T: Scheduler,
> tonic::server::StreamingService<super::AnnouncePeersRequest>
for AnnouncePeersSvc<T> {
type Response = ();
type ResponseStream = T::AnnouncePeersStream;
type Future = BoxFuture<
tonic::Response<Self::ResponseStream>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<
tonic::Streaming<super::AnnouncePeersRequest>,
>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as Scheduler>::announce_peers(&inner, 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 method = AnnouncePeersSvc(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.v2.Scheduler/StatTask" => {
#[allow(non_camel_case_types)]
struct StatTaskSvc<T: Scheduler>(pub Arc<T>);
Expand Down

0 comments on commit f1676bd

Please sign in to comment.