Skip to main content

folk_api/
lib.rs

1//! # `folk-api`
2//!
3//! Plugin contract for Folk: every plugin in Folk depends on this crate
4//! and **only** on this crate. The server core (`folk-core`) provides the
5//! concrete implementations of [`Executor`], [`RpcRegistrar`],
6//! [`HealthRegistry`], and [`MetricsRegistry`].
7//!
8//! ## Writing a plugin
9//!
10//! Most plugins should:
11//!
12//! 1. Implement [`ServerPlugin`] (not [`Plugin`] directly) for a long-running
13//!    background task.
14//! 2. Wrap the implementation in [`ServerPluginWrapper`].
15//! 3. Implement [`PluginFactory`] to construct the plugin from config.
16//! 4. Export `pub fn folk_plugin_factory() -> Box<dyn PluginFactory>`.
17//!
18//! See `folk-spec/adr/0006-plugin-api-shape.md` for the full design rationale,
19//! and `folk-plugin-http` for a complete working example (phase 6).
20
21pub mod context;
22pub mod executor;
23pub mod factory;
24pub mod health;
25pub mod metrics;
26pub mod plugin;
27pub mod response;
28pub mod rpc;
29pub mod server_plugin;
30
31pub use context::PluginContext;
32pub use executor::{Executor, value_to_chunks};
33pub use factory::PluginFactory;
34pub use health::{HealthCheckFn, HealthRegistry, HealthStatus};
35pub use metrics::{Counter, CounterVec, Gauge, GaugeVec, Histogram, HistogramVec, MetricsRegistry};
36pub use plugin::Plugin;
37pub use response::ResponseChunk;
38pub use rpc::{BoxFuture, RpcHandler, RpcMethodDef, RpcRegistrar};
39pub use server_plugin::{ServerPlugin, ServerPluginWrapper};
40
41/// The Folk API version. Equals this crate's `Cargo.toml` `version` field.
42///
43/// Used for diagnostics and the `folk --version` output. There is no runtime
44/// version negotiation; see `folk-spec/adr/0004-no-capability-negotiation.md`.
45pub const FOLK_API_VERSION: &str = env!("CARGO_PKG_VERSION");