storagelifecycle

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ReaderLeaseDuration          = 2 * time.Minute
	LeaseRenewalInterval         = 30 * time.Second
	DirectDownloadLeaseDuration  = 10 * time.Minute
	DeletionGracePeriod          = DirectDownloadLeaseDuration
	MaterializationLeaseDuration = 2 * time.Minute
)

Variables

View Source
var (
	ErrLocationUnavailable      = errors.New("storage location is unavailable")
	ErrDirectRepresentation     = errors.New("storage location has no direct-download representation")
	ErrReaderLeaseLost          = errors.New("storage reader lease was lost")
	ErrMaterializationLeaseHeld = errors.New("materialization lease is already held")
	ErrMaterializationLeaseLost = errors.New("materialization lease was lost")
)

Functions

This section is empty.

Types

type AcquireReaderOptions

type AcquireReaderOptions struct {
	Direct bool
}

type CapacityEvictionResult

type CapacityEvictionResult struct {
	Claimed   bool
	Pinned    bool
	SizeBytes int64
}

type CapacityObservation

type CapacityObservation struct {
	LocationID       string
	LeaseVersion     int64
	LastDownloadedAt *int64
	RecencyAt        int64
}

type DeletionResult

type DeletionResult struct {
	Task      *ent.StorageDeletion
	Fenced    bool
	Finalized bool
}

type MaterializationLease

type MaterializationLease struct {
	Location   *ent.StorageLocation
	Token      string
	RenewAfter time.Duration
}

type Options

type Options struct {
	Now                          func() time.Time
	ReaderLeaseDuration          time.Duration
	LeaseRenewalInterval         time.Duration
	DirectDownloadLeaseDuration  time.Duration
	DeletionGracePeriod          time.Duration
	MaterializationLeaseDuration time.Duration
	ReaderAcquireRetryBackoff    time.Duration
}

type PartsDeletionResult

type PartsDeletionResult struct {
	Task      *ent.StorageDeletion
	PartCount int
}

type ReaderLease

type ReaderLease struct {
	ID         string
	Location   *ent.StorageLocation
	Scope      storagereaderlease.Scope
	ExpiresAt  time.Time
	RenewAfter time.Duration
}

type Service

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

func New

func New(db *ent.Client) *Service

func NewWithOptions

func NewWithOptions(db *ent.Client, options Options) *Service

func (*Service) AcquireMaterialization

func (s *Service) AcquireMaterialization(ctx context.Context, locationID string) (*MaterializationLease, error)

func (*Service) AcquireReader

func (s *Service) AcquireReader(ctx context.Context, cacheEntryID string, options AcquireReaderOptions) (*ReaderLease, error)

func (*Service) ClaimPartsDeletion

func (s *Service) ClaimPartsDeletion(ctx context.Context, locationID string) (PartsDeletionResult, error)

func (*Service) ExtendDirectReader

func (s *Service) ExtendDirectReader(ctx context.Context, leaseID string) error

func (*Service) FenceDetachedLocation

func (s *Service) FenceDetachedLocation(ctx context.Context, db *ent.Client, locationID string) (DeletionResult, error)

func (*Service) FinishMaterialization

func (s *Service) FinishMaterialization(ctx context.Context, locationID, token string) error

func (*Service) MarkMaterializationUnsupported

func (s *Service) MarkMaterializationUnsupported(ctx context.Context, locationID, token string) error

func (*Service) MaterializationActive

func (s *Service) MaterializationActive(location *ent.StorageLocation) bool

func (*Service) PurgeDanglingCacheEntry

func (s *Service) PurgeDanglingCacheEntry(ctx context.Context, cacheEntryID, locationID string) (bool, error)

PurgeDanglingCacheEntry removes an entry only if it still references the storage location that was confirmed missing. The location is fenced only after its final cache entry has been detached.

func (*Service) PurgeDanglingCacheEntryIfUnchanged

func (s *Service) PurgeDanglingCacheEntryIfUnchanged(ctx context.Context, cacheEntryID string, observed *ent.StorageLocation) (bool, error)

PurgeDanglingCacheEntryIfUnchanged removes an entry only while the storage representation and materialization ownership still match the state that was inspected before the missing object was confirmed. The conditional update is also the cross-dialect write lock used by the rest of the fencing model.

func (*Service) PurgeExpiredReaderLeases

func (s *Service) PurgeExpiredReaderLeases(ctx context.Context) (int, error)

func (*Service) ReleaseMaterialization

func (s *Service) ReleaseMaterialization(ctx context.Context, locationID, token string) error

func (*Service) ReleaseReader

func (s *Service) ReleaseReader(ctx context.Context, leaseID string) error

func (*Service) RenewMaterialization

func (s *Service) RenewMaterialization(ctx context.Context, locationID, token string) error

func (*Service) RenewReader

func (s *Service) RenewReader(ctx context.Context, leaseID string) error

func (*Service) RequestCapacityEviction

func (s *Service) RequestCapacityEviction(ctx context.Context, observed CapacityObservation) (CapacityEvictionResult, error)

RequestCapacityEviction removes a location only while its access observation is still current. Active readers pin the location instead of merely delaying its physical deletion, which preserves capacity eviction's LRU contract.

func (*Service) RequestExpiredLocationDeletion

func (s *Service) RequestExpiredLocationDeletion(ctx context.Context, locationID string, cutoff int64) (DeletionResult, error)

RequestExpiredLocationDeletion atomically rechecks retention eligibility after fencing concurrent readers and cache-entry replacement transactions.

func (*Service) RequestLocationDeletion

func (s *Service) RequestLocationDeletion(ctx context.Context, locationID string, deleteCacheEntries, requireOrphan bool) (DeletionResult, error)

Jump to

Keyboard shortcuts

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