Skip to main content

LifecyclePlugin

Trait LifecyclePlugin 

Source
pub trait LifecyclePlugin: Send + Sync {
    // Required method
    fn name(&self) -> &str;

    // Provided methods
    fn priority(&self) -> u32 { ... }
    fn on_server_start(&self, _config_json: &str) -> Result<(), String> { ... }
    fn on_server_stop(&self) -> Result<(), String> { ... }
    fn on_request_complete(&self, _event_json: &str) -> Result<(), String> { ... }
    fn on_cache_write(&self, _key: &str, _tags_json: &str) -> Result<(), String> { ... }
    fn on_cache_invalidate(
        &self,
        _pattern: &str,
        _count: u32,
    ) -> Result<(), String> { ... }
    fn on_reload(&self) -> Result<(), String> { ... }
    fn cleanup(&self) -> Result<(), String> { ... }
}
Expand description

A plugin that receives notifications at key server lifecycle points.

Designed for both compile-time and WASM execution. All methods receive and return JSON strings for ABI compatibility. Lifecycle hooks fire asynchronously after the response is sent — they must not block the request path.

WASM plugins: fuel budgets are enforced per call (see types::fuel).

Required Methods§

Source

fn name(&self) -> &str

Unique identifier.

Provided Methods§

Source

fn priority(&self) -> u32

Execution order among lifecycle plugins. Lower runs first.

Source

fn on_server_start(&self, _config_json: &str) -> Result<(), String>

Called once when the server starts, after all subsystems are initialized.

config_json contains this plugin’s config section from bext.config.toml.

Source

fn on_server_stop(&self) -> Result<(), String>

Called when the server is shutting down gracefully.

Source

fn on_request_complete(&self, _event_json: &str) -> Result<(), String>

Called after a request has been fully processed and the response sent.

event_json contains: path, method, status, cache_status, render_time_us, tenant_id, site_id, encoding, is_bot.

Source

fn on_cache_write(&self, _key: &str, _tags_json: &str) -> Result<(), String>

Called after a new entry is stored in the ISR cache.

Source

fn on_cache_invalidate(&self, _pattern: &str, _count: u32) -> Result<(), String>

Called when ISR cache entries are invalidated.

Source

fn on_reload(&self) -> Result<(), String>

Called after a successful JSC pool reload (bundle updated).

Source

fn cleanup(&self) -> Result<(), String>

Cleanup before plugin unload. Release resources here.

Implementors§