use vil_connector_macros::connector_fault;
#[connector_fault]
pub enum CdcFault {
ConnectionFailed {
conn_hash: u32,
reason_code: u32,
},
ReplicationStartFailed {
slot_hash: u32,
pg_error_code: u32,
},
UnknownMessage {
msg_type: u8,
},
SlotNotFound {
slot_hash: u32,
},
PublicationNotFound {
pub_hash: u32,
},
StreamClosed {
slot_hash: u32,
},
KeepaliveFailed {
os_code: u32,
},
}
impl CdcFault {
pub fn as_error_code(&self) -> u32 {
match self {
CdcFault::ConnectionFailed { .. } => 1,
CdcFault::ReplicationStartFailed { .. } => 2,
CdcFault::UnknownMessage { .. } => 3,
CdcFault::SlotNotFound { .. } => 4,
CdcFault::PublicationNotFound { .. } => 5,
CdcFault::StreamClosed { .. } => 6,
CdcFault::KeepaliveFailed { .. } => 7,
}
}
}