pub struct Context {
pub device_id: String,
pub trace_id: String,
/* private fields */
}Expand description
当前请求的追踪上下文,记录设备 ID、Trace ID、起始时间和登录账号。
Fields§
§device_id: String设备 ID
trace_id: String链路追踪 ID
Implementations§
Source§impl Context
impl Context
Sourcepub fn new(device_id: impl Into<String>, trace_id: impl Into<String>) -> Self
pub fn new(device_id: impl Into<String>, trace_id: impl Into<String>) -> Self
创建新的请求上下文,记录设备 ID 和 Trace ID,并以当前时刻为起始时间。
Sourcepub fn elapsed_ms(&self) -> u64
pub fn elapsed_ms(&self) -> u64
返回自请求开始以来经过的毫秒数。
Sourcepub fn get_account(&self) -> Arc<String>
pub fn get_account(&self) -> Arc<String>
返回当前上下文关联的登录账号。
Sourcepub fn set_account(&self, account: impl Into<String>)
pub fn set_account(&self, account: impl Into<String>)
设置当前上下文的登录账号,无锁原子写入。
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Context
impl RefUnwindSafe for Context
impl Send for Context
impl Sync for Context
impl Unpin for Context
impl UnsafeUnpin for Context
impl UnwindSafe for Context
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more