pub struct PanicSafeRegistry { /* private fields */ }Expand description
panic 安全的插件注册表
包装插件调用以 std::panic::catch_unwind,panic 后自动将插件置为
PluginState::AutoDisabled 并通过 tracing::warn! 告警,宿主继续运行。
Implementations§
Source§impl PanicSafeRegistry
impl PanicSafeRegistry
Sourcepub fn register_safe(
&self,
plugin: Arc<dyn SzOrmPlugin>,
) -> Result<(), PluginError>
pub fn register_safe( &self, plugin: Arc<dyn SzOrmPlugin>, ) -> Result<(), PluginError>
安全注册插件(验证元数据后置为 Enabled)
Sourcepub fn invoke_safe<F, R>(
&self,
plugin_name: &str,
f: F,
) -> Result<R, PluginError>
pub fn invoke_safe<F, R>( &self, plugin_name: &str, f: F, ) -> Result<R, PluginError>
安全调用插件,panic 时自动禁用
f 接收插件引用并返回结果。若插件 panic,则置为
AutoDisabled 并返回 PluginError::ExecutionFailed。
Sourcepub fn state(&self, name: &str) -> Option<PluginState>
pub fn state(&self, name: &str) -> Option<PluginState>
查询插件状态
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for PanicSafeRegistry
impl !RefUnwindSafe for PanicSafeRegistry
impl !UnwindSafe for PanicSafeRegistry
impl Send for PanicSafeRegistry
impl Sync for PanicSafeRegistry
impl Unpin for PanicSafeRegistry
impl UnsafeUnpin for PanicSafeRegistry
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