blobstore

package
v0.0.0-...-75ddc91 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2023 License: BSD-3-Clause Imports: 20 Imported by: 0

Documentation

Overview

Package cas implements the REAPI ContentAddressableStorage and ByteStream services.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LimitReadCloser

func LimitReadCloser(r io.ReadCloser, limit int64) io.ReadCloser

LimitReadCloser wraps an io.LimitedReader in a LimitedReadCloser.

func Register

func Register(s *grpc.Server, cas *ContentAddressableStorage, dataDir string) error

Register creates and registers a new Service with the given gRPC server. The dataDir is created if it does not exist.

Types

type ContentAddressableStorage

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

ContentAddressableStorage is a simple CAS implementation that stores files on the local disk.

func New

func New(dataDir string) (*ContentAddressableStorage, error)

New creates a new local CAS. The data directory is created if it does not exist.

func (*ContentAddressableStorage) Adopt

Adopt moves a file from the given path into the CAS. The digest is assumed to have been validated by the caller.

func (*ContentAddressableStorage) Get

Get reads a file for the given digest from disk and returns its contents.

func (*ContentAddressableStorage) LinkTo

func (c *ContentAddressableStorage) LinkTo(d digest.Digest, path string) error

LinkTo creates a link `path` pointing to the file with digest `d` in the CAS. If the operating system supports cloning files via copy-on-write semantics, the file is cloned instead of hard linked.

func (*ContentAddressableStorage) Open

func (c *ContentAddressableStorage) Open(d digest.Digest, offset int64, limit int64) (io.ReadCloser, error)

Open returns an io.ReadCloser for the requested digest if it exists. The returned ReadCloser is limited to the given offset and limit. The offset must be non-negative and no larger than the file size. A limit of 0 means no limit, and a limit that's larger than the file size is truncated to the file size.

func (*ContentAddressableStorage) Put

func (c *ContentAddressableStorage) Put(data []byte) (digest.Digest, error)

Put stores the given data in the CAS and returns its digest.

func (*ContentAddressableStorage) Stat

Stat returns os.FileInfo for the requested digest if it exists.

type LimitedReadCloser

type LimitedReadCloser struct {
	*io.LimitedReader
	io.Closer
}

LimitedReadCloser is an io.ReadCloser that limits the number of bytes that can be read.

type Service

type Service struct {
	remote.UnimplementedContentAddressableStorageServer
	bytestream.UnimplementedByteStreamServer
	// contains filtered or unexported fields
}

Service implements the REAPI ContentAddressableStorage and ByteStream services.

func NewService

func NewService(cas *ContentAddressableStorage, uploadDir string) (*Service, error)

NewService creates a new Service.

func (*Service) BatchReadBlobs

func (*Service) BatchUpdateBlobs

BatchUpdateBlobs implements the ContentAddressableStorage.BatchUpdateBlobs RPC.

func (*Service) FindMissingBlobs

FindMissingBlobs implements the ContentAddressableStorage.FindMissingBlobs RPC.

func (*Service) GetTree

func (*Service) QueryWriteStatus

QueryWriteStatus implements the ByteStream.QueryWriteStatus RPC.

func (*Service) Read

Read implements the ByteStream.Read RPC.

func (*Service) Write

Write implements the ByteStream.Write RPC.

Jump to

Keyboard shortcuts

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