risingwave_frontend/catalog/
connection_catalog.rs1use risingwave_pb::catalog::connection::Info;
16use risingwave_pb::catalog::{PbConnection, connection};
17
18use crate::catalog::{ConnectionId, OwnedByUserCatalog};
19use crate::user::UserId;
20
21#[derive(Clone, Debug, PartialEq)]
22pub struct ConnectionCatalog {
23 pub id: ConnectionId,
24 pub name: String,
25 pub info: connection::Info,
26 pub owner: UserId,
27}
28
29impl ConnectionCatalog {
30 pub fn connection_type(&self) -> &str {
31 match &self.info {
32 #[expect(deprecated)]
33 Info::PrivateLinkService(srv) => srv.get_provider().unwrap().as_str_name(),
34 Info::ConnectionParams(params) => params.get_connection_type().unwrap().as_str_name(),
35 }
36 }
37
38 pub fn provider(&self) -> &str {
39 match &self.info {
40 #[expect(deprecated)]
41 Info::PrivateLinkService(_) => "PRIVATELINK",
42 Info::ConnectionParams(_) => panic!("ConnectionParams is not supported as provider."),
43 }
44 }
45}
46
47impl From<&PbConnection> for ConnectionCatalog {
48 fn from(prost: &PbConnection) -> Self {
49 Self {
50 id: prost.id,
51 name: prost.name.clone(),
52 info: prost.info.clone().unwrap(),
53 owner: prost.owner,
54 }
55 }
56}
57
58impl OwnedByUserCatalog for ConnectionCatalog {
59 fn owner(&self) -> UserId {
60 self.owner
61 }
62}