store

package
v0.0.0-...-3231407 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// PrefetchWorkers is the number of workers that will be used to prefetch files.
	// To disable prefetch, set this to 0.
	PrefetchWorkers = 50

	// ResolveRetries is the number of times to attempt resolving a key before giving up.
	ResolveRetries = 3

	// ResolveTimeout is the timeout for resolving a key.
	ResolveTimeout = 20 * time.Millisecond
)

Functions

This section is empty.

Types

type File

type File interface {
	// Seek sets the current file offset.
	Seek(offset int64, whence int) (int64, error)

	// Fstat returns the size of the file.
	Fstat() (int64, error)

	// Read reads up to len(p) bytes into p. It returns the number of bytes read (0 <= n <= len(p)) and any error encountered.
	Read(p []byte) (n int, err error)

	// ReadAt reads len(p) bytes from the File starting at byte offset off. It returns the number of bytes read and the error, if any.
	ReadAt(buff []byte, off int64) (int, error)
}

File is an abstraction for a file that can be read from this store. It is similar to os.File.

type FilesStore

type FilesStore interface {
	// Key tries to find the cache key for the requested content or returns empty.
	Key(c *gin.Context) (key string, d digest.Digest, err error)

	// Open opens the requested file and starts prefetching it. It also returns the size of the file.
	Open(c *gin.Context) (File, error)

	// Subscribe returns a channel that will be notified when a blob is added to the store.
	Subscribe() chan string
}

FilesStore describes a store for files.

func NewFilesStore

func NewFilesStore(ctx context.Context, r routing.Router) (FilesStore, error)

NewFilesStore creates a new store.

type MockStore

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

func NewMockStore

func NewMockStore(ctx context.Context, r routing.Router) (*MockStore, error)

func (*MockStore) Cache

func (m *MockStore) Cache() cache.Cache

func (MockStore) Key

func (s MockStore) Key(c *gin.Context) (string, digest.Digest, error)

Key tries to find the cache key for the requested content or returns empty.

func (MockStore) Open

func (s MockStore) Open(c *gin.Context) (File, error)

Open opens the requested file and starts prefetching it.

func (MockStore) Subscribe

func (s MockStore) Subscribe() chan string

Subscribe returns a channel that will be notified when a blob is added to the store.

Jump to

Keyboard shortcuts

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