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, CdcSourceRuntimeFlags, CdcSourceTypeTrait, Mysql,
23 check_alter_with_options_inner, check_common_with_options,
24};
25
26impl CdcSourceRuntimeFlags for Mysql {
29 const CAN_BACKFILL: bool = true;
30 const CAN_USE_TRANSACTION_METADATA: bool = true;
31 const NEEDS_NON_EMPTY_INITIAL_OFFSET: bool = true;
32}
33
34impl CdcSourceDdlValidator for Mysql {
37 fn check_and_fill_create_with_options(
38 props: &mut BTreeMap<String, String>,
39 ) -> ConnectorResult<()> {
40 check_common_with_options(props)?;
41 props
45 .entry("server.id".to_owned())
46 .or_insert(rand::rng().random_range(1..u32::MAX).to_string());
47 Ok(())
48 }
49
50 fn check_alter_with_options(
51 props: &BTreeMap<String, String>,
52 secret_refs: &BTreeMap<String, PbSecretRef>,
53 ) -> ConnectorResult<()> {
54 check_common_with_options(props)?;
55 check_alter_with_options_inner(
56 Self::CDC_CONNECTOR_NAME,
57 props,
58 secret_refs,
59 &[
60 "cdc.source.wait.streaming.start.timeout",
61 "debezium.max.queue.size",
62 "debezium.queue.memory.ratio",
63 "hostname",
64 "port",
65 "password",
66 ],
67 )
68 }
69}