risingwave_connector/source/cdc/
mysql.rs1use std::collections::BTreeMap;
16
17use rand::Rng;
18use risingwave_pb::secret::PbSecretRef;
19
20use crate::error::ConnectorResult;
21use crate::source::cdc::{
22 CdcSourceDdlValidator, CdcSourceExternalTableIdentifier, CdcSourceRuntimeFlags,
23 CdcSourceTypeTrait, Mysql, check_alter_with_options_inner, check_common_with_options,
24};
25
26impl CdcSourceRuntimeFlags for Mysql {
29 const CAN_AUTO_SCHEMA_CHANGE: bool = true;
30 const CAN_BACKFILL: bool = true;
31 const CAN_USE_TRANSACTION_METADATA: bool = true;
32 const NEEDS_NON_EMPTY_INITIAL_OFFSET: bool = true;
33}
34
35impl CdcSourceDdlValidator for Mysql {
38 fn check_and_fill_create_with_options(
39 props: &mut BTreeMap<String, String>,
40 secret_refs: &BTreeMap<String, PbSecretRef>,
41 ) -> ConnectorResult<()> {
42 check_common_with_options::<Self>(props, secret_refs)?;
43 props
47 .entry("server.id".to_owned())
48 .or_insert(rand::rng().random_range(1..u32::MAX).to_string());
49 Ok(())
50 }
51
52 fn check_alter_with_options(
53 props: &BTreeMap<String, String>,
54 secret_refs: &BTreeMap<String, PbSecretRef>,
55 ) -> ConnectorResult<()> {
56 check_common_with_options::<Self>(props, secret_refs)?;
57 check_alter_with_options_inner(
58 Self::CDC_CONNECTOR_NAME,
59 props,
60 secret_refs,
61 &[
62 "cdc.source.wait.streaming.start.timeout",
63 "debezium.max.queue.size",
64 "debezium.queue.memory.ratio",
65 "hostname",
66 "port",
67 "password",
68 ],
69 )
70 }
71}
72
73impl CdcSourceExternalTableIdentifier for Mysql {}