files

package
v2.24.0 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2025 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewOverlayFS added in v2.23.0

func NewOverlayFS(baseFS fs.FS, overlays []Overlay) fs.FS

Types

type Cache

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

Cache persists the files for template versions, and is used by dynamic parameters to deduplicate the files in memory. When any number of users opens the workspace creation form for a given template version, it's files are loaded into memory exactly once. We hold those files until there are no longer any open connections, and then we remove the value from the map.

func New added in v2.24.0

func New(registerer prometheus.Registerer, authz rbac.Authorizer) *Cache

New returns a file cache that will fetch files from a database

func (*Cache) Acquire

func (c *Cache) Acquire(ctx context.Context, db database.Store, fileID uuid.UUID) (*CloseFS, error)

Acquire will load the fs.FS for the given file. It guarantees that parallel calls for the same fileID will only result in one fetch, and that parallel calls for distinct fileIDs will fetch in parallel.

Safety: Every call to Acquire that does not return an error must have a matching call to Release.

func (*Cache) Count added in v2.23.0

func (c *Cache) Count() int

Count returns the number of files currently in the cache. Mainly used for unit testing assertions.

type CacheCloser added in v2.24.0

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

CacheCloser is a cache wrapper used to close all acquired files. This is a more simple interface to use if opening multiple files at once.

func NewCacheCloser added in v2.24.0

func NewCacheCloser(cache FileAcquirer) *CacheCloser

func (*CacheCloser) Acquire added in v2.24.0

func (c *CacheCloser) Acquire(ctx context.Context, db database.Store, fileID uuid.UUID) (*CloseFS, error)

func (*CacheCloser) Close added in v2.24.0

func (c *CacheCloser) Close()

type CacheEntryValue added in v2.24.0

type CacheEntryValue struct {
	fs.FS
	Object rbac.Object
	Size   int64
}

type CloseFS added in v2.24.0

type CloseFS struct {
	fs.FS
	// contains filtered or unexported fields
}

CloseFS is a wrapper around fs.FS that implements io.Closer. The Close() method tells the cache to release the fileID. Once all open references are closed, the file is removed from the cache.

func (*CloseFS) Close added in v2.24.0

func (f *CloseFS) Close()

type FileAcquirer added in v2.24.0

type FileAcquirer interface {
	Acquire(ctx context.Context, db database.Store, fileID uuid.UUID) (*CloseFS, error)
}

type Overlay added in v2.23.0

type Overlay struct {
	Path string
	fs.FS
}

Jump to

Keyboard shortcuts

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