cache

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: 28 Imported by: 0

Documentation

Index

Constants

View Source
const MaxBlockListEntries = 50_000

MaxBlockListEntries is the Azure block blob protocol limit.

Variables

View Source
var (
	ErrNoWriteScope        = errors.New("no scope with write permission found")
	ErrUploadAlreadyExists = errors.New("upload already exists")
	ErrUploadNotFound      = errors.New("upload not found")
	ErrNoPartsUploaded     = errors.New("no parts have been uploaded")
	ErrPartCountMismatch   = errors.New("uploaded part count does not match actual part count in storage")
	ErrBlockListTooLarge   = errors.New("block list exceeds 50000 entries")
	ErrCacheNotFound       = errors.New("cache not found")
)

Functions

func ReadScopesByPermission

func ReadScopesByPermission(scope auth.CacheScope) []string

func WriteScope

func WriteScope(scope auth.CacheScope) (string, bool)

Types

type BlockListCommit added in v1.1.1

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

BlockListCommit is an upload-scoped capability prepared before the block list request body is parsed. Its upload snapshot is intentionally opaque to callers.

func (*BlockListCommit) Commit added in v1.1.1

func (c *BlockListCommit) Commit(ctx context.Context, blockIDs []string) error

type CapacityTrigger added in v1.1.1

type CapacityTrigger interface {
	Trigger()
}

type CreateUploadResult

type CreateUploadResult struct {
	UploadID int64
}

type DownloadError added in v1.1.1

type DownloadError struct {
	Err               error
	CacheEntryID      string
	StorageLocationID string
	Representation    string
}

func (*DownloadError) Error added in v1.1.1

func (e *DownloadError) Error() string

func (*DownloadError) Unwrap added in v1.1.1

func (e *DownloadError) Unwrap() error

type DownloadStream added in v1.1.1

type DownloadStream struct {
	io.ReadCloser
	CacheEntryID      string
	StorageLocationID string
	Representation    string
}

type MatchResult

type MatchResult struct {
	CacheEntry  *ent.CacheEntry
	DownloadURL string
}

type Options

type Options struct {
	DB                    *ent.Client
	Storage               storage.Adapter
	EnableDirectDownloads bool
	MergeConcurrency      int
	Lifecycle             *storagelifecycle.Service
	Logger                *zerolog.Logger
	Capacity              CapacityTrigger
}

type Service

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

func NewService

func NewService(options Options) *Service

func (*Service) CommitBlockList

func (s *Service) CommitBlockList(ctx context.Context, uploadID int64, blockIDs []string) error

func (*Service) CompleteUpload

func (s *Service) CompleteUpload(ctx context.Context, key, version string, scope auth.CacheScope) (int64, error)

func (*Service) CreateUpload

func (s *Service) CreateUpload(ctx context.Context, key, version string, scope auth.CacheScope) (*CreateUploadResult, error)

func (*Service) Download

func (s *Service) Download(ctx context.Context, cacheEntryID string) (*DownloadStream, error)

func (*Service) GetCacheEntryWithDownloadURL

func (s *Service) GetCacheEntryWithDownloadURL(ctx context.Context, keys []string, version string, scope auth.CacheScope, fallbackDownloadURL func(string) string) (*MatchResult, error)

func (*Service) MatchCacheEntry

func (s *Service) MatchCacheEntry(ctx context.Context, keys []string, version string, scope auth.CacheScope) (*ent.CacheEntry, error)

func (*Service) PrepareBlockListCommit added in v1.1.1

func (s *Service) PrepareBlockListCommit(ctx context.Context, uploadID int64) (*BlockListCommit, error)

func (*Service) StopAcceptingMerges

func (s *Service) StopAcceptingMerges()

func (*Service) UploadBlock

func (s *Service) UploadBlock(ctx context.Context, uploadID int64, blockID string, stream io.Reader) error

func (*Service) UploadPart

func (s *Service) UploadPart(ctx context.Context, uploadID int64, stream io.Reader) error

func (*Service) WaitForMerges

func (s *Service) WaitForMerges(ctx context.Context) error

Jump to

Keyboard shortcuts

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