lease

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 22, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package lease implements the lease enforcement primitives: glob match, target canonicalization, expires_at and budget checks.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CanonicalizePath

func CanonicalizePath(p string) string

CanonicalizePath collapses dot segments and double slashes. A leading slash is preserved.

func CanonicalizeURL

func CanonicalizeURL(raw string) (string, error)

CanonicalizeURL lowercases scheme/host and normalises path.

func IsSubset

func IsSubset(parent, child arcp.Lease, parentRemaining map[arcp.Currency]float64, parentExpiry, childExpiry *time.Time) error

IsSubset reports whether child is a subset of parent: every child capability appears in parent and every child pattern is matched by at least one parent pattern. Budget patterns are compared numerically against parentRemaining.

Types

type State

type State struct {
	// contains filtered or unexported fields
}

State holds the runtime-mutable lease state for one job: the immutable lease, the optional expires_at deadline, and per-currency budget counters.

func NewState

func NewState(lease arcp.Lease, expiresAt *time.Time) *State

NewState builds a State from the lease grant and accept time.

func (*State) Budget

func (s *State) Budget() map[arcp.Currency]float64

Budget returns a snapshot of remaining per-currency budget.

func (*State) Debit

func (s *State) Debit(cur arcp.Currency, v float64) (float64, error)

Debit subtracts v from the named currency counter. Returns the remaining balance and any error.

func (*State) ExpiresAt

func (s *State) ExpiresAt() *time.Time

ExpiresAt returns the lease expiry, if any.

func (*State) HasBudget

func (s *State) HasBudget() bool

HasBudget reports whether the lease has any cost.budget counters.

func (*State) Initial

func (s *State) Initial() map[arcp.Currency]float64

Initial returns the per-currency starting budget.

func (*State) Lease

func (s *State) Lease() arcp.Lease

Lease returns the immutable lease grant.

func (*State) ValidateOp

func (s *State) ValidateOp(now time.Time, cap arcp.Capability, target string) error

ValidateOp checks that op (capability, target) is allowed under the lease at time now. Returns nil on success or a structured arcp.Error.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL