Skip to main content

cc_lb_plugin_api/
lib.rs

1//! Public plugin contract for the `cc-lb` proxy lifecycle.
2//!
3//! The core proxy owns the wire-level server loop and drives requests through
4//! `parse -> authenticate -> route -> shape -> sign -> relay_stream`.
5//! This crate defines the stable types and object-safe traits used at those
6//! boundaries: authentication plugins identify a [`Principal`], router plugins
7//! choose an [`Upstream`] and [`UpstreamDialect`], dialects build a
8//! [`ShapedRequest`], signers consume it into a [`SignedRequest`], and the core
9//! relays the signed request while emitting [`ObserveEvent`] values to
10//! observability hooks.
11//!
12//! The crate deliberately uses `http`, `bytes`, and `url` types instead of
13//! exposing the server's transport implementation. Request body validation,
14//! semantic JSON checks, and concrete HTTP client behavior live in downstream
15//! crates, not in this API contract.
16
17#![deny(unsafe_code)]
18#![warn(missing_docs)]
19
20mod errors;
21mod traits;
22pub mod types;
23
24pub use errors::{
25    DialectError, ObservabilityError, RouteError, RuntimeError, SignerError, UpstreamError,
26};
27#[allow(deprecated)]
28pub use traits::RouterPlugin;
29pub use traits::{
30    ApiKeyAwareSignerFactory, FilterError, FilterOutput, FilterPlugin, ObservabilityHook,
31    PluginRuntime, Signer, SignerFactory, UpstreamDialect,
32};
33pub use types::{
34    CredentialStrategy, InternalError, InternalErrorKind, InternalErrorStage, ObserveEvent,
35    PerCandidateReason, PluginManifest, PluginSlot, Principal, PrincipalKind, PrincipalQuotas,
36    RateLimitKind, RateLimitObservation, RequestContext, RetryDecision, RouteDecision,
37    RoutingTrace, ShapedRequest, ShapedRequestBuilder, SignedRequest, SigningCapability,
38    SubscriptionQuotaCandidateSnapshot, SubscriptionQuotaDataState, TerminalStrategy, Upstream,
39    UpstreamCandidate, UpstreamKind, shape_request, sign_request,
40};
41
42/// Stable registry id for the built-in cache-affinity router filter.
43pub const BUILTIN_CACHE_AFFINITY_ID: uuid::Uuid = uuid::Uuid::from_u128(1);
44
45/// Stable registry name for the built-in cache-affinity router filter.
46pub const BUILTIN_CACHE_AFFINITY_NAME: &str = "cache-affinity";
47
48/// Wire version exposed by the built-in cache-affinity router filter.
49pub const BUILTIN_CACHE_AFFINITY_WIRE_VERSION: u8 = 3;
50
51mod private {
52    #[derive(Clone, Copy, Debug, Eq, PartialEq)]
53    pub(crate) struct Seal;
54}