fix(client): baseline status subscriptions at the current snapshot
This commit is contained in:
2 files changed
+23
-5
No files matched your search
@@ -188,12 +188,15 @@ impl ManagedClientHandle {
|
|||||||
|
|
||||||
/// Subscribe to authoritative durable latest-state observation.
|
/// Subscribe to authoritative durable latest-state observation.
|
||||||
///
|
///
|
||||||
|
/// The current snapshot is marked as seen when subscribing.
|
||||||
/// The current snapshot is immediately available through `borrow()`. Updates
|
/// The current snapshot is immediately available through `borrow()`. Updates
|
||||||
/// may coalesce; this is not a lossless event log. After the task terminates,
|
/// may coalesce; this is not a lossless event log. After the task terminates,
|
||||||
/// the sender closes but the final snapshot remains readable. Use
|
/// the sender closes but the final snapshot remains readable. Use
|
||||||
/// [`Self::subscribe`] for the lossy presentation-event stream.
|
/// [`Self::subscribe`] for the lossy presentation-event stream.
|
||||||
pub fn subscribe_status(&self) -> ManagedStatusSubscription {
|
pub fn subscribe_status(&self) -> ManagedStatusSubscription {
|
||||||
self.status.clone()
|
let mut status = self.status.clone();
|
||||||
|
drop(status.borrow_and_update());
|
||||||
|
status
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Subscribe to future lossy presentation events.
|
/// Subscribe to future lossy presentation events.
|
||||||
|
|||||||
@@ -27,6 +27,25 @@ fn stop_resolves_every_accepted_update_and_closes_admission() {
|
|||||||
);
|
);
|
||||||
assert!(!subscription.borrow().stop_requested);
|
assert!(!subscription.borrow().stop_requested);
|
||||||
assert!(subscription.borrow().final_outcome.is_none());
|
assert!(subscription.borrow().final_outcome.is_none());
|
||||||
|
let runtime = tokio::runtime::Builder::new_current_thread()
|
||||||
|
.enable_all()
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
let mut task = pin!(task);
|
||||||
|
{
|
||||||
|
let _runtime = runtime.enter();
|
||||||
|
assert!(task
|
||||||
|
.as_mut()
|
||||||
|
.poll(&mut Context::from_waker(Waker::noop()))
|
||||||
|
.is_pending());
|
||||||
|
}
|
||||||
|
assert_eq!(handle.status().lifecycle, ManagedLifecycle::Running);
|
||||||
|
subscription = handle.subscribe_status();
|
||||||
|
assert_eq!(subscription.borrow().lifecycle, ManagedLifecycle::Running);
|
||||||
|
assert!(pin!(subscription.changed())
|
||||||
|
.as_mut()
|
||||||
|
.poll(&mut Context::from_waker(Waker::noop()))
|
||||||
|
.is_pending());
|
||||||
let receipts: Vec<_> = (0..3)
|
let receipts: Vec<_> = (0..3)
|
||||||
.map(|index| {
|
.map(|index| {
|
||||||
handle
|
handle
|
||||||
@@ -52,10 +71,6 @@ fn stop_resolves_every_accepted_update_and_closes_admission() {
|
|||||||
handle.update_targets(vec![]),
|
handle.update_targets(vec![]),
|
||||||
Err(ManagedCommandError::Stopping)
|
Err(ManagedCommandError::Stopping)
|
||||||
));
|
));
|
||||||
let runtime = tokio::runtime::Builder::new_current_thread()
|
|
||||||
.enable_all()
|
|
||||||
.build()
|
|
||||||
.unwrap();
|
|
||||||
runtime.block_on(async {
|
runtime.block_on(async {
|
||||||
tokio::time::timeout(Duration::from_secs(2), async {
|
tokio::time::timeout(Duration::from_secs(2), async {
|
||||||
let outcome = task.await;
|
let outcome = task.await;
|
||||||
|
|||||||
Reference in new issue
Block a user