Documentation
¶
Index ¶
- Constants
- func BillingCapabilityLeaseID(scope contract.BusinessScope, binding plugin.ResolvedBinding, operation string) (string, error)
- func ScheduledJobHandlers(runtime engine.TenantJobRuntime) map[scheduler.JobType]scheduler.JobHandler
- func ScheduledJobHandlersWithBilling(runtime engine.TenantJobRuntime, provider BillingProvider) map[scheduler.JobType]scheduler.JobHandler
- func ScheduledJobHandlersWithModuleBilling(runtime engine.TenantJobRuntime) map[scheduler.JobType]scheduler.JobHandler
- type BillingLine
- type BillingObligation
- type BillingOwnerCommands
- type BillingPeriod
- type BillingProvider
- type BillingResult
- type CapabilityBillingAdapter
- func (a *CapabilityBillingAdapter) CreateObligation(ctx context.Context, execution policy.Execution, scope contract.ScopeContext, ...) (BillingResult, error)
- func (a *CapabilityBillingAdapter) ReconcileObligation(ctx context.Context, execution policy.Execution, scope contract.ScopeContext, ...) (BillingResult, error)
- type InternalBillingAdapter
- func (a InternalBillingAdapter) CreateObligation(ctx context.Context, execution policy.Execution, scope contract.ScopeContext, ...) (BillingResult, error)
- func (a InternalBillingAdapter) ReconcileObligation(ctx context.Context, execution policy.Execution, scope contract.ScopeContext, ...) (BillingResult, error)
Constants ¶
const ( BillingCapabilityName contract.CapabilityName = "billing.invoice" BillingCreateOperation string = "create_obligation@1" BillingReconcileOperation string = "reconcile_obligation@1" )
const ( BillingStateAccepted = "accepted" BillingStateIssued = "issued" BillingStatePending = "pending" BillingStateUnknown = "unknown" BillingStateNotFound = "not_found" )
const JobType scheduler.JobType = "subscription_invoice"
Variables ¶
This section is empty.
Functions ¶
func BillingCapabilityLeaseID ¶
func BillingCapabilityLeaseID(scope contract.BusinessScope, binding plugin.ResolvedBinding, operation string) (string, error)
BillingCapabilityLeaseID returns the stable ID used to provision the scheduler grant through the tenant's existing capability lease store.
func ScheduledJobHandlers ¶
func ScheduledJobHandlers(runtime engine.TenantJobRuntime) map[scheduler.JobType]scheduler.JobHandler
ScheduledJobHandlers registers the job for the subscription package while leaving billing capability availability to the application composition.
func ScheduledJobHandlersWithBilling ¶
func ScheduledJobHandlersWithBilling(runtime engine.TenantJobRuntime, provider BillingProvider) map[scheduler.JobType]scheduler.JobHandler
func ScheduledJobHandlersWithModuleBilling ¶
func ScheduledJobHandlersWithModuleBilling(runtime engine.TenantJobRuntime) map[scheduler.JobType]scheduler.JobHandler
ScheduledJobHandlersWithModuleBilling adapts the tenant's selected provider binding into the subscription billing port for this scheduler generation.
Types ¶
type BillingLine ¶
type BillingObligation ¶
type BillingObligation struct {
Source contract.BusinessRef `json:"source"`
BillingPeriod BillingPeriod `json:"billingPeriod"`
Customer contract.BusinessRef `json:"customer"`
Currency string `json:"currency"`
Lines []BillingLine `json:"lines"`
IdempotencyKey string `json:"idempotencyKey"`
}
func (BillingObligation) Validate ¶
func (o BillingObligation) Validate() error
type BillingOwnerCommands ¶
type BillingOwnerCommands interface {
CreateObligation(context.Context, policy.Execution, contract.ScopeContext, BillingObligation) (BillingResult, error)
ReconcileObligation(context.Context, policy.Execution, contract.ScopeContext, string) (BillingResult, error)
}
BillingOwnerCommands is the owner module's command boundary for internal billing. The adapter carries no invoice tables or accounting rules; owner commands must enforce durable uniqueness on the tenant-scoped idempotency key and expose authoritative reconciliation for that key.
type BillingPeriod ¶
type BillingProvider ¶
type BillingProvider interface {
// CreateObligation must durably deduplicate by obligation.IdempotencyKey.
// Repeating the same key must return the same obligation identity and must
// never create a second business effect.
CreateObligation(context.Context, policy.Execution, contract.ScopeContext, BillingObligation) (BillingResult, error)
// ReconcileObligation may return not_found only when no effect for key can
// still commit. pending/unknown must remain unresolved until authoritative.
ReconcileObligation(context.Context, policy.Execution, contract.ScopeContext, string) (BillingResult, error)
}
type BillingResult ¶
type BillingResult struct {
Obligation contract.BusinessRef `json:"obligation"`
State string `json:"state"`
ExternalReference string `json:"externalReference,omitempty"`
}
type CapabilityBillingAdapter ¶
type CapabilityBillingAdapter struct {
Plan plugin.BindingPlan
Caller contract.ModuleID
Scope contract.BusinessScope
LeaseStore plugin.CapabilityLeaseReader
Create contract.CapabilityLease
Reconcile contract.CapabilityLease
}
CapabilityBillingAdapter invokes the provider selected in the tenant's immutable module BindingPlan. Its durable leases fence each effect attempt.
func NewCapabilityBillingAdapter ¶
func NewCapabilityBillingAdapter(runtime engine.TenantJobRuntime) (*CapabilityBillingAdapter, error)
func (*CapabilityBillingAdapter) CreateObligation ¶
func (a *CapabilityBillingAdapter) CreateObligation(ctx context.Context, execution policy.Execution, scope contract.ScopeContext, obligation BillingObligation) (BillingResult, error)
func (*CapabilityBillingAdapter) ReconcileObligation ¶
func (a *CapabilityBillingAdapter) ReconcileObligation(ctx context.Context, execution policy.Execution, scope contract.ScopeContext, key string) (BillingResult, error)
type InternalBillingAdapter ¶
type InternalBillingAdapter struct{ Commands BillingOwnerCommands }
func (InternalBillingAdapter) CreateObligation ¶
func (a InternalBillingAdapter) CreateObligation(ctx context.Context, execution policy.Execution, scope contract.ScopeContext, obligation BillingObligation) (BillingResult, error)
func (InternalBillingAdapter) ReconcileObligation ¶
func (a InternalBillingAdapter) ReconcileObligation(ctx context.Context, execution policy.Execution, scope contract.ScopeContext, key string) (BillingResult, error)