Skip to main content

d_engine_proto/generated/
d_engine.server.replication.rs

1// This file is @generated by prost-build.
2#[derive(serde::Serialize, serde::Deserialize)]
3#[derive(Clone, PartialEq, ::prost::Message)]
4pub struct AppendEntriesRequest {
5    #[prost(uint64, tag = "1")]
6    pub term: u64,
7    #[prost(uint32, tag = "2")]
8    pub leader_id: u32,
9    #[prost(uint64, tag = "3")]
10    pub prev_log_index: u64,
11    #[prost(uint64, tag = "4")]
12    pub prev_log_term: u64,
13    #[prost(message, repeated, tag = "5")]
14    pub entries: ::prost::alloc::vec::Vec<super::super::common::Entry>,
15    #[prost(uint64, tag = "6")]
16    pub leader_commit_index: u64,
17}
18#[derive(serde::Serialize, serde::Deserialize)]
19#[derive(Clone, Copy, PartialEq, ::prost::Message)]
20pub struct AppendEntriesResponse {
21    #[prost(uint32, tag = "1")]
22    pub node_id: u32,
23    #[prost(uint64, tag = "2")]
24    pub term: u64,
25    #[prost(oneof = "append_entries_response::Result", tags = "3, 4, 5")]
26    pub result: ::core::option::Option<append_entries_response::Result>,
27}
28/// Nested message and enum types in `AppendEntriesResponse`.
29pub mod append_entries_response {
30    #[derive(serde::Serialize, serde::Deserialize)]
31    #[derive(Clone, Copy, PartialEq, ::prost::Oneof)]
32    pub enum Result {
33        #[prost(message, tag = "3")]
34        Success(super::SuccessResult),
35        #[prost(message, tag = "4")]
36        Conflict(super::ConflictResult),
37        #[prost(uint64, tag = "5")]
38        HigherTerm(u64),
39    }
40}
41#[derive(serde::Serialize, serde::Deserialize)]
42#[derive(Clone, Copy, PartialEq, ::prost::Message)]
43pub struct SuccessResult {
44    #[prost(message, optional, tag = "1")]
45    pub last_match: ::core::option::Option<super::super::common::LogId>,
46}
47#[derive(serde::Serialize, serde::Deserialize)]
48#[derive(Clone, Copy, PartialEq, ::prost::Message)]
49pub struct ConflictResult {
50    #[prost(uint64, optional, tag = "1")]
51    pub conflict_term: ::core::option::Option<u64>,
52    #[prost(uint64, optional, tag = "2")]
53    pub conflict_index: ::core::option::Option<u64>,
54}
55/// Generated client implementations.
56pub mod raft_replication_service_client {
57    #![allow(
58        unused_variables,
59        dead_code,
60        missing_docs,
61        clippy::wildcard_imports,
62        clippy::let_unit_value,
63    )]
64    use tonic::codegen::*;
65    use tonic::codegen::http::Uri;
66    #[derive(Debug, Clone)]
67    pub struct RaftReplicationServiceClient<T> {
68        inner: tonic::client::Grpc<T>,
69    }
70    impl RaftReplicationServiceClient<tonic::transport::Channel> {
71        /// Attempt to create a new client by connecting to a given endpoint.
72        pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
73        where
74            D: TryInto<tonic::transport::Endpoint>,
75            D::Error: Into<StdError>,
76        {
77            let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
78            Ok(Self::new(conn))
79        }
80    }
81    impl<T> RaftReplicationServiceClient<T>
82    where
83        T: tonic::client::GrpcService<tonic::body::Body>,
84        T::Error: Into<StdError>,
85        T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
86        <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
87    {
88        pub fn new(inner: T) -> Self {
89            let inner = tonic::client::Grpc::new(inner);
90            Self { inner }
91        }
92        pub fn with_origin(inner: T, origin: Uri) -> Self {
93            let inner = tonic::client::Grpc::with_origin(inner, origin);
94            Self { inner }
95        }
96        pub fn with_interceptor<F>(
97            inner: T,
98            interceptor: F,
99        ) -> RaftReplicationServiceClient<InterceptedService<T, F>>
100        where
101            F: tonic::service::Interceptor,
102            T::ResponseBody: Default,
103            T: tonic::codegen::Service<
104                http::Request<tonic::body::Body>,
105                Response = http::Response<
106                    <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
107                >,
108            >,
109            <T as tonic::codegen::Service<
110                http::Request<tonic::body::Body>,
111            >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
112        {
113            RaftReplicationServiceClient::new(
114                InterceptedService::new(inner, interceptor),
115            )
116        }
117        /// Compress requests with the given encoding.
118        ///
119        /// This requires the server to support it otherwise it might respond with an
120        /// error.
121        #[must_use]
122        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
123            self.inner = self.inner.send_compressed(encoding);
124            self
125        }
126        /// Enable decompressing responses.
127        #[must_use]
128        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
129            self.inner = self.inner.accept_compressed(encoding);
130            self
131        }
132        /// Limits the maximum size of a decoded message.
133        ///
134        /// Default: `4MB`
135        #[must_use]
136        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
137            self.inner = self.inner.max_decoding_message_size(limit);
138            self
139        }
140        /// Limits the maximum size of an encoded message.
141        ///
142        /// Default: `usize::MAX`
143        #[must_use]
144        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
145            self.inner = self.inner.max_encoding_message_size(limit);
146            self
147        }
148        pub async fn append_entries(
149            &mut self,
150            request: impl tonic::IntoRequest<super::AppendEntriesRequest>,
151        ) -> std::result::Result<
152            tonic::Response<super::AppendEntriesResponse>,
153            tonic::Status,
154        > {
155            self.inner
156                .ready()
157                .await
158                .map_err(|e| {
159                    tonic::Status::unknown(
160                        format!("Service was not ready: {}", e.into()),
161                    )
162                })?;
163            let codec = tonic::codec::ProstCodec::default();
164            let path = http::uri::PathAndQuery::from_static(
165                "/d_engine.server.replication.RaftReplicationService/AppendEntries",
166            );
167            let mut req = request.into_request();
168            req.extensions_mut()
169                .insert(
170                    GrpcMethod::new(
171                        "d_engine.server.replication.RaftReplicationService",
172                        "AppendEntries",
173                    ),
174                );
175            self.inner.unary(req, path, codec).await
176        }
177        /// Persistent bidirectional stream per peer; eliminates per-batch h2 stream open/close overhead.
178        pub async fn stream_append_entries(
179            &mut self,
180            request: impl tonic::IntoStreamingRequest<
181                Message = super::AppendEntriesRequest,
182            >,
183        ) -> std::result::Result<
184            tonic::Response<tonic::codec::Streaming<super::AppendEntriesResponse>>,
185            tonic::Status,
186        > {
187            self.inner
188                .ready()
189                .await
190                .map_err(|e| {
191                    tonic::Status::unknown(
192                        format!("Service was not ready: {}", e.into()),
193                    )
194                })?;
195            let codec = tonic::codec::ProstCodec::default();
196            let path = http::uri::PathAndQuery::from_static(
197                "/d_engine.server.replication.RaftReplicationService/StreamAppendEntries",
198            );
199            let mut req = request.into_streaming_request();
200            req.extensions_mut()
201                .insert(
202                    GrpcMethod::new(
203                        "d_engine.server.replication.RaftReplicationService",
204                        "StreamAppendEntries",
205                    ),
206                );
207            self.inner.streaming(req, path, codec).await
208        }
209    }
210}
211/// Generated server implementations.
212pub mod raft_replication_service_server {
213    #![allow(
214        unused_variables,
215        dead_code,
216        missing_docs,
217        clippy::wildcard_imports,
218        clippy::let_unit_value,
219    )]
220    use tonic::codegen::*;
221    /// Generated trait containing gRPC methods that should be implemented for use with RaftReplicationServiceServer.
222    #[async_trait]
223    pub trait RaftReplicationService: std::marker::Send + std::marker::Sync + 'static {
224        async fn append_entries(
225            &self,
226            request: tonic::Request<super::AppendEntriesRequest>,
227        ) -> std::result::Result<
228            tonic::Response<super::AppendEntriesResponse>,
229            tonic::Status,
230        >;
231        /// Server streaming response type for the StreamAppendEntries method.
232        type StreamAppendEntriesStream: tonic::codegen::tokio_stream::Stream<
233                Item = std::result::Result<super::AppendEntriesResponse, tonic::Status>,
234            >
235            + std::marker::Send
236            + 'static;
237        /// Persistent bidirectional stream per peer; eliminates per-batch h2 stream open/close overhead.
238        async fn stream_append_entries(
239            &self,
240            request: tonic::Request<tonic::Streaming<super::AppendEntriesRequest>>,
241        ) -> std::result::Result<
242            tonic::Response<Self::StreamAppendEntriesStream>,
243            tonic::Status,
244        >;
245    }
246    #[derive(Debug)]
247    pub struct RaftReplicationServiceServer<T> {
248        inner: Arc<T>,
249        accept_compression_encodings: EnabledCompressionEncodings,
250        send_compression_encodings: EnabledCompressionEncodings,
251        max_decoding_message_size: Option<usize>,
252        max_encoding_message_size: Option<usize>,
253    }
254    impl<T> RaftReplicationServiceServer<T> {
255        pub fn new(inner: T) -> Self {
256            Self::from_arc(Arc::new(inner))
257        }
258        pub fn from_arc(inner: Arc<T>) -> Self {
259            Self {
260                inner,
261                accept_compression_encodings: Default::default(),
262                send_compression_encodings: Default::default(),
263                max_decoding_message_size: None,
264                max_encoding_message_size: None,
265            }
266        }
267        pub fn with_interceptor<F>(
268            inner: T,
269            interceptor: F,
270        ) -> InterceptedService<Self, F>
271        where
272            F: tonic::service::Interceptor,
273        {
274            InterceptedService::new(Self::new(inner), interceptor)
275        }
276        /// Enable decompressing requests with the given encoding.
277        #[must_use]
278        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
279            self.accept_compression_encodings.enable(encoding);
280            self
281        }
282        /// Compress responses with the given encoding, if the client supports it.
283        #[must_use]
284        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
285            self.send_compression_encodings.enable(encoding);
286            self
287        }
288        /// Limits the maximum size of a decoded message.
289        ///
290        /// Default: `4MB`
291        #[must_use]
292        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
293            self.max_decoding_message_size = Some(limit);
294            self
295        }
296        /// Limits the maximum size of an encoded message.
297        ///
298        /// Default: `usize::MAX`
299        #[must_use]
300        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
301            self.max_encoding_message_size = Some(limit);
302            self
303        }
304    }
305    impl<T, B> tonic::codegen::Service<http::Request<B>>
306    for RaftReplicationServiceServer<T>
307    where
308        T: RaftReplicationService,
309        B: Body + std::marker::Send + 'static,
310        B::Error: Into<StdError> + std::marker::Send + 'static,
311    {
312        type Response = http::Response<tonic::body::Body>;
313        type Error = std::convert::Infallible;
314        type Future = BoxFuture<Self::Response, Self::Error>;
315        fn poll_ready(
316            &mut self,
317            _cx: &mut Context<'_>,
318        ) -> Poll<std::result::Result<(), Self::Error>> {
319            Poll::Ready(Ok(()))
320        }
321        fn call(&mut self, req: http::Request<B>) -> Self::Future {
322            match req.uri().path() {
323                "/d_engine.server.replication.RaftReplicationService/AppendEntries" => {
324                    #[allow(non_camel_case_types)]
325                    struct AppendEntriesSvc<T: RaftReplicationService>(pub Arc<T>);
326                    impl<
327                        T: RaftReplicationService,
328                    > tonic::server::UnaryService<super::AppendEntriesRequest>
329                    for AppendEntriesSvc<T> {
330                        type Response = super::AppendEntriesResponse;
331                        type Future = BoxFuture<
332                            tonic::Response<Self::Response>,
333                            tonic::Status,
334                        >;
335                        fn call(
336                            &mut self,
337                            request: tonic::Request<super::AppendEntriesRequest>,
338                        ) -> Self::Future {
339                            let inner = Arc::clone(&self.0);
340                            let fut = async move {
341                                <T as RaftReplicationService>::append_entries(
342                                        &inner,
343                                        request,
344                                    )
345                                    .await
346                            };
347                            Box::pin(fut)
348                        }
349                    }
350                    let accept_compression_encodings = self.accept_compression_encodings;
351                    let send_compression_encodings = self.send_compression_encodings;
352                    let max_decoding_message_size = self.max_decoding_message_size;
353                    let max_encoding_message_size = self.max_encoding_message_size;
354                    let inner = self.inner.clone();
355                    let fut = async move {
356                        let method = AppendEntriesSvc(inner);
357                        let codec = tonic::codec::ProstCodec::default();
358                        let mut grpc = tonic::server::Grpc::new(codec)
359                            .apply_compression_config(
360                                accept_compression_encodings,
361                                send_compression_encodings,
362                            )
363                            .apply_max_message_size_config(
364                                max_decoding_message_size,
365                                max_encoding_message_size,
366                            );
367                        let res = grpc.unary(method, req).await;
368                        Ok(res)
369                    };
370                    Box::pin(fut)
371                }
372                "/d_engine.server.replication.RaftReplicationService/StreamAppendEntries" => {
373                    #[allow(non_camel_case_types)]
374                    struct StreamAppendEntriesSvc<T: RaftReplicationService>(pub Arc<T>);
375                    impl<
376                        T: RaftReplicationService,
377                    > tonic::server::StreamingService<super::AppendEntriesRequest>
378                    for StreamAppendEntriesSvc<T> {
379                        type Response = super::AppendEntriesResponse;
380                        type ResponseStream = T::StreamAppendEntriesStream;
381                        type Future = BoxFuture<
382                            tonic::Response<Self::ResponseStream>,
383                            tonic::Status,
384                        >;
385                        fn call(
386                            &mut self,
387                            request: tonic::Request<
388                                tonic::Streaming<super::AppendEntriesRequest>,
389                            >,
390                        ) -> Self::Future {
391                            let inner = Arc::clone(&self.0);
392                            let fut = async move {
393                                <T as RaftReplicationService>::stream_append_entries(
394                                        &inner,
395                                        request,
396                                    )
397                                    .await
398                            };
399                            Box::pin(fut)
400                        }
401                    }
402                    let accept_compression_encodings = self.accept_compression_encodings;
403                    let send_compression_encodings = self.send_compression_encodings;
404                    let max_decoding_message_size = self.max_decoding_message_size;
405                    let max_encoding_message_size = self.max_encoding_message_size;
406                    let inner = self.inner.clone();
407                    let fut = async move {
408                        let method = StreamAppendEntriesSvc(inner);
409                        let codec = tonic::codec::ProstCodec::default();
410                        let mut grpc = tonic::server::Grpc::new(codec)
411                            .apply_compression_config(
412                                accept_compression_encodings,
413                                send_compression_encodings,
414                            )
415                            .apply_max_message_size_config(
416                                max_decoding_message_size,
417                                max_encoding_message_size,
418                            );
419                        let res = grpc.streaming(method, req).await;
420                        Ok(res)
421                    };
422                    Box::pin(fut)
423                }
424                _ => {
425                    Box::pin(async move {
426                        let mut response = http::Response::new(
427                            tonic::body::Body::default(),
428                        );
429                        let headers = response.headers_mut();
430                        headers
431                            .insert(
432                                tonic::Status::GRPC_STATUS,
433                                (tonic::Code::Unimplemented as i32).into(),
434                            );
435                        headers
436                            .insert(
437                                http::header::CONTENT_TYPE,
438                                tonic::metadata::GRPC_CONTENT_TYPE,
439                            );
440                        Ok(response)
441                    })
442                }
443            }
444        }
445    }
446    impl<T> Clone for RaftReplicationServiceServer<T> {
447        fn clone(&self) -> Self {
448            let inner = self.inner.clone();
449            Self {
450                inner,
451                accept_compression_encodings: self.accept_compression_encodings,
452                send_compression_encodings: self.send_compression_encodings,
453                max_decoding_message_size: self.max_decoding_message_size,
454                max_encoding_message_size: self.max_encoding_message_size,
455            }
456        }
457    }
458    /// Generated gRPC service name
459    pub const SERVICE_NAME: &str = "d_engine.server.replication.RaftReplicationService";
460    impl<T> tonic::server::NamedService for RaftReplicationServiceServer<T> {
461        const NAME: &'static str = SERVICE_NAME;
462    }
463}