agents wake on send: broker.recv_blocking + 30s long-poll on Recv
This commit is contained in:
parent
f1fd787f17
commit
dfbcf2b9d1
3 changed files with 50 additions and 4 deletions
|
|
@ -69,6 +69,8 @@ async fn serve(stream: UnixStream, coord: Arc<Coordinator>) -> Result<()> {
|
|||
}
|
||||
}
|
||||
|
||||
const MANAGER_RECV_LONG_POLL: std::time::Duration = std::time::Duration::from_secs(30);
|
||||
|
||||
async fn dispatch(req: &ManagerRequest, coord: &Coordinator) -> ManagerResponse {
|
||||
match req {
|
||||
ManagerRequest::Send { to, body } => match coord.broker.send(&Message {
|
||||
|
|
@ -97,7 +99,11 @@ async fn dispatch(req: &ManagerRequest, coord: &Coordinator) -> ManagerResponse
|
|||
message: format!("{e:#}"),
|
||||
},
|
||||
},
|
||||
ManagerRequest::Recv => match coord.broker.recv(MANAGER_AGENT) {
|
||||
ManagerRequest::Recv => match coord
|
||||
.broker
|
||||
.recv_blocking(MANAGER_AGENT, MANAGER_RECV_LONG_POLL)
|
||||
.await
|
||||
{
|
||||
Ok(Some(msg)) => ManagerResponse::Message {
|
||||
from: msg.from,
|
||||
body: msg.body,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue