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 = "bytes", tag = "1")]
15        pub key: ::prost::bytes::Bytes,
16        #[prost(bytes = "bytes", tag = "2")]
17        pub value: ::prost::bytes::Bytes,
18    }
19    #[derive(serde::Serialize, serde::Deserialize)]
20    #[derive(Clone, PartialEq, ::prost::Message)]
21    pub struct Delete {
22        #[prost(bytes = "bytes", tag = "1")]
23        pub key: ::prost::bytes::Bytes,
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    /// Key list to be read
48    #[prost(bytes = "bytes", repeated, tag = "2")]
49    pub keys: ::prost::alloc::vec::Vec<::prost::bytes::Bytes>,
50    /// Optional consistency policy for this request
51    ///
52    /// When present: Client explicitly specifies consistency requirements
53    /// When absent: Use cluster's configured default policy
54    #[prost(enumeration = "ReadConsistencyPolicy", optional, tag = "3")]
55    pub consistency_policy: ::core::option::Option<i32>,
56}
57#[derive(serde::Serialize, serde::Deserialize)]
58#[derive(Clone, PartialEq, ::prost::Message)]
59pub struct ClientResponse {
60    #[prost(enumeration = "super::error::ErrorCode", tag = "1")]
61    pub error: i32,
62    #[prost(message, optional, tag = "4")]
63    pub metadata: ::core::option::Option<super::error::ErrorMetadata>,
64    #[prost(oneof = "client_response::SuccessResult", tags = "2, 3")]
65    pub success_result: ::core::option::Option<client_response::SuccessResult>,
66}
67/// Nested message and enum types in `ClientResponse`.
68pub mod client_response {
69    #[derive(serde::Serialize, serde::Deserialize)]
70    #[derive(Clone, PartialEq, ::prost::Oneof)]
71    pub enum SuccessResult {
72        #[prost(bool, tag = "2")]
73        WriteAck(bool),
74        #[prost(message, tag = "3")]
75        ReadData(super::ReadResults),
76    }
77}
78/// Renamed from ClientGetResult
79#[derive(serde::Serialize, serde::Deserialize)]
80#[derive(Clone, PartialEq, ::prost::Message)]
81pub struct ClientResult {
82    #[prost(bytes = "bytes", tag = "1")]
83    pub key: ::prost::bytes::Bytes,
84    #[prost(bytes = "bytes", tag = "2")]
85    pub value: ::prost::bytes::Bytes,
86}
87#[derive(serde::Serialize, serde::Deserialize)]
88#[derive(Clone, PartialEq, ::prost::Message)]
89pub struct ReadResults {
90    #[prost(message, repeated, tag = "1")]
91    pub results: ::prost::alloc::vec::Vec<ClientResult>,
92}
93/// Read consistency policy for controlling read operation guarantees
94///
95/// Allows clients to choose between performance and consistency trade-offs
96/// on a per-request basis when supported by the cluster configuration.
97#[derive(serde::Serialize, serde::Deserialize)]
98#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
99#[repr(i32)]
100pub enum ReadConsistencyPolicy {
101    /// Lease-based reads for better performance with weaker consistency
102    ///
103    /// Leader serves reads locally without contacting followers during lease period.
104    /// Provides lower latency but slightly weaker consistency guarantees.
105    LeaseRead = 0,
106    /// Fully linearizable reads for strongest consistency
107    ///
108    /// Leader verifies its leadership with a quorum before serving the read,
109    /// ensuring strict linearizability. Guarantees that all reads reflect
110    /// the most recent committed value in the cluster.
111    LinearizableRead = 1,
112    /// Eventually consistent reads from any node
113    ///
114    /// Allows reading from any node (leader, follower, or candidate) without
115    /// additional consistency checks. May return stale data but provides
116    /// best read performance and availability. Suitable for scenarios where
117    /// eventual consistency is acceptable.
118    EventualConsistency = 2,
119}
120impl ReadConsistencyPolicy {
121    /// String value of the enum field names used in the ProtoBuf definition.
122    ///
123    /// The values are not transformed in any way and thus are considered stable
124    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
125    pub fn as_str_name(&self) -> &'static str {
126        match self {
127            Self::LeaseRead => "READ_CONSISTENCY_POLICY_LEASE_READ",
128            Self::LinearizableRead => "READ_CONSISTENCY_POLICY_LINEARIZABLE_READ",
129            Self::EventualConsistency => "READ_CONSISTENCY_POLICY_EVENTUAL_CONSISTENCY",
130        }
131    }
132    /// Creates an enum from field names used in the ProtoBuf definition.
133    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
134        match value {
135            "READ_CONSISTENCY_POLICY_LEASE_READ" => Some(Self::LeaseRead),
136            "READ_CONSISTENCY_POLICY_LINEARIZABLE_READ" => Some(Self::LinearizableRead),
137            "READ_CONSISTENCY_POLICY_EVENTUAL_CONSISTENCY" => {
138                Some(Self::EventualConsistency)
139            }
140            _ => None,
141        }
142    }
143}
144/// Generated client implementations.
145pub mod raft_client_service_client {
146    #![allow(
147        unused_variables,
148        dead_code,
149        missing_docs,
150        clippy::wildcard_imports,
151        clippy::let_unit_value,
152    )]
153    use tonic::codegen::*;
154    use tonic::codegen::http::Uri;
155    #[derive(Debug, Clone)]
156    pub struct RaftClientServiceClient<T> {
157        inner: tonic::client::Grpc<T>,
158    }
159    impl RaftClientServiceClient<tonic::transport::Channel> {
160        /// Attempt to create a new client by connecting to a given endpoint.
161        pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
162        where
163            D: TryInto<tonic::transport::Endpoint>,
164            D::Error: Into<StdError>,
165        {
166            let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
167            Ok(Self::new(conn))
168        }
169    }
170    impl<T> RaftClientServiceClient<T>
171    where
172        T: tonic::client::GrpcService<tonic::body::BoxBody>,
173        T::Error: Into<StdError>,
174        T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
175        <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
176    {
177        pub fn new(inner: T) -> Self {
178            let inner = tonic::client::Grpc::new(inner);
179            Self { inner }
180        }
181        pub fn with_origin(inner: T, origin: Uri) -> Self {
182            let inner = tonic::client::Grpc::with_origin(inner, origin);
183            Self { inner }
184        }
185        pub fn with_interceptor<F>(
186            inner: T,
187            interceptor: F,
188        ) -> RaftClientServiceClient<InterceptedService<T, F>>
189        where
190            F: tonic::service::Interceptor,
191            T::ResponseBody: Default,
192            T: tonic::codegen::Service<
193                http::Request<tonic::body::BoxBody>,
194                Response = http::Response<
195                    <T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
196                >,
197            >,
198            <T as tonic::codegen::Service<
199                http::Request<tonic::body::BoxBody>,
200            >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
201        {
202            RaftClientServiceClient::new(InterceptedService::new(inner, interceptor))
203        }
204        /// Compress requests with the given encoding.
205        ///
206        /// This requires the server to support it otherwise it might respond with an
207        /// error.
208        #[must_use]
209        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
210            self.inner = self.inner.send_compressed(encoding);
211            self
212        }
213        /// Enable decompressing responses.
214        #[must_use]
215        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
216            self.inner = self.inner.accept_compressed(encoding);
217            self
218        }
219        /// Limits the maximum size of a decoded message.
220        ///
221        /// Default: `4MB`
222        #[must_use]
223        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
224            self.inner = self.inner.max_decoding_message_size(limit);
225            self
226        }
227        /// Limits the maximum size of an encoded message.
228        ///
229        /// Default: `usize::MAX`
230        #[must_use]
231        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
232            self.inner = self.inner.max_encoding_message_size(limit);
233            self
234        }
235        pub async fn handle_client_write(
236            &mut self,
237            request: impl tonic::IntoRequest<super::ClientWriteRequest>,
238        ) -> std::result::Result<tonic::Response<super::ClientResponse>, tonic::Status> {
239            self.inner
240                .ready()
241                .await
242                .map_err(|e| {
243                    tonic::Status::unknown(
244                        format!("Service was not ready: {}", e.into()),
245                    )
246                })?;
247            let codec = tonic::codec::ProstCodec::default();
248            let path = http::uri::PathAndQuery::from_static(
249                "/raft.client.RaftClientService/HandleClientWrite",
250            );
251            let mut req = request.into_request();
252            req.extensions_mut()
253                .insert(
254                    GrpcMethod::new("raft.client.RaftClientService", "HandleClientWrite"),
255                );
256            self.inner.unary(req, path, codec).await
257        }
258        pub async fn handle_client_read(
259            &mut self,
260            request: impl tonic::IntoRequest<super::ClientReadRequest>,
261        ) -> std::result::Result<tonic::Response<super::ClientResponse>, tonic::Status> {
262            self.inner
263                .ready()
264                .await
265                .map_err(|e| {
266                    tonic::Status::unknown(
267                        format!("Service was not ready: {}", e.into()),
268                    )
269                })?;
270            let codec = tonic::codec::ProstCodec::default();
271            let path = http::uri::PathAndQuery::from_static(
272                "/raft.client.RaftClientService/HandleClientRead",
273            );
274            let mut req = request.into_request();
275            req.extensions_mut()
276                .insert(
277                    GrpcMethod::new("raft.client.RaftClientService", "HandleClientRead"),
278                );
279            self.inner.unary(req, path, codec).await
280        }
281    }
282}
283/// Generated server implementations.
284pub mod raft_client_service_server {
285    #![allow(
286        unused_variables,
287        dead_code,
288        missing_docs,
289        clippy::wildcard_imports,
290        clippy::let_unit_value,
291    )]
292    use tonic::codegen::*;
293    /// Generated trait containing gRPC methods that should be implemented for use with RaftClientServiceServer.
294    #[async_trait]
295    pub trait RaftClientService: std::marker::Send + std::marker::Sync + 'static {
296        async fn handle_client_write(
297            &self,
298            request: tonic::Request<super::ClientWriteRequest>,
299        ) -> std::result::Result<tonic::Response<super::ClientResponse>, tonic::Status>;
300        async fn handle_client_read(
301            &self,
302            request: tonic::Request<super::ClientReadRequest>,
303        ) -> std::result::Result<tonic::Response<super::ClientResponse>, tonic::Status>;
304    }
305    #[derive(Debug)]
306    pub struct RaftClientServiceServer<T> {
307        inner: Arc<T>,
308        accept_compression_encodings: EnabledCompressionEncodings,
309        send_compression_encodings: EnabledCompressionEncodings,
310        max_decoding_message_size: Option<usize>,
311        max_encoding_message_size: Option<usize>,
312    }
313    impl<T> RaftClientServiceServer<T> {
314        pub fn new(inner: T) -> Self {
315            Self::from_arc(Arc::new(inner))
316        }
317        pub fn from_arc(inner: Arc<T>) -> Self {
318            Self {
319                inner,
320                accept_compression_encodings: Default::default(),
321                send_compression_encodings: Default::default(),
322                max_decoding_message_size: None,
323                max_encoding_message_size: None,
324            }
325        }
326        pub fn with_interceptor<F>(
327            inner: T,
328            interceptor: F,
329        ) -> InterceptedService<Self, F>
330        where
331            F: tonic::service::Interceptor,
332        {
333            InterceptedService::new(Self::new(inner), interceptor)
334        }
335        /// Enable decompressing requests with the given encoding.
336        #[must_use]
337        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
338            self.accept_compression_encodings.enable(encoding);
339            self
340        }
341        /// Compress responses with the given encoding, if the client supports it.
342        #[must_use]
343        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
344            self.send_compression_encodings.enable(encoding);
345            self
346        }
347        /// Limits the maximum size of a decoded message.
348        ///
349        /// Default: `4MB`
350        #[must_use]
351        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
352            self.max_decoding_message_size = Some(limit);
353            self
354        }
355        /// Limits the maximum size of an encoded message.
356        ///
357        /// Default: `usize::MAX`
358        #[must_use]
359        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
360            self.max_encoding_message_size = Some(limit);
361            self
362        }
363    }
364    impl<T, B> tonic::codegen::Service<http::Request<B>> for RaftClientServiceServer<T>
365    where
366        T: RaftClientService,
367        B: Body + std::marker::Send + 'static,
368        B::Error: Into<StdError> + std::marker::Send + 'static,
369    {
370        type Response = http::Response<tonic::body::BoxBody>;
371        type Error = std::convert::Infallible;
372        type Future = BoxFuture<Self::Response, Self::Error>;
373        fn poll_ready(
374            &mut self,
375            _cx: &mut Context<'_>,
376        ) -> Poll<std::result::Result<(), Self::Error>> {
377            Poll::Ready(Ok(()))
378        }
379        fn call(&mut self, req: http::Request<B>) -> Self::Future {
380            match req.uri().path() {
381                "/raft.client.RaftClientService/HandleClientWrite" => {
382                    #[allow(non_camel_case_types)]
383                    struct HandleClientWriteSvc<T: RaftClientService>(pub Arc<T>);
384                    impl<
385                        T: RaftClientService,
386                    > tonic::server::UnaryService<super::ClientWriteRequest>
387                    for HandleClientWriteSvc<T> {
388                        type Response = super::ClientResponse;
389                        type Future = BoxFuture<
390                            tonic::Response<Self::Response>,
391                            tonic::Status,
392                        >;
393                        fn call(
394                            &mut self,
395                            request: tonic::Request<super::ClientWriteRequest>,
396                        ) -> Self::Future {
397                            let inner = Arc::clone(&self.0);
398                            let fut = async move {
399                                <T as RaftClientService>::handle_client_write(
400                                        &inner,
401                                        request,
402                                    )
403                                    .await
404                            };
405                            Box::pin(fut)
406                        }
407                    }
408                    let accept_compression_encodings = self.accept_compression_encodings;
409                    let send_compression_encodings = self.send_compression_encodings;
410                    let max_decoding_message_size = self.max_decoding_message_size;
411                    let max_encoding_message_size = self.max_encoding_message_size;
412                    let inner = self.inner.clone();
413                    let fut = async move {
414                        let method = HandleClientWriteSvc(inner);
415                        let codec = tonic::codec::ProstCodec::default();
416                        let mut grpc = tonic::server::Grpc::new(codec)
417                            .apply_compression_config(
418                                accept_compression_encodings,
419                                send_compression_encodings,
420                            )
421                            .apply_max_message_size_config(
422                                max_decoding_message_size,
423                                max_encoding_message_size,
424                            );
425                        let res = grpc.unary(method, req).await;
426                        Ok(res)
427                    };
428                    Box::pin(fut)
429                }
430                "/raft.client.RaftClientService/HandleClientRead" => {
431                    #[allow(non_camel_case_types)]
432                    struct HandleClientReadSvc<T: RaftClientService>(pub Arc<T>);
433                    impl<
434                        T: RaftClientService,
435                    > tonic::server::UnaryService<super::ClientReadRequest>
436                    for HandleClientReadSvc<T> {
437                        type Response = super::ClientResponse;
438                        type Future = BoxFuture<
439                            tonic::Response<Self::Response>,
440                            tonic::Status,
441                        >;
442                        fn call(
443                            &mut self,
444                            request: tonic::Request<super::ClientReadRequest>,
445                        ) -> Self::Future {
446                            let inner = Arc::clone(&self.0);
447                            let fut = async move {
448                                <T as RaftClientService>::handle_client_read(
449                                        &inner,
450                                        request,
451                                    )
452                                    .await
453                            };
454                            Box::pin(fut)
455                        }
456                    }
457                    let accept_compression_encodings = self.accept_compression_encodings;
458                    let send_compression_encodings = self.send_compression_encodings;
459                    let max_decoding_message_size = self.max_decoding_message_size;
460                    let max_encoding_message_size = self.max_encoding_message_size;
461                    let inner = self.inner.clone();
462                    let fut = async move {
463                        let method = HandleClientReadSvc(inner);
464                        let codec = tonic::codec::ProstCodec::default();
465                        let mut grpc = tonic::server::Grpc::new(codec)
466                            .apply_compression_config(
467                                accept_compression_encodings,
468                                send_compression_encodings,
469                            )
470                            .apply_max_message_size_config(
471                                max_decoding_message_size,
472                                max_encoding_message_size,
473                            );
474                        let res = grpc.unary(method, req).await;
475                        Ok(res)
476                    };
477                    Box::pin(fut)
478                }
479                _ => {
480                    Box::pin(async move {
481                        let mut response = http::Response::new(empty_body());
482                        let headers = response.headers_mut();
483                        headers
484                            .insert(
485                                tonic::Status::GRPC_STATUS,
486                                (tonic::Code::Unimplemented as i32).into(),
487                            );
488                        headers
489                            .insert(
490                                http::header::CONTENT_TYPE,
491                                tonic::metadata::GRPC_CONTENT_TYPE,
492                            );
493                        Ok(response)
494                    })
495                }
496            }
497        }
498    }
499    impl<T> Clone for RaftClientServiceServer<T> {
500        fn clone(&self) -> Self {
501            let inner = self.inner.clone();
502            Self {
503                inner,
504                accept_compression_encodings: self.accept_compression_encodings,
505                send_compression_encodings: self.send_compression_encodings,
506                max_decoding_message_size: self.max_decoding_message_size,
507                max_encoding_message_size: self.max_encoding_message_size,
508            }
509        }
510    }
511    /// Generated gRPC service name
512    pub const SERVICE_NAME: &str = "raft.client.RaftClientService";
513    impl<T> tonic::server::NamedService for RaftClientServiceServer<T> {
514        const NAME: &'static str = SERVICE_NAME;
515    }
516}