Documentation ¶
Overview ¶
Package file provides goma file service implementation.
Index ¶
- Constants
- func FromLocal(ctx context.Context, fc filepb.FileServiceClient, fname string, ...) (os.FileInfo, error)
- func FromReader(ctx context.Context, fc filepb.FileServiceClient, r io.Reader, ...) error
- func IsValid(blob *gomapb.FileBlob) bool
- func Key(blob *gomapb.FileBlob) (string, error)
- func ToLocal(ctx context.Context, fc filepb.FileServiceClient, blob *gomapb.FileBlob, ...) error
- type BlobSpec
- type Disk
- type LocalCache
- type Service
Constants ¶
View Source
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 )
View Source
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 )
Variables ¶
This section is empty.
Functions ¶
func FromLocal ¶
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.
Types ¶
type Disk ¶
type Disk struct {
Client filepb.FileServiceClient
}
Disk provides convenient methods to convert between local file and FileBlob in goma file service.
type LocalCache ¶
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 (LocalCache) LookupFile ¶
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 (LocalCache) StoreFile ¶
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 ¶
type Service struct { filepb.UnimplementedFileServiceServer // Cache is a fileblob storage. Cache cachepb.CacheServiceClient }
Service represents goma file service.
func (*Service) LookupFile ¶
func (s *Service) LookupFile(ctx context.Context, req *gomapb.LookupFileReq) (*gomapb.LookupFileResp, error)
LookupFile looks up FileBlob.
func (*Service) StoreFile ¶
func (s *Service) StoreFile(ctx context.Context, req *gomapb.StoreFileReq) (*gomapb.StoreFileResp, error)
StoreFile stores FileBlob.
Click to show internal directories.
Click to hide internal directories.