Skip to main content

LifecycleContext

Struct LifecycleContext 

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

一次 Tick 的不可变 correlation 上下文。

with_* 方法均返回新值;调用方可以在 T1/T2/T3/T4/T5 间传递上下文, 不需要全局 carrier 或 task-local 状态。current_stage 的父阶段恒为 T1, 使同一 Tick 内的本地子树不会意外嵌套到前一个效果。

Implementations§

Source§

impl LifecycleContext

Source

pub fn new( tick_id: u64, parent_tick_id: Option<u64>, carrier: Option<TraceCarrier>, ) -> LifecycleContext

创建 T1 根上下文;网络能力默认关闭,避免缺能力时伪造 network span。

Source

pub fn root( tick_id: u64, parent_tick_id: Option<u64>, carrier: Option<TraceCarrier>, ) -> LifecycleContext

创建带父 Tick 的 T1 上下文,作为 engine 的语义化构造别名。

Source

pub const fn tick_id(&self) -> u64

返回当前 Tick 的独立 ID。

Source

pub const fn parent_tick_id(&self) -> Option<u64>

返回上游 Tick ID;没有可证明的上游时保持 None。

Source

pub fn carrier(&self) -> Option<&TraceCarrier>

返回显式 carrier 的只读引用。

Source

pub fn span_parent(&self) -> Option<&TraceCarrier>

返回当前 Tick 内部 T1 span 的显式 parent carrier;没有 OTel 时保持 None。

Source

pub fn with_span_parent( &self, span_parent: Option<TraceCarrier>, ) -> LifecycleContext

返回新的上下文并绑定本 Tick 的内部 span parent,不写入全局或 task-local 状态。

Source

pub fn otel_parent(&self) -> Option<&TraceCarrier>

选择异步子节点的显式 parent;内部 T1 优先,外部 W3C carrier 仅作根回退。

Source

pub const fn current_stage(&self) -> LifecycleStage

返回当前生命周期阶段。

Source

pub const fn parent_stage(&self) -> LifecycleStage

返回当前阶段在 T1 根下的挂载点。

Source

pub const fn stage_status(&self, stage: LifecycleStage) -> LifecycleStatus

读取五阶段状态,不会修改上下文。

Source

pub fn with_stage_status( &self, stage: LifecycleStage, status: LifecycleStatus, ) -> LifecycleContext

设置阶段状态并返回新上下文。

Source

pub const fn has_capability(&self, capability: LifecycleCapability) -> bool

读取能力是否存在。

Source

pub const fn capability_status( &self, capability: LifecycleCapability, ) -> LifecycleStatus

读取能力状态;未提供能力时固定返回 NotApplicable。

Source

pub fn with_capability( &self, capability: LifecycleCapability, enabled: bool, ) -> LifecycleContext

设置能力存在性;关闭能力时状态自动收敛到 NotApplicable。

Source

pub fn with_capability_status( &self, capability: LifecycleCapability, status: LifecycleStatus, ) -> LifecycleContext

设置能力状态并返回新上下文;NotApplicable 会同时关闭该能力。

Source

pub fn local_stage(&self, stage: LifecycleStage) -> LifecycleContext

构造同一 Tick 的局部阶段上下文,所有局部节点直接挂到 T1。

Trait Implementations§

Source§

impl Clone for LifecycleContext

Source§

fn clone(&self) -> LifecycleContext

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 Debug for LifecycleContext

Source§

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

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

impl Default for LifecycleContext

Source§

fn default() -> LifecycleContext

创建 synthetic root,供无 Tick 的测试/启动 effect 使用。

Source§

impl Eq for LifecycleContext

Source§

impl PartialEq for LifecycleContext

Source§

fn eq(&self, other: &LifecycleContext) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for LifecycleContext

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self> ⓘ

Attaches the current Context to this type, returning a WithContext wrapper. Read more
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> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> MaybeSend for T
where T: Send,

Source§

impl<T> MaybeSync for T
where T: Sync,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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, <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