memory

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package memory supplies an explicit single-process lockout authority. It is useful for tests and local applications; it is never a Redis failure fallback.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

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

Backend is a mutex-protected, bounded process-local lockout authority.

func New

func New(maxEntries int, source clock.Clock) (*Backend, error)

New creates a bounded in-memory authority using source as its clock.

func (*Backend) Close

func (b *Backend) Close() error

Close seals the backend and clears its retained lockout entries under its mutex.

func (*Backend) LockoutBegin

func (b *Backend) LockoutBegin(ctx context.Context, key lockout.Key, policy lockout.Policy, candidate lockout.Generation) (lockout.Admission, error)

LockoutBegin atomically checks the lock and returns the current snapshot for an allowed attempt.

func (*Backend) LockoutFinish

func (b *Backend) LockoutFinish(ctx context.Context, key lockout.Key, policy lockout.Policy, snapshot lockout.Snapshot, outcome lockout.Outcome) (lockout.Decision, error)

LockoutFinish atomically applies an admitted outcome; stale successes cannot clear newer failures, and expired generations do not mutate current state.

func (*Backend) LockoutReset

func (b *Backend) LockoutReset(ctx context.Context, key lockout.Key, policy lockout.Policy) (bool, error)

LockoutReset atomically removes the key's state and reports whether it existed.

Jump to

Keyboard shortcuts

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