d_engine/generated/
raft.client.rs

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