Documentation
¶
Overview ¶
Package billingbinding adapts one validated public billing.Binding to the existing internal runtime chokepoints: the cheap pre-route credit screen, the quote/atomic exposure admission authority, and the terminal evidence handoff.
The adapter translates internal call facts into public typed DTOs and projects binding results back onto internal domain records. It performs no rating, journal writes, or provider-field parsing; the binding owns its snapshots, workers, and raters. Binding-owned resources start once through StartOwnedResources and close once in reverse order through Close; borrowed handles are declared only and are never closed.
The reference internal billing composition (ComposeBilling) and an external binding occupy the same ProductionOptions chokepoints, so both exercise the same runtime admission and terminal paths.
Index ¶
- Variables
- type Adapter
- func (a *Adapter) Admit(ctx context.Context, in runtimecore.BillingExposureAdmissionInput) (billing.CallExposure, error)
- func (a *Adapter) AppendCall(ctx context.Context, record billing.CallUsageRecord) error
- func (a *Adapter) AppendLeg(ctx context.Context, record billing.CallLegUsageRecord) error
- func (a *Adapter) Check(ctx context.Context, accountID string) error
- func (a *Adapter) Chokepoints() (runtimecore.BillingCreditGate, runtimecore.BillingExposureAdmission, ...)
- func (a *Adapter) Close() error
- func (a *Adapter) Identity() runtimecore.BillingIdentity
- func (a *Adapter) StartOwnedResources(ctx context.Context) error
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidBinding identifies a binding the adapter refuses to compose. ErrInvalidBinding = errors.New("billingbinding: invalid binding") // ErrCreditScreen identifies a failed cheap credit screen translation. ErrCreditScreen = errors.New("billingbinding: credit screen failed") // ErrAdmission identifies a failed quote/admission translation. ErrAdmission = errors.New("billingbinding: exposure admission failed") // ErrTerminal identifies a failed terminal handoff translation. ErrTerminal = errors.New("billingbinding: terminal handoff failed") // ErrLifecycle identifies a binding-owned resource lifecycle failure. ErrLifecycle = errors.New("billingbinding: lifecycle failed") )
Functions ¶
This section is empty.
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
Adapter binds one validated public billing.Binding to the internal runtime billing chokepoints. It is safe for concurrent use by the executor.
func NewAdapter ¶
func NewAdapter(binding sdkbilling.Binding) (*Adapter, error)
NewAdapter validates the binding before publication. It rejects invalid, typed-nil, and incomplete bindings; duplicate monetary bindings are rejected by sdkbilling.ValidateBindings at the facade.
func (*Adapter) Admit ¶
func (a *Adapter) Admit(ctx context.Context, in runtimecore.BillingExposureAdmissionInput) (billing.CallExposure, error)
Admit implements atomic exposure admission by quoting the frozen offer through the binding quoter and admitting the frozen quote through the binding admission port. It exercises the same runtime admission path as the reference composition: the executor calls Admit once per route plan.
func (*Adapter) AppendCall ¶
AppendCall implements the terminal call-closure handoff. Call closures carry identity, outcome, and frozen references; request-scoped inference evidence travels on B-leg envelopes.
func (*Adapter) AppendLeg ¶
AppendLeg implements the terminal B-leg handoff by translating the leg record — including its neutral V2 observations — into a public terminal envelope. The binding durably acknowledges; success is returned only for a valid acknowledgement.
func (*Adapter) Check ¶
Check implements the cheap pre-route credit screen by translating the account identity into a public credit-screen input. Unknown scope fails closed without calling the binding. A deny maps onto the internal denied class so the executor classifies it exactly like the reference path. The binary gate cannot carry degraded guarantees, so degraded fails closed through the existing unavailable class before provider execution; it is never ordinary allow. Any other failure stays unavailable.
func (*Adapter) Chokepoints ¶
func (a *Adapter) Chokepoints() (runtimecore.BillingCreditGate, runtimecore.BillingExposureAdmission, billing.TerminalUsageSink, runtimecore.BillingIdentity)
Chokepoints exposes the adapter as the three runtime billing chokepoints plus the billing identity. The host composition assigns them onto the same production ports as the internal reference composition; the adapter never invents an internal store.
func (*Adapter) Close ¶
Close releases started binding-owned resources once, in reverse start order. Borrowed handles are never touched. It is registered with host cleanup exactly once, so normal Host/Manager Close and repeated Close dispose owned resources exactly once.
func (*Adapter) Identity ¶
func (a *Adapter) Identity() runtimecore.BillingIdentity
Identity resolves runtime billing identity from the binding scope and trusted per-request scope. It is wire-bounded: resolvers read only scope and static snapshot identities, never provider-shaped request data, so the large-payload fast path stays open.
func (*Adapter) StartOwnedResources ¶
StartOwnedResources starts binding-owned resources once, in registration order. A start failure unwinds already-started resources in reverse order and leaves the adapter unstarted so the build fails before publication.