risingwave_pb/
compactor.rs

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