Documentation ¶
Overview ¶
Package cas implements the REAPI ContentAddressableStorage and ByteStream services.
Index ¶
- func LimitReadCloser(r io.ReadCloser, limit int64) io.ReadCloser
- func Register(s *grpc.Server, cas *ContentAddressableStorage, dataDir string) error
- type ContentAddressableStorage
- func (c *ContentAddressableStorage) Adopt(d digest.Digest, path string) error
- func (c *ContentAddressableStorage) Get(d digest.Digest) ([]byte, error)
- func (c *ContentAddressableStorage) LinkTo(d digest.Digest, path string) error
- func (c *ContentAddressableStorage) Open(d digest.Digest, offset int64, limit int64) (io.ReadCloser, error)
- func (c *ContentAddressableStorage) Put(data []byte) (digest.Digest, error)
- func (c *ContentAddressableStorage) Stat(d digest.Digest) (os.FileInfo, error)
- type LimitedReadCloser
- type Service
- func (s *Service) BatchReadBlobs(ctx context.Context, request *remote.BatchReadBlobsRequest) (*remote.BatchReadBlobsResponse, error)
- func (s *Service) BatchUpdateBlobs(ctx context.Context, request *remote.BatchUpdateBlobsRequest) (*remote.BatchUpdateBlobsResponse, error)
- func (s *Service) FindMissingBlobs(ctx context.Context, request *remote.FindMissingBlobsRequest) (*remote.FindMissingBlobsResponse, error)
- func (s *Service) GetTree(request *remote.GetTreeRequest, ...) error
- func (s *Service) QueryWriteStatus(ctx context.Context, request *bytestream.QueryWriteStatusRequest) (*bytestream.QueryWriteStatusResponse, error)
- func (s *Service) Read(request *bytestream.ReadRequest, server bytestream.ByteStream_ReadServer) error
- func (s *Service) Write(server bytestream.ByteStream_WriteServer) error
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.
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 ¶
func (c *ContentAddressableStorage) Adopt(d digest.Digest, path string) error
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 ¶
func (c *ContentAddressableStorage) Get(d digest.Digest) ([]byte, error)
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.
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 (s *Service) BatchReadBlobs(ctx context.Context, request *remote.BatchReadBlobsRequest) (*remote.BatchReadBlobsResponse, error)
func (*Service) BatchUpdateBlobs ¶
func (s *Service) BatchUpdateBlobs(ctx context.Context, request *remote.BatchUpdateBlobsRequest) (*remote.BatchUpdateBlobsResponse, error)
BatchUpdateBlobs implements the ContentAddressableStorage.BatchUpdateBlobs RPC.
func (*Service) FindMissingBlobs ¶
func (s *Service) FindMissingBlobs(ctx context.Context, request *remote.FindMissingBlobsRequest) (*remote.FindMissingBlobsResponse, error)
FindMissingBlobs implements the ContentAddressableStorage.FindMissingBlobs RPC.
func (*Service) GetTree ¶
func (s *Service) GetTree(request *remote.GetTreeRequest, treeServer remote.ContentAddressableStorage_GetTreeServer) error
func (*Service) QueryWriteStatus ¶
func (s *Service) QueryWriteStatus(ctx context.Context, request *bytestream.QueryWriteStatusRequest) (*bytestream.QueryWriteStatusResponse, error)
QueryWriteStatus implements the ByteStream.QueryWriteStatus RPC.
func (*Service) Read ¶
func (s *Service) Read(request *bytestream.ReadRequest, server bytestream.ByteStream_ReadServer) error
Read implements the ByteStream.Read RPC.
func (*Service) Write ¶
func (s *Service) Write(server bytestream.ByteStream_WriteServer) error
Write implements the ByteStream.Write RPC.