risingwave_frontend/catalog/
connection_catalog.rsuse risingwave_pb::catalog::connection::Info;
use risingwave_pb::catalog::{connection, PbConnection};
use crate::catalog::{ConnectionId, OwnedByUserCatalog};
use crate::user::UserId;
#[derive(Clone, Debug, PartialEq)]
pub struct ConnectionCatalog {
pub id: ConnectionId,
pub name: String,
pub info: connection::Info,
pub owner: UserId,
}
impl ConnectionCatalog {
pub fn connection_type(&self) -> &str {
match &self.info {
Info::PrivateLinkService(srv) => srv.get_provider().unwrap().as_str_name(),
Info::ConnectionParams(params) => params.get_connection_type().unwrap().as_str_name(),
}
}
pub fn provider(&self) -> &str {
match &self.info {
Info::PrivateLinkService(_) => "PRIVATELINK",
Info::ConnectionParams(_) => panic!("ConnectionParams is not supported as provider."),
}
}
}
impl From<&PbConnection> for ConnectionCatalog {
fn from(prost: &PbConnection) -> Self {
Self {
id: prost.id,
name: prost.name.clone(),
info: prost.info.clone().unwrap(),
owner: prost.owner,
}
}
}
impl OwnedByUserCatalog for ConnectionCatalog {
fn owner(&self) -> UserId {
self.owner
}
}