Skip to main content

Reporter

Struct Reporter 

Source
pub(crate) struct Reporter<'a> {
    observer: &'a dyn ProxyObserver,
    enabled: bool,
    counters: &'a Recorder,
    session_id: SessionId,
    side: ProxySide,
    stream_id: Option<u64>,
}
Expand description

Where this module’s events and counters go.

Holds the session identity so no call site has to restate it, and holds the Recorder so that a counter bump and its event are one function call apart at most. Borrowed rather than owned: it is built per call from session.rs’s ForwardCtx, which this module deliberately does not name.

Fields§

§observer: &'a dyn ProxyObserver§enabled: bool

Cached observer.wants_events(). Gates events only — counters are unconditional.

§counters: &'a Recorder§session_id: SessionId§side: ProxySide§stream_id: Option<u64>

Implementations§

Source§

impl<'a> Reporter<'a>

Source

pub(crate) fn new( observer: &'a dyn ProxyObserver, enabled: bool, counters: &'a Recorder, session_id: SessionId, side: ProxySide, stream_id: Option<u64>, ) -> Self

Build one for a stream direction, or for the datagram path (stream_id: None).

Source

pub(crate) fn applied(&self, site: Site, action: ActionKind, effect: Effect)

One ProxyEvent::ActionApplied, for one phase of one action — and the counter, for the two kinds that have one.

The bumps sit outside the enabled gate, on exactly the terms Self::refused gives for its own: a session with nobody watching still counts what it did, and a counter that moved only when someone was looking would agree with its event by construction rather than by measurement.

Each kind reaches this method once per unit it was applied to, which is what makes a match on the kind a count and not an over-count. check_composition refuses Delay and Hold as an inner action and refuses Truncate and ResetStream as a wrapped one, so a composition can hold neither of these two; and Self::applied_deferred, which reports the inner kind when a deferred unit is released, can therefore never name either of them. A delayed unit is counted at its decision and reported again at its release under whatever it was wrapping, and only the first of those two is a Delay.

Source

pub(crate) fn applied_deferred(&self, site: Site, deferred: Deferred)

The release-phase half of a Action::Delay / Action::Hold.

Always at Site::Object or Site::Control — the two sites with a queue — and always with the inner action’s kind, which is what tells it apart from the Queued event emitted at the decision.

Source

pub(crate) fn refused(&self, site: Site, action: ActionKind, refusal: Refusal)

One ProxyEvent::ActionRefused, and one actions_refused.

The counter is bumped outside the enabled gate on purpose: a session with no observer attached still counts what it refused, and the counter and the event are asserted independently. Bumping it inside would make the two agree only when someone was watching.

Source

pub(crate) fn failed(&self, site: Site, action: ActionKind, error: String)

One ProxyEvent::ActionFailed: the action was admitted and the transport rejected it.

Called by session.rs, not from here — this module produces the bytes and the plan, and the caller hands them to the transport, so only the caller can see the rejection. It follows an ActionApplied for the same attempt rather than replacing one. execute emits the admission before it returns, and the caller cannot un-emit it once the transport declines; the two together say the engine did it, and it did not arrive, which is the whole truth and neither event carries it alone. What this is exclusive of is ActionRefused: a refused unit was never the engine’s to place, so a transport failure on its bytes is ImpairmentKind::DatagramNotSent instead.

Note the event carries no stream_id: it is the datagram path’s, and a datagram has no stream to name.

Source

pub(crate) fn impairment(&self, kind: ImpairmentKind)

One ProxyEvent::Impairment, carrying the connection it is about.

The leg is worked out here, from the kind, rather than being a parameter each call site supplies. A site knows one thing — the direction it reads from — and most of what this enum reports is a failure to write, which belongs to the other connection. Asking twenty sites to make that turn is asking for the one to get it wrong that nothing downstream can catch: the event still arrives, still carries a leg, and names the wrong one.

See crate::event::impairment_leg for the table and for why four kinds answer None.

§Ordering

Every caller of this is past the thing it is reporting: the reset has been handed to the transport, the datagram has come back refused, the queue has been abandoned. That is a rule about the call sites rather than something this function can enforce, and it is stated on ProxyEvent::Impairment because it is what an observer is entitled to rely on.

Source

fn emit(&self, event: ProxyEvent)

Trait Implementations§

Source§

impl<'a> Clone for Reporter<'a>

Source§

fn clone(&self) -> Reporter<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for Reporter<'a>

Source§

impl Debug for Reporter<'_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for Reporter<'a>

§

impl<'a> !UnwindSafe for Reporter<'a>

§

impl<'a> Freeze for Reporter<'a>

§

impl<'a> Send for Reporter<'a>

§

impl<'a> Sync for Reporter<'a>

§

impl<'a> Unpin for Reporter<'a>

§

impl<'a> UnsafeUnpin for Reporter<'a>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more