Expand description
§folk-api
Plugin contract for Folk: every plugin in Folk depends on this crate
and only on this crate. The server core (folk-core) provides the
concrete implementations of Executor, RpcRegistrar,
HealthRegistry, and MetricsRegistry.
§Writing a plugin
Most plugins should:
- Implement
ServerPlugin(notPlugindirectly) for a long-running background task. - Wrap the implementation in
ServerPluginWrapper. - Implement
PluginFactoryto construct the plugin from config. - Export
pub fn folk_plugin_factory() -> Box<dyn PluginFactory>.
See folk-spec/adr/0006-plugin-api-shape.md for the full design rationale,
and folk-plugin-http for a complete working example (phase 6).
Re-exports§
pub use context::PluginContext;pub use executor::Executor;pub use factory::PluginFactory;pub use health::HealthCheckFn;pub use health::HealthRegistry;pub use health::HealthStatus;pub use metrics::Counter;pub use metrics::CounterVec;pub use metrics::Gauge;pub use metrics::GaugeVec;pub use metrics::Histogram;pub use metrics::HistogramVec;pub use metrics::MetricsRegistry;pub use plugin::Plugin;pub use rpc::BoxFuture;pub use rpc::RpcHandler;pub use rpc::RpcMethodDef;pub use rpc::RpcRegistrar;pub use server_plugin::ServerPlugin;pub use server_plugin::ServerPluginWrapper;
Modules§
- context
- Dependencies handed to a plugin at boot.
- executor
- The
Executortrait — how plugins send work to PHP workers. - factory
- Plugin factory: how
folk-builder’s generatedmain.rsconstructs each plugin. - health
- Health check registration.
- metrics
- Metrics registration. Plugins create metric families and update counters, gauges, and histograms.
- plugin
- The
Plugintrait: every plugin in Folk implements this. - rpc
- RPC method registration: plugins expose methods that callers (PHP workers or external admin tools) can invoke on the master.
- server_
plugin ServerPluginhelper trait for the common case: a plugin that runs one long-lived background task (HTTP server, queue consumer, etc.) and shuts down when the server signals shutdown.
Constants§
- FOLK_
API_ VERSION - The Folk API version. Equals this crate’s
Cargo.tomlversionfield.