fs

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2021 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Set is used by wire.

Functions

This section is empty.

Types

type File

type File struct {
	*FileMeta
	*blob.Blob
}

A File associates an open Blob with additional metadata.

func (*File) IsDir

func (f *File) IsDir() bool

IsDir implements fs.FileInfo.

func (*File) ModTime

func (f *File) ModTime() time.Time

ModTime implements fs.FileInfo.

func (*File) Mode

func (f *File) Mode() fs.FileMode

Mode implements fs.FileInfo.

func (*File) Name

func (f *File) Name() string

Name implements fs.FileInfo and returns the file's path.

func (*File) Size

func (f *File) Size() int64

Size implements fs.FileInfo.

func (*File) Stat

func (f *File) Stat() (fs.FileInfo, error)

Stat implements fs.FileInfo.

func (*File) String

func (f *File) String() string

func (*File) Sys

func (f *File) Sys() interface{}

Sys implements fs.FileInfo.

type FileMeta

type FileMeta struct {
	CTime, MTime time.Time
	Meta         map[string]string
	Path         string
	Tenant       *tenant.ID
	Version      int64
}

FileMeta describes file-like data other than the file's size.

type FileSystem

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

FileSystem provides multi-tenant access to named files.

func (*FileSystem) Delete

func (f *FileSystem) Delete(ctx context.Context, name string) error

Delete ensures that no file exists with the given name.

func (*FileSystem) Open

func (f *FileSystem) Open(name string) (fs.File, error)

Open implements fs.FS and simply wraps OpenVersion. If there is no file with that path, Open will look instead to see if there are any files with that path prefix. If so, it will return a File that represents a directory listing.

func (*FileSystem) OpenVersion

func (f *FileSystem) OpenVersion(ctx context.Context, name string, version int64) (*File, error)

OpenVersion returns an open handle to the named file. If version <= 0, the latest version of the file will be returned.

func (*FileSystem) Put

func (f *FileSystem) Put(ctx context.Context, meta *FileMeta, hash blob.Hash) error

Put creates or updates a file that is associated with the given content hash. The FileMeta will be updated by this call.

func (*FileSystem) ReadDir

func (f *FileSystem) ReadDir(name string) ([]fs.DirEntry, error)

ReadDir implements fs.ReadDirFS.

func (*FileSystem) Stat

func (f *FileSystem) Stat(name string) (fs.FileInfo, error)

Stat implements fs.StatFS.

func (*FileSystem) Tenant

func (f *FileSystem) Tenant() *tenant.ID

Tenant returns the tenant associated with the FileSystem.

type Server

type Server struct {
	Config *config.Config
	DB     *pgxpool.Pool
	FS     *Store

	file.UnsafeFilesServer `wire:"-"`
	// contains filtered or unexported fields
}

Server implements the file.FilesServer interface.

func (*Server) Delete

func (s *Server) Delete(ctx context.Context, req *file.DeleteRequest) (*emptypb.Empty, error)

Delete implements file.FilesServer.

func (*Server) List

func (s *Server) List(ctx context.Context, req *file.ListRequest) (*file.ListResponse, error)

List implements file.FilesServer.

func (*Server) Retrieve

func (s *Server) Retrieve(
	ctx context.Context, req *file.RetrievalRequest,
) (*file.RetrievalResponse, error)

Retrieve implements file.FilesServer.

type Store

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

Store is a factory for FileSystem instances.

func ProvideStore

func ProvideStore(
	ctx context.Context,
	blobs *blob.Store,
	config *config.Config,
	db *pgxpool.Pool,
	logger *log.Logger,
) (*Store, func(), error)

ProvideStore is called by wire.

func (*Store) FileSystem

func (s *Store) FileSystem(tenant *tenant.ID) *FileSystem

FileSystem returns a filesystem abstraction around the store.

Jump to

Keyboard shortcuts

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