feat(client): await managed updates from blocking callers

This commit is contained in:
Nils Andreas Svee committed 2026-09-01 01:49:59 +07:00
1 parent 344533f8b6
commit 31fd76f78d
2 files changed
+17 -8

No files matched your search

@@ -250,15 +250,11 @@ fn dynamic_update_reaches_background_worker() {
.unwrap();
let handle = owner.handle();
let acknowledgement = test_runtime().block_on(async {
timeout(
Duration::from_secs(2),
handle.update_targets(vec![target(&server)]).unwrap(),
)
.await
let acknowledgement = handle
.update_targets(vec![target(&server)])
.unwrap()
.unwrap()
});
.blocking_wait()
.unwrap();
assert_eq!(acknowledgement.sequence, 1);
server.wait_probe();
test_runtime().block_on(async {
+13
View File
@@ -301,6 +301,19 @@ pub struct ManagedCommandReceipt {
receiver: oneshot::Receiver<Result<ManagedCommandAcknowledgement, ManagedCommandApplyError>>,
}
impl ManagedCommandReceipt {
/// Block until the target-set transaction is applied or rejected.
///
/// This is for synchronous callers such as [`BlockingManagedClient`]. It
/// must not be called from an asynchronous runtime; use the [`Future`]
/// implementation there instead.
pub fn blocking_wait(self) -> Result<ManagedCommandAcknowledgement, ManagedCommandApplyError> {
self.receiver
.blocking_recv()
.unwrap_or(Err(ManagedCommandApplyError::AcknowledgementDisconnected))
}
}
impl Future for ManagedCommandReceipt {
type Output = Result<ManagedCommandAcknowledgement, ManagedCommandApplyError>;
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {