risingwave_meta_service/
lib.rs

1// Copyright 2025 RisingWave Labs
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#![feature(impl_trait_in_assoc_type)]
16#![feature(coverage_attribute)]
17
18use risingwave_meta::*;
19
20pub mod backup_service;
21pub mod cloud_service;
22pub mod cluster_limit_service;
23pub mod cluster_service;
24pub mod ddl_service;
25pub mod event_log_service;
26pub mod health_service;
27pub mod heartbeat_service;
28pub mod hosted_iceberg_catalog_service;
29pub mod hummock_service;
30pub mod meta_member_service;
31pub mod monitor_service;
32pub mod notification_service;
33pub mod scale_service;
34pub mod serving_service;
35pub mod session_config;
36pub mod sink_coordination_service;
37pub mod stream_service;
38pub mod system_params_service;
39pub mod telemetry_service;
40pub mod user_service;
41
42use std::pin::Pin;
43use std::task::{Context, Poll};
44
45use futures::Stream;
46use tokio::sync::mpsc::UnboundedReceiver;
47
48use crate::MetaError;
49
50/// `RwReceiverStream` is a wrapper around `tokio::sync::mpsc::UnboundedReceiver` that implements
51/// Stream. `RwReceiverStream` is similar to `tokio_stream::wrappers::ReceiverStream`, but it
52/// maps Result<S, `MetaError`> to Result<S, `tonic::Status`>.
53pub struct RwReceiverStream<S: Send + Sync + 'static> {
54    inner: UnboundedReceiver<Result<S, MetaError>>,
55}
56
57impl<S: Send + Sync + 'static> RwReceiverStream<S> {
58    pub fn new(inner: UnboundedReceiver<Result<S, MetaError>>) -> Self {
59        Self { inner }
60    }
61}
62
63impl<S: Send + Sync + 'static> Stream for RwReceiverStream<S> {
64    type Item = Result<S, tonic::Status>;
65
66    fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
67        self.inner
68            .poll_recv(cx)
69            .map(|opt| opt.map(|res| res.map_err(Into::into)))
70    }
71}
72
73use std::net::SocketAddr;
74
75#[derive(Clone)]
76pub struct AddressInfo {
77    pub advertise_addr: String,
78    pub listen_addr: SocketAddr,
79    pub prometheus_addr: Option<SocketAddr>,
80    pub dashboard_addr: Option<SocketAddr>,
81}
82impl Default for AddressInfo {
83    fn default() -> Self {
84        Self {
85            advertise_addr: "".to_owned(),
86            listen_addr: SocketAddr::V4("127.0.0.1:0000".parse().unwrap()),
87            prometheus_addr: None,
88            dashboard_addr: None,
89        }
90    }
91}