agent: handle connection failures

This commit is contained in:
Hendrik Hofstadt 2020-08-21 23:48:17 +02:00
parent 30d921ec25
commit 0d5bef7366
1 changed files with 10 additions and 3 deletions

View File

@ -113,7 +113,7 @@ impl Agent for AgentImpl {
let bridge = self.bridge.clone();
let rpc_url = self.rpc_url.clone();
tokio::spawn(async move {
match tokio::spawn(async move {
let rpc = RpcClient::new(rpc_url.to_string());
let sub = PubsubClient::program_subscribe(&url, &bridge).unwrap();
@ -221,8 +221,15 @@ impl Agent for AgentImpl {
};
}
});
});
Ok(Response::new(rx))
})
.await
{
Ok(_) => Ok(Response::new(rx)),
Err(_) => Err(Status::new(
Code::Unavailable,
"failed to connect to solana",
)),
}
}
}