pub trait Plugin: Send + Sync {
// Required methods
fn info(&self) -> &PluginInfo;
fn state(&self) -> PluginState;
fn init(&mut self) -> impl Future<Output = Result<(), IronpostError>> + Send;
fn start(
&mut self,
) -> impl Future<Output = Result<(), IronpostError>> + Send;
fn stop(&mut self) -> impl Future<Output = Result<(), IronpostError>> + Send;
fn health_check(&self) -> impl Future<Output = HealthStatus> + Send;
}Expand description
모든 모듈이 구현하는 플러그인 trait
Pipeline의 상위 추상화로,
메타데이터 조회와 초기화 단계를 추가합니다.
§생명주기
Created → init() → Initialized → start() → Running → stop() → Stopped§구현 예시
ⓘ
struct MyPlugin {
info: PluginInfo,
state: PluginState,
}
impl Plugin for MyPlugin {
fn info(&self) -> &PluginInfo { &self.info }
fn state(&self) -> PluginState { self.state }
async fn init(&mut self) -> Result<(), IronpostError> {
self.state = PluginState::Initialized;
Ok(())
}
async fn start(&mut self) -> Result<(), IronpostError> {
self.state = PluginState::Running;
Ok(())
}
async fn stop(&mut self) -> Result<(), IronpostError> {
self.state = PluginState::Stopped;
Ok(())
}
async fn health_check(&self) -> HealthStatus {
HealthStatus::Healthy
}
}Required Methods§
Sourcefn info(&self) -> &PluginInfo
fn info(&self) -> &PluginInfo
플러그인 메타데이터를 반환합니다.
Sourcefn state(&self) -> PluginState
fn state(&self) -> PluginState
현재 플러그인 상태를 반환합니다.
Sourcefn init(&mut self) -> impl Future<Output = Result<(), IronpostError>> + Send
fn init(&mut self) -> impl Future<Output = Result<(), IronpostError>> + Send
플러그인을 초기화합니다.
리소스 할당, 설정 검증 등을 수행합니다.
Created 상태에서만 호출 가능합니다.
Sourcefn start(&mut self) -> impl Future<Output = Result<(), IronpostError>> + Send
fn start(&mut self) -> impl Future<Output = Result<(), IronpostError>> + Send
플러그인을 시작합니다.
Initialized 또는 Stopped 상태에서만 호출 가능합니다.
Sourcefn stop(&mut self) -> impl Future<Output = Result<(), IronpostError>> + Send
fn stop(&mut self) -> impl Future<Output = Result<(), IronpostError>> + Send
플러그인을 정지합니다.
Running 상태에서만 호출 가능합니다.
Graceful shutdown을 수행합니다.
Sourcefn health_check(&self) -> impl Future<Output = HealthStatus> + Send
fn health_check(&self) -> impl Future<Output = HealthStatus> + Send
플러그인의 건강 상태를 확인합니다.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.