-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(broker): local worker peer lifecycle
- Loading branch information
krhougs
committed
Oct 19, 2022
1 parent
8fcce80
commit 6c558ec
Showing
15 changed files
with
256 additions
and
113 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,15 @@ | ||
use crate::mgmt::{BrokerMgmtShared, MyIdentity}; | ||
use crate::mgmt::BrokerMgmtShared; | ||
use crate::LocalWorkerManagerChannelMessage::ReceivedKeepAlive; | ||
use axum::http::StatusCode; | ||
use axum::response::IntoResponse; | ||
use axum::{extract::Extension, Json}; | ||
use serde::{Deserialize, Serialize}; | ||
use service_network::mgmt_types::LocalWorkerIdentity; | ||
use std::sync::Arc; | ||
|
||
#[derive(Clone, Serialize, Deserialize)] | ||
pub struct LocalWorkerIdentity { | ||
pub instance_name: String, | ||
pub instance_id: String, | ||
pub address_string: String, | ||
pub public_port: u16, | ||
pub public_key: String, | ||
} | ||
|
||
pub async fn handle_keepalive( | ||
Extension(shared): Extension<Arc<BrokerMgmtShared>>, | ||
Json(lwi): Json<LocalWorkerIdentity>, | ||
) -> impl IntoResponse { | ||
let config = &shared.config; | ||
let _ = shared.tx.clone().send(ReceivedKeepAlive(lwi.clone())).await; | ||
( | ||
StatusCode::IM_A_TEAPOT, | ||
Json(MyIdentity { | ||
instance_name: config.common.instance_name.to_string(), | ||
instance_id: config.instance_id.to_string(), | ||
}), | ||
) | ||
let _ = shared.tx.clone().send(ReceivedKeepAlive(lwi)).await; | ||
(StatusCode::IM_A_TEAPOT, shared.my_id.clone()) | ||
} |
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.