import "go.chromium.org/goma/server/file"
Package file provides goma file service implementation.
cache.go disk.go doc.go key.go service.go value.go
const ( // LargeFileThreshold defines a number of bytes to use FILE_META instead of FILE. LargeFileThreshold = 2 * 1024 * 1024 // FileChunkSize defines a size of each FILE_CHUNK content. FileChunkSize = 2 * 1024 * 1024 )
const ( // DefaultMaxMsgSize is max message size for file service. // file service will handle 2MB chunk * 5 chunks in a request. // grpc's default is 4MB. DefaultMaxMsgSize = 12 * 1024 * 1024 )
func FromLocal(ctx context.Context, fc filepb.FileServiceClient, fname string, blob *gomapb.FileBlob) (os.FileInfo, error)
FromLocal reads fname and fills in blob, and stores it in FileServiceClient.
func FromReader(ctx context.Context, fc filepb.FileServiceClient, r io.Reader, blob *gomapb.FileBlob) error
FromReader reads contents from r and fills in blob, and stores it in FileServiceClient if fc != nil. content size must be blob's FileSize.
IsValid checks blob is valid FileBlob.
Key returns hash key for blob.
func ToLocal(ctx context.Context, fc filepb.FileServiceClient, blob *gomapb.FileBlob, fname string) error
ToLocal writes FileBlob contents in fname. If FileBlob is FILE_META, it will fetch FILE_CHUNK using FileServiceClient.
BlobSpec represents a file by HashKey and/or Blob.
Init initializes BlobSpec from HashKey or Blob. Either HashKey or Blob must be set before initialization.
type Disk struct { Client filepb.FileServiceClient }
Disk provides convenient methods to convert between local file and FileBlob in goma file service.
FromLocal fills spec from fname.
ToLocal creates file named fname from spec.
type LocalCache struct { // Client is goma file service client. // If it is nil, it only uses local disk cache. Client filepb.FileServiceClient // Dir is a directory for local disk cache. Dir string }
LocalCache is a goma file service with local disk cache.
func (c LocalCache) LookupFile(ctx context.Context, req *gomapb.LookupFileReq, opts ...grpc.CallOption) (*gomapb.LookupFileResp, error)
LookupFile looks up FileBlob for requested hash keys. It it is found in local disk cache, it will be used. Otherwise and c.Client is not nil, ask c.Client.
func (c LocalCache) StoreFile(ctx context.Context, req *gomapb.StoreFileReq, opts ...grpc.CallOption) (*gomapb.StoreFileResp, error)
StoreFile stores FileBlob in local disk, and c.Client if c.Client is not nil.
type Service struct { // Cache is a fileblob storage. Cache cachepb.CacheServiceClient }
Service represents goma file service.
func (s *Service) LookupFile(ctx context.Context, req *gomapb.LookupFileReq) (*gomapb.LookupFileResp, error)
LookupFile looks up FileBlob.
func (s *Service) StoreFile(ctx context.Context, req *gomapb.StoreFileReq) (*gomapb.StoreFileResp, error)
StoreFile stores FileBlob.
Package file imports 20 packages (graph) and is imported by 5 packages. Updated 2020-10-27. Refresh now. Tools for package owners.