Skip to main content

Crate folk_api

Crate folk_api 

Source
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:

  1. Implement ServerPlugin (not Plugin directly) for a long-running background task.
  2. Wrap the implementation in ServerPluginWrapper.
  3. Implement PluginFactory to construct the plugin from config.
  4. 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 Executor trait — how plugins send work to PHP workers.
factory
Plugin factory: how folk-builder’s generated main.rs constructs each plugin.
health
Health check registration.
metrics
Metrics registration. Plugins create metric families and update counters, gauges, and histograms.
plugin
The Plugin trait: 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
ServerPlugin helper 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.toml version field.