Skip to main content

ConnectionInner

Struct ConnectionInner 

Source
pub struct ConnectionInner {
Show 13 fields pub http_client: Client, pub url: String, pub session_id: String, pub headers: IndexMap<String, String>, pub extra_headers: RwLock<IndexMap<String, String>>, pub backoff_current_interval: Duration, pub backoff_initial_interval: Duration, pub backoff_randomization_factor: f64, pub backoff_multiplier: f64, pub backoff_max_interval: Duration, pub backoff_max_elapsed_time: Duration, pub call_timeout: Duration, pub initialize_result: InitializeResult, /* private fields */
}
Expand description

The actual connection state. Behind an Arc inside Connection.

Fields are public for read-only access (callers reach them via Connection’s Deref), but every method on this type is private — the public surface lives on Connection and delegates through.

Fields§

§http_client: Client§url: String§session_id: String§headers: IndexMap<String, String>

All HTTP headers stamped on every POST / GET this connection makes — the same merged map (defaults + caller overrides) the Client built once during connect. Mcp-Session-Id, Content-Type, and Accept are still set by the request builders and override anything in headers.

§extra_headers: RwLock<IndexMap<String, String>>

Mutable per-request override layer stamped AFTER headers on every outbound HTTP request. The request-builder uses reqwest::header::HeaderMap::insert semantics so any key present in extra_headers REPLACES the same key in headers. Used by the proxy to inject session-global headers (X-OBJECTIVEAI-RESPONSE-ID etc.) that override per-URL values without re-dialing. Empty by default; set via Connection::set_extra_headers.

§backoff_current_interval: Duration§backoff_initial_interval: Duration§backoff_randomization_factor: f64§backoff_multiplier: f64§backoff_max_interval: Duration§backoff_max_elapsed_time: Duration§call_timeout: Duration§initialize_result: InitializeResult

The server’s capabilities and info from the initialize response.

Trait Implementations§

Source§

impl Debug for ConnectionInner

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Drop for ConnectionInner

Source§

fn drop(&mut self)

Orphan-DELETE hook: when a freshly-minted connection (not a resume) is dropped without any deliberate use — no call_tool, no read_resource, no explicit Connection::delete — spawn a fire-and-forget HTTP DELETE so the upstream session we just opened doesn’t sit there accruing per-session state for nothing.

Reconnect-resumes are deliberately excluded: a reconnect’s any_calls == false only means this Connection instance never called anything — the underlying upstream session may well have been used by an earlier Connection that opened it, did real work, and let us re-attach. Tearing it down here would kill a still-live session out from under whoever owns it. Reconnects rely on the proxy’s explicit Connection::delete (or Client::delete) for upstream cleanup instead.

Skip conditions (any one triggers a no-op):

  • mock is true — there was never an HTTP session to begin with.
  • is_reconnect is true — see above; the upstream session pre-existed this connection and isn’t ours to tear down on drop.
  • any_calls is true — the connection was deliberately used, or an explicit Connection::delete already ran.
  • No tokio runtime is in scope — tokio::spawn would panic. Silently leak the upstream session in this case (sync teardown paths e.g. cfg(test) blocks not driven by tokio).

The listener-cancel DropGuard inside _listener_cancel_guard fires automatically as part of this same drop call, so by the time the orphan DELETE goes out the listener task has already been told to cancel — no SSE/GET race with the upstream DELETE.

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> Instrument for T

Source§

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

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

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToAst for T

Source§

fn ast(self, begin: usize, end: usize) -> Spanned<Self>

Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

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