pub struct SerialPlugin { /* private fields */ }Expand description
单号生成器插件
遵循 TaskPlugin 模式——插件是薄封装,不持有任何数据库连接或 SQL。
持久化逻辑通过 Arc<dyn SerialGenerator> 委托给业务方。
§自动配置模式
若未通过 new() 传入自定义生成器,插件在 start() 时自动创建 Memory 后端。
对于 Redis/PG 后端,需通过 new(serial_config, arc_generator) 注入。
Implementations§
Source§impl SerialPlugin
impl SerialPlugin
Sourcepub fn new(config: SerialConfig, generator: Arc<dyn SerialGenerator>) -> Self
pub fn new(config: SerialConfig, generator: Arc<dyn SerialGenerator>) -> Self
Sourcepub fn with_memory(config: SerialConfig) -> Self
pub fn with_memory(config: SerialConfig) -> Self
使用默认 memory 后端创建插件(零依赖自动配置)
Sourcepub fn generator(&self) -> Arc<dyn SerialGenerator>
pub fn generator(&self) -> Arc<dyn SerialGenerator>
Trait Implementations§
Source§impl Plugin for SerialPlugin
impl Plugin for SerialPlugin
Source§fn start<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = CoreResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn start<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = CoreResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
启动插件:验证连接、初始化资源 Read more
Source§fn stop<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = CoreResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn stop<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = CoreResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
关闭插件:释放资源 Read more
Source§fn depends_on(&self) -> &[&str]
fn depends_on(&self) -> &[&str]
依赖的其他插件名称(用于拓扑排序,保证启动顺序) Read more
Auto Trait Implementations§
impl !Freeze for SerialPlugin
impl !RefUnwindSafe for SerialPlugin
impl !UnwindSafe for SerialPlugin
impl Send for SerialPlugin
impl Sync for SerialPlugin
impl Unpin for SerialPlugin
impl UnsafeUnpin for SerialPlugin
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