Skip to main content

ActiveCall

Struct ActiveCall 

Source
pub struct ActiveCall { /* private fields */ }
Expand description

An in-flight framework boundary.

Dropping it without calling ActiveCall::succeed or ActiveCall::fail emits an abandoned finish record, which preserves a balanced trace when a future is cancelled or unwinds.

Implementations§

Source§

impl ActiveCall

Source

pub fn context(&self) -> &CallContext

Examples found in repository?
examples/outbound_child_diagnostic.rs (line 30)
12fn main() {
13    let observer = Observer::with_writer(ObserverConfig::default(), std::io::sink()).unwrap();
14    let (incoming, _) = observer
15        .start_external_call_with_rpc(
16            "shop",
17            "ingress",
18            "orders",
19            "query",
20            Some("gateway-opaque"),
21            RpcCorrelationId::new("0.3").unwrap(),
22        )
23        .unwrap();
24    let ingress_event = EventContext::new(
25        RequestIdentity::new("request-7").unwrap(),
26        RouteIdentity::new("/incoming").unwrap(),
27        1,
28    )
29    .unwrap();
30    let parent = RequestDiagnosticScope::output_unavailable(incoming.context(), &ingress_event)
31        .with_task(DiagnosticTaskId::from_runtime_id("42").unwrap())
32        .unwrap_or_else(|_| panic!("task"))
33        .with_zone(DiagnosticZone::from_validated_ingress("zone-a").unwrap());
34
35    // programming.rs generates the wire child; Boundary uses its trace/rpc plus
36    // request_id/function. The adapter below does NOT generate these identities.
37    let wire_trace = "gateway-opaque";
38    let wire_rpc = "0.3.1";
39    let request_id = "request-7";
40    let function = "remote.query";
41    let (root, _) = observer
42        .start_external_call_with_rpc(
43            "saddle",
44            "zone-a",
45            "profusecontract",
46            "invoke",
47            Some(wire_trace),
48            RpcCorrelationId::new(wire_rpc).unwrap(),
49        )
50        .unwrap();
51    let event = EventContext::new(
52        RequestIdentity::new(request_id).unwrap(),
53        RouteIdentity::new(function).unwrap(),
54        1,
55    )
56    .unwrap();
57    let child = parent
58        .derive_outbound_child(root.context(), &event)
59        .unwrap();
60    let failure = child.fail(
61        std::io::ErrorKind::ConnectionRefused,
62        DiagnosticCategory::UnexpectedError,
63        BoundedDiagnosticCause::new(
64            DiagnosticStage::RequestDecode,
65            DiagnosticCode::new("outbound.connect_failed").unwrap(),
66        ),
67    );
68    let id = failure.source_diagnostic().id();
69    let (retained, delivery) =
70        failure.finish_boundary_retained(None, &DiagnosticOutcomeAxes::default());
71    assert_eq!(retained.source_diagnostic().id(), id);
72    assert_eq!(*retained.error(), std::io::ErrorKind::ConnectionRefused);
73    assert_eq!(
74        delivery.source_submission(),
75        DiagnosticSubmission::OutputUnavailable
76    );
77    assert_eq!(
78        delivery.boundary_submission(),
79        DiagnosticSubmission::OutputUnavailable
80    );
81    println!("GO: Boundary-shaped child Call/Event consumed; absent output retains same failure");
82}
Source

pub fn succeed(self)

Source

pub fn fail(self, error: &SaddleError)

Trait Implementations§

Source§

impl Drop for ActiveCall

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.