-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
175 additions
and
83 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
use reqwest; | ||
use crate::akka_cluster::model::ClusterStatus; | ||
|
||
pub fn get_akka_cluster_status(url: &String) -> Result<ClusterStatus, String> { | ||
get_akka_cluster_status_async(url) | ||
} | ||
|
||
#[tokio::main] | ||
async fn get_akka_cluster_status_async(url: &String) -> Result<ClusterStatus, String> { | ||
let response = reqwest::get(url).await.map_err(|e| e.to_string())?; | ||
if response.status().is_success() { | ||
let cluster_status: ClusterStatus = response.json().await.map_err(|e| e.to_string())?; | ||
Ok(cluster_status) | ||
} else { | ||
Err(format!("Request to get cluster status failed with status {}", response.status())) | ||
} | ||
} |
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,2 @@ | ||
pub mod model; | ||
pub mod client; |
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,32 @@ | ||
use std::fmt; | ||
use serde::Deserialize; | ||
|
||
#[derive(Clone)] | ||
pub struct AkkaClusterSettings { | ||
pub cluster_status_address: String, | ||
} | ||
|
||
#[derive(Deserialize, Debug)] | ||
pub struct ClusterStatus { | ||
#[serde(rename(deserialize = "selfNode"))] | ||
pub self_node: String, | ||
pub members: Vec<ClusterMember>, | ||
pub unreachable: Vec<String>, | ||
pub leader: String, | ||
pub oldest: String, | ||
} | ||
|
||
#[derive(Deserialize, Debug)] | ||
pub struct ClusterMember { | ||
pub node: String, | ||
#[serde(rename(deserialize = "nodeUid"))] | ||
pub node_uid: String, | ||
pub status: String, | ||
pub roles: Vec<String>, | ||
} | ||
|
||
impl fmt::Display for ClusterMember { | ||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
write!(f, "==> node: {}\n uid: {}\n status: {}\n roles: {}", self.node, self.node_uid, self.status, self.roles.join(", ")) | ||
} | ||
} |
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
Oops, something went wrong.