-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add NodeState to ShotoverNode + some renaming (#1758)
- Loading branch information
1 parent
25827de
commit eb4fb2f
Showing
7 changed files
with
60 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
shotover/src/transforms/kafka/sink_cluster/shotover_node.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
use crate::transforms::kafka::sink_cluster::kafka_node::KafkaAddress; | ||
use atomic_enum::atomic_enum; | ||
use kafka_protocol::messages::BrokerId; | ||
use kafka_protocol::protocol::StrBytes; | ||
use serde::{Deserialize, Serialize}; | ||
use std::sync::Arc; | ||
|
||
#[derive(Serialize, Deserialize, Debug, Clone)] | ||
#[serde(deny_unknown_fields)] | ||
pub struct ShotoverNodeConfig { | ||
pub address: String, | ||
pub rack: String, | ||
pub broker_id: i32, | ||
} | ||
|
||
impl ShotoverNodeConfig { | ||
pub(crate) fn build(self) -> anyhow::Result<ShotoverNode> { | ||
Ok(ShotoverNode { | ||
address: KafkaAddress::from_str(&self.address)?, | ||
rack: StrBytes::from_string(self.rack), | ||
broker_id: BrokerId(self.broker_id), | ||
state: Arc::new(AtomicShotoverNodeState::new(ShotoverNodeState::Up)), | ||
}) | ||
} | ||
} | ||
|
||
#[derive(Clone)] | ||
pub(crate) struct ShotoverNode { | ||
pub address: KafkaAddress, | ||
pub rack: StrBytes, | ||
pub broker_id: BrokerId, | ||
#[allow(unused)] | ||
state: Arc<AtomicShotoverNodeState>, | ||
} | ||
|
||
#[atomic_enum] | ||
#[derive(PartialEq)] | ||
pub(crate) enum ShotoverNodeState { | ||
Up, | ||
Down, | ||
} |