Documentation
¶
Index ¶
- Variables
- func IsAmbiguousRenewError(err error) bool
- func SnapshotStateFromReadiness(r domain.Readiness) economics.SnapshotState
- func WrapError(op string, err error) error
- type AcquireCommand
- type AcquireResult
- type AcquireSetCommand
- type AcquireSetMember
- type AcquireSetResult
- type AdmitInput
- type AdmitResult
- type AdmittedLease
- type Clock
- type Error
- type LeaseSetOccupancyCounts
- type LeaseStore
- type Provider
- func (p *Provider) AdmitLease(ctx context.Context, in authority.LeaseAdmission) (authority.LeaseDecision, error)
- func (p *Provider) MarkLeaseSetUncertain(ctx context.Context, setID string) error
- func (p *Provider) QueryLeases(ctx context.Context, q authority.LeaseQuery) (authority.LeasePage, error)
- func (p *Provider) ReleaseLease(ctx context.Context, in authority.LeaseRelease) error
- func (p *Provider) RenewLease(ctx context.Context, in authority.LeaseRenew) (authority.LeaseDecision, error)
- type QueryCommand
- type QueryResult
- type QuerySetsCommand
- type QuerySetsResult
- type ReleaseCommand
- type ReleaseInput
- type ReleaseResult
- type ReleaseSetCommand
- type ReleaseSetResult
- type RenewCommand
- type RenewInput
- type RenewResult
- type RenewSetCommand
- type RenewSetResult
- type RuleSnapshot
- type RuleSource
- type Service
- func (s *Service) Admit(ctx context.Context, in AdmitInput) (AdmitResult, error)
- func (s *Service) LeaseSetOccupancyCounts(ctx context.Context) (LeaseSetOccupancyCounts, error)
- func (s *Service) Query(ctx context.Context, q QueryCommand) (QueryResult, error)
- func (s *Service) Readiness(ctx context.Context) (authority.Readiness, error)
- func (s *Service) ReadinessDomain(ctx context.Context) (domain.Readiness, error)
- func (s *Service) ReconcileUncertainSets(ctx context.Context) ([]string, error)
- func (s *Service) Release(ctx context.Context, in ReleaseInput) error
- func (s *Service) Renew(ctx context.Context, in RenewInput) (AdmitResult, error)
- func (s *Service) RulesSnapshot(ctx context.Context) (RuleSnapshot, error)
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotFound = errors.New("concurrencyauthority: lease not found") ErrInvalidInput = errors.New("concurrencyauthority: invalid input") ErrSnapshotEmpty = errors.New("concurrencyauthority: rule snapshot unavailable") )
Sentinel application errors.
Functions ¶
func IsAmbiguousRenewError ¶
IsAmbiguousRenewError reports whether err means occupancy may still be held after an unconfirmed renew attempt (timeout/transport/unavailable).
func SnapshotStateFromReadiness ¶
func SnapshotStateFromReadiness(r domain.Readiness) economics.SnapshotState
SnapshotStateFromReadiness maps concurrency readiness onto economics.SnapshotState.
Types ¶
type AcquireCommand ¶
type AcquireCommand struct {
Lease domain.Lease
RuleID string
Dimensions domain.Dimensions
Limit int
Mode domain.RuleMode
Now time.Time
}
AcquireCommand requests an idempotent lease insert under a capacity limit.
type AcquireResult ¶
type AcquireResult struct {
Lease domain.Lease
Replayed bool
RemainingSlots int
CapacityExceeded bool
Rejected bool
}
AcquireResult is the store outcome for one acquire attempt.
type AcquireSetCommand ¶
type AcquireSetCommand struct {
SetID string
RequestID string
Members []AcquireSetMember
TTL time.Duration
RenewBefore time.Duration
Now time.Time
}
AcquireSetCommand requests atomic multi-rule occupancy for one logical request.
type AcquireSetMember ¶
type AcquireSetMember struct {
Lease domain.Lease
RuleID string
Dimensions domain.Dimensions
Limit int
Mode domain.RuleMode
}
AcquireSetMember is one rule occupancy proposed for an atomic set acquire.
type AcquireSetResult ¶
type AcquireSetResult struct {
Set domain.LeaseSet
Replayed bool
RemainingSlots int
CapacityExceeded bool
Rejected bool
LockOrder []string
DenyingRuleID string
}
AcquireSetResult is the store outcome for one set acquire/replay.
type AdmitInput ¶
type AdmitInput struct {
RequestID string
Scope scope.PrincipalScopeView
Namespace string
TTL time.Duration
BoundVersion economics.PolicySnapshotRef
IdempotencyKey string
Lifecycle metering.LifecycleScope
ParentLeaseID string
AuxPolicy domain.AuxPolicy
RuleID string
}
AdmitInput is application-level lease admission input.
type AdmitResult ¶
type AdmitResult struct {
Kind domain.DecisionKind
LeaseID string
Generation int64
ExpiresAt time.Time
RemainingSlots int
Readiness domain.Readiness
BoundVersion economics.PolicySnapshotRef
Evidence domain.Evidence
Acquired bool
Replayed bool
RuleID string
RenewBefore time.Duration
TTL time.Duration
FailureBehavior domain.FailureBehavior
// Leases holds all rule occupancies from this Admit. It is empty on deny,
// and on error every lease acquired by this Admit is rolled back.
Leases []AdmittedLease
SetID string
}
AdmitResult is the application admit outcome.
For multi-rule allow, scalar LeaseID/Generation/... are the primary lease (last successfully acquired / lastAllow) for backward compatibility. Leases lists every occupancy acquired or replayed in this Admit.
type AdmittedLease ¶
type AdmittedLease struct {
LeaseID string
RuleID string
Generation int64
ExpiresAt time.Time
RenewBefore time.Duration
TTL time.Duration
FailureBehavior domain.FailureBehavior
Acquired bool
Replayed bool
}
AdmittedLease is one rule occupancy acquired or replayed during Admit.
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error wraps an operation failure without leaking store details.
type LeaseSetOccupancyCounts ¶
type LeaseSetOccupancyCounts struct {
Active int
Uncertain int
Expiring int
Released int
Failed int
}
LeaseSetOccupancyCounts is a bounded control-plane projection of set states.
type LeaseStore ¶
type LeaseStore interface {
Acquire(ctx context.Context, cmd AcquireCommand) (AcquireResult, error)
Renew(ctx context.Context, cmd RenewCommand) (RenewResult, error)
Release(ctx context.Context, cmd ReleaseCommand) (ReleaseResult, error)
Query(ctx context.Context, q QueryCommand) (QueryResult, error)
CheckReadiness(ctx context.Context) (domain.Readiness, error)
// Atomic lease-set operations (Phase 6 / requirements 10.3–10.9).
AcquireSet(ctx context.Context, cmd AcquireSetCommand) (AcquireSetResult, error)
RenewSet(ctx context.Context, cmd RenewSetCommand) (RenewSetResult, error)
ReleaseSet(ctx context.Context, cmd ReleaseSetCommand) (ReleaseSetResult, error)
QuerySets(ctx context.Context, q QuerySetsCommand) (QuerySetsResult, error)
MarkSetUncertain(ctx context.Context, setID string, now time.Time) error
}
LeaseStore is the persistence port implemented by task 8.2 dialects.
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider adapts Service onto authority.ConcurrencyProvider.
func NewProvider ¶
NewProvider returns a ConcurrencyProvider backed by svc.
func (*Provider) AdmitLease ¶
func (p *Provider) AdmitLease(ctx context.Context, in authority.LeaseAdmission) (authority.LeaseDecision, error)
AdmitLease implements authority.ConcurrencyProvider.
func (*Provider) MarkLeaseSetUncertain ¶
MarkLeaseSetUncertain marks a set conservatively occupied after ambiguous renew.
func (*Provider) QueryLeases ¶
func (p *Provider) QueryLeases(ctx context.Context, q authority.LeaseQuery) (authority.LeasePage, error)
QueryLeases implements authority.ConcurrencyProvider.
func (*Provider) ReleaseLease ¶
ReleaseLease implements authority.ConcurrencyProvider.
func (*Provider) RenewLease ¶
func (p *Provider) RenewLease(ctx context.Context, in authority.LeaseRenew) (authority.LeaseDecision, error)
RenewLease implements authority.ConcurrencyProvider.
type QueryCommand ¶
type QueryCommand struct {
LeaseID string
RequestID string
RuleID string
State domain.LeaseState
Now time.Time
Limit int
}
QueryCommand is a bounded lease query.
type QueryResult ¶
QueryResult is a bounded page of leases.
type QuerySetsCommand ¶
type QuerySetsCommand struct {
SetID string
RequestID string
State domain.LeaseSetState
Now time.Time
Limit int
}
QuerySetsCommand is a bounded lease-set query.
type QuerySetsResult ¶
QuerySetsResult is a bounded page of lease sets.
type ReleaseCommand ¶
ReleaseCommand releases a lease idempotently.
type ReleaseInput ¶
ReleaseInput is application-level lease release input.
type ReleaseResult ¶
ReleaseResult is the store outcome for release.
type ReleaseSetCommand ¶
ReleaseSetCommand releases an entire lease set idempotently.
type ReleaseSetResult ¶
ReleaseSetResult is the store outcome for set release.
type RenewCommand ¶
type RenewCommand struct {
LeaseID string
RequestID string
ExpectedGeneration int64
TTL time.Duration
Now time.Time
}
RenewCommand extends a lease with generation CAS.
type RenewInput ¶
type RenewInput struct {
LeaseID string
RequestID string
ExpectedGeneration int64
TTL time.Duration
SetID string
RenewBefore time.Duration
}
RenewInput is application-level lease renewal input.
type RenewResult ¶
RenewResult is the store outcome for renew.
type RenewSetCommand ¶
type RenewSetCommand struct {
SetID string
RequestID string
ExpectedGeneration int64
TTL time.Duration
RenewBefore time.Duration
Now time.Time
}
RenewSetCommand renews every member of a lease set under one generation CAS.
type RenewSetResult ¶
RenewSetResult is the store outcome for set renew.
type RuleSnapshot ¶
type RuleSnapshot struct {
ID string
Version string
EffectiveAt time.Time
FetchedAt time.Time
State economics.SnapshotState
Readiness domain.Readiness
Rules []domain.Rule
}
RuleSnapshot is the immutable rule set consumed by admit orchestration.
func (RuleSnapshot) PolicyRef ¶
func (s RuleSnapshot) PolicyRef() economics.PolicySnapshotRef
PolicyRef returns the bindable policy snapshot identity for this rule set.
type RuleSource ¶
type RuleSource interface {
Snapshot(ctx context.Context) (RuleSnapshot, error)
}
RuleSource provides immutable concurrency rule snapshots.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service owns concurrency-lease orchestration for admit, renew, release, query, and readiness. Persistence dialects implement LeaseStore (task 8.2).
func NewService ¶
func NewService(rules RuleSource, store LeaseStore, clock Clock) *Service
NewService constructs a service with explicit dependencies. A nil clock uses the system wall clock.
func (*Service) Admit ¶
func (s *Service) Admit(ctx context.Context, in AdmitInput) (AdmitResult, error)
Admit acquires or replays occupancy for matching rules. Strict multi-rule matches use one atomic lease set; advisory rules still use per-lease Acquire. If admission fails after occupancy was acquired, the leases newly acquired by this call are rolled back (replayed pre-existing leases are left untouched).
func (*Service) LeaseSetOccupancyCounts ¶
func (s *Service) LeaseSetOccupancyCounts(ctx context.Context) (LeaseSetOccupancyCounts, error)
LeaseSetOccupancyCounts returns bounded occupancy counts by set state.
func (*Service) Query ¶
func (s *Service) Query(ctx context.Context, q QueryCommand) (QueryResult, error)
Query returns a bounded lease page.
func (*Service) Readiness ¶
Readiness maps domain readiness onto the public authority readiness enum.
func (*Service) ReadinessDomain ¶
ReadinessDomain returns domain readiness from store (and optional snapshot). Uncertain or failed lease-set occupancy degrades readiness (task 6.4 remediation).
func (*Service) ReconcileUncertainSets ¶
ReconcileUncertainSets conservatively keeps uncertain sets occupied and returns their IDs for durable release-work resumption (startup reconciliation).
func (*Service) Release ¶
func (s *Service) Release(ctx context.Context, in ReleaseInput) error
Release releases a lease or lease set idempotently.
func (*Service) Renew ¶
func (s *Service) Renew(ctx context.Context, in RenewInput) (AdmitResult, error)
Renew extends an active lease or lease set with generation CAS.
func (*Service) RulesSnapshot ¶
func (s *Service) RulesSnapshot(ctx context.Context) (RuleSnapshot, error)
RulesSnapshot returns the current immutable rule set for capacity queries.