pub struct CpClient { /* private fields */ }Expand description
Outbound client to a control plane’s per-tenant edge API.
Implementations§
Source§impl CpClient
impl CpClient
Sourcepub fn from_cfg(cfg: &ControlPlaneCfg) -> Result<Option<Arc<CpClient>>>
pub fn from_cfg(cfg: &ControlPlaneCfg) -> Result<Option<Arc<CpClient>>>
Build the client if managed mode is enabled and configured; otherwise None. Fails fast on
an enabled-but-incomplete config so a misconfigured edge doesn’t silently run unmanaged.
Sourcepub async fn pull_policy(&self, etag: Option<&str>) -> Result<PullResult>
pub async fn pull_policy(&self, etag: Option<&str>) -> Result<PullResult>
Conditional policy pull. 200 → Policy; 304 → NotModified; other statuses → Err.
Sourcepub fn set_policy_etag(&self, etag: &str)
pub fn set_policy_etag(&self, etag: &str)
Record the ETag of the policy now applied, so the next usage report carries it.
Sourcepub async fn report_usage(&self, delta: &UsageDelta) -> Result<()>
pub async fn report_usage(&self, delta: &UsageDelta) -> Result<()>
Report a usage delta, with this edge’s heartbeat on the same body.
Sourcepub async fn pull_quota(&self) -> Result<(bool, i64)>
pub async fn pull_quota(&self) -> Result<(bool, i64)>
Pull the tenant’s current quota verdict (over_quota + reset_epoch). Any non-success
status is an error so the caller keeps the last verdict rather than acting on a partial read.
Sourcepub async fn acme_lease(
&self,
directory_url: &str,
domains: &[String],
) -> Result<LeaseVerdict>
pub async fn acme_lease( &self, directory_url: &str, domains: &[String], ) -> Result<LeaseVerdict>
Ask the control plane for permission to order a certificate for domains.
This is the fleet-wide half of the ACME budget. The local ledger in
crate::acme_budget can only account limits that are per-edge; the CA’s
per-registered-domain limit is shared across every edge under that domain, and only
something all of them talk to can count it. That is the control plane.
The edge sends raw identifiers and nothing else. It does not compute or send a bucket key: the control plane derives those, so that an edge cannot — by accident or otherwise — key itself into a private bucket and opt out of the shared limit.
Any error here means the caller falls back to the local budget; see LeaseVerdict.
Sourcepub async fn acme_lease_outcome(&self, lease_id: &str, outcome: &str)
pub async fn acme_lease_outcome(&self, lease_id: &str, outcome: &str)
Tell the control plane how a leased order ended. Best-effort: the lease is already debited and is never refunded, so a lost report costs observability, not correctness. An unreported lease is closed as consumed by the control plane once it expires.
Sourcepub async fn forward_csp(&self, raw: &Bytes)
pub async fn forward_csp(&self, raw: &Bytes)
Forward a raw CSP report body (best-effort; errors are logged, never surfaced).