Skip to main content

CpClient

Struct CpClient 

Source
pub struct CpClient { /* private fields */ }
Expand description

Outbound client to a control plane’s per-tenant edge API.

Implementations§

Source§

impl CpClient

Source

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.

Source

pub async fn pull_policy(&self, etag: Option<&str>) -> Result<PullResult>

Conditional policy pull. 200Policy; 304NotModified; other statuses → Err.

Source

pub fn set_policy_etag(&self, etag: &str)

Record the ETag of the policy now applied, so the next usage report carries it.

Source

pub async fn report_usage(&self, delta: &UsageDelta) -> Result<()>

Report a usage delta, with this edge’s heartbeat on the same body.

Source

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.

Source

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.

Source

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.

Source

pub async fn forward_csp(&self, raw: &Bytes)

Forward a raw CSP report body (best-effort; errors are logged, never surfaced).

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more