Documentation
¶
Overview ¶
Package memory is the compatibility facade for the target-oriented process-local replay and revocation adapter. Start with explicit clocks and NewConsumptionStore/NewRevocations. Canonical adapter locks own state, which is lost on restart; callers own cleanup cutoffs, capacity and revocation errors. No worker, persistent backend or close lifecycle is introduced.
Deprecated: use github.com/faustbrian/go-capability/v2/adapters/memory. This package remains supported through the documented compatibility interval.
Index ¶
- type Clock
- type ConsumptionStore
- type Revocations
- func (store *Revocations) Check(ctx context.Context, query capability.RevocationQuery) (bool, error)
- func (store *Revocations) RevokeCapability(ctx context.Context, issuer, capabilityID string) error
- func (store *Revocations) RevokeIssuedBefore(ctx context.Context, issuer string, cutoff time.Time) error
- func (store *Revocations) RevokeKey(ctx context.Context, issuer, keyID string) error
- func (store *Revocations) RevokeResource(ctx context.Context, issuer, tenant, resource string) error
- func (store *Revocations) RevokeSubject(ctx context.Context, issuer, subject string) error
- type StoreLimits
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Clock ¶
type Clock interface {
// Now supplies trusted wall time concurrently and promptly; called by the
// canonical store outside its locks.
Now() time.Time
}
Clock supplies wall time for expiry decisions.
type ConsumptionStore ¶
type ConsumptionStore struct {
// contains filtered or unexported fields
}
ConsumptionStore preserves the released compatibility-path type identity while delegating all behavior to the canonical adapter. Zero is unusable; Consume/Cleanup share the canonical synchronization/clock/admission owner.
func NewConsumptionStore ¶
func NewConsumptionStore(clock Clock) (*ConsumptionStore, error)
NewConsumptionStore constructs an empty store with DefaultStoreLimits.
func NewConsumptionStoreWithLimits ¶
func NewConsumptionStoreWithLimits(clock Clock, limits StoreLimits) (*ConsumptionStore, error)
NewConsumptionStoreWithLimits copies positive budgets into the canonical store but borrows Clock. Nil clock/invalid limits return nil and ErrInvalidConfiguration; typed nil and blocking/panicking clocks are caller-owned.
func (*ConsumptionStore) Cleanup ¶
Cleanup releases removed count and string-byte admission. The trusted caller must choose a cutoff beyond all relevant acceptance windows to avoid resetting live allowance; no background cleanup runs.
func (*ConsumptionStore) Consume ¶
func (store *ConsumptionStore) Consume(ctx context.Context, request capability.Consumption) (capability.ConsumptionResult, error)
Consume records a use through the canonical finite store. ErrCapacity is a known no-consume refusal; repeats do not charge additional admission.
type Revocations ¶
type Revocations struct {
// contains filtered or unexported fields
}
Revocations preserves the released compatibility-path type identity while delegating to the canonical finite adapter. Administrative writers must handle ErrCapacity: a failed insertion does not revoke authority. Zero is unusable; canonical owner locks serialize methods, without expiry/removal or distributed propagation. The wrapper owns no additional state or worker.
func NewRevocations ¶
func NewRevocations() *Revocations
NewRevocations constructs an empty set with DefaultStoreLimits.
func NewRevocationsWithLimits ¶
func NewRevocationsWithLimits(limits StoreLimits) (*Revocations, error)
NewRevocationsWithLimits constructs a set with explicit positive budgets.
func (*Revocations) Check ¶
func (store *Revocations) Check(ctx context.Context, query capability.RevocationQuery) (bool, error)
Check reports whether any exact revocation boundary matches query.
func (*Revocations) RevokeCapability ¶
func (store *Revocations) RevokeCapability(ctx context.Context, issuer, capabilityID string) error
RevokeCapability revokes one capability ID within an issuer namespace.
func (*Revocations) RevokeIssuedBefore ¶
func (store *Revocations) RevokeIssuedBefore(ctx context.Context, issuer string, cutoff time.Time) error
RevokeIssuedBefore revokes capabilities issued strictly before cutoff.
func (*Revocations) RevokeKey ¶
func (store *Revocations) RevokeKey(ctx context.Context, issuer, keyID string) error
RevokeKey revokes every capability signed by one key ID for an issuer.
func (*Revocations) RevokeResource ¶
func (store *Revocations) RevokeResource(ctx context.Context, issuer, tenant, resource string) error
RevokeResource revokes an exact issuer, tenant, and resource boundary.
func (*Revocations) RevokeSubject ¶
func (store *Revocations) RevokeSubject(ctx context.Context, issuer, subject string) error
RevokeSubject revokes every subject-bound capability for an issuer.
type StoreLimits ¶
type StoreLimits = capabilitymemory.StoreLimits
StoreLimits preserves the canonical finite process-local budget contract.
func DefaultStoreLimits ¶
func DefaultStoreLimits() StoreLimits
DefaultStoreLimits returns the canonical finite defaults.