跳到主要内容
本页尚未翻译

下面显示的是英文原文。

outcomes

outcomes() returns how every handler call settled, in call order.

Each entry is an Outcome: Ack, Nack, Drop, DecodeFailed or Panicked. settled and assert_outcome read the latest call only; outcomes pins a sequence, such as a nack followed by the ack of its redelivery. A batch call has one entry, classified by its first delivery. Outcome is #[non_exhaustive], so a match on it needs a wildcard arm.

Example​

#[tokio::test]
async fn every_order_settled_in_turn() -> Result<(), Box<dyn Error>> {
let tb = TestApp::start(app()).await?;
let broker = tb.broker::<MemoryBroker>();
for id in [1, 0, 2] {
broker.message(&Order { id }).to("orders").publish().await?;
}

assert_eq!(
broker.subscriber("orders").outcomes(),
[Outcome::Ack, Outcome::Drop, Outcome::Ack],
);
Ok(())
}