pub struct MiddlewareChain { /* private fields */ }Expand description
有序中间件链
按 order 升序执行前置处理,降序执行后置处理。
链长上限 MAX_CHAIN_LEN,超过返回 PluginError::ChainTooLong。
Implementations§
Source§impl MiddlewareChain
impl MiddlewareChain
Sourcepub fn add(
&mut self,
order: i32,
middleware: Arc<dyn MiddlewareExtension>,
) -> Result<(), PluginError>
pub fn add( &mut self, order: i32, middleware: Arc<dyn MiddlewareExtension>, ) -> Result<(), PluginError>
添加中间件,按 order 排序插入
Sourcepub fn before_query(&self, sql: &str) -> Result<String, PluginError>
pub fn before_query(&self, sql: &str) -> Result<String, PluginError>
前置处理:按 order 升序执行
Sourcepub fn after_query(
&self,
sql: &str,
result: &str,
) -> Result<String, PluginError>
pub fn after_query( &self, sql: &str, result: &str, ) -> Result<String, PluginError>
后置处理:按 order 降序执行
Sourcepub fn last_chain_latency(&self) -> Duration
pub fn last_chain_latency(&self) -> Duration
最近一次链执行开销
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for MiddlewareChain
impl !RefUnwindSafe for MiddlewareChain
impl !UnwindSafe for MiddlewareChain
impl Send for MiddlewareChain
impl Sync for MiddlewareChain
impl Unpin for MiddlewareChain
impl UnsafeUnpin for MiddlewareChain
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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