server: go.chromium.org/goma/server/file Index | Files

package file

import "go.chromium.org/goma/server/file"

Package file provides goma file service implementation.

Index

Package Files

cache.go disk.go doc.go key.go service.go value.go

Constants

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 Uses

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 Uses

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.

func IsValid Uses

func IsValid(blob *gomapb.FileBlob) bool

IsValid checks blob is valid FileBlob.

func Key Uses

func Key(blob *gomapb.FileBlob) (string, error)

Key returns hash key for blob.

func ToLocal Uses

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.

type BlobSpec Uses

type BlobSpec struct {
    HashKey      string
    Blob         *gomapb.FileBlob
    IsExecutable bool
}

BlobSpec represents a file by HashKey and/or Blob.

func (*BlobSpec) Init Uses

func (b *BlobSpec) Init(ctx context.Context, client filepb.FileServiceClient) error

Init initializes BlobSpec from HashKey or Blob. Either HashKey or Blob must be set before initialization.

type Disk Uses

type Disk struct {
    Client filepb.FileServiceClient
}

Disk provides convenient methods to convert between local file and FileBlob in goma file service.

func (Disk) FromLocal Uses

func (d Disk) FromLocal(ctx context.Context, fname string, spec *BlobSpec) error

FromLocal fills spec from fname.

func (Disk) ToLocal Uses

func (d Disk) ToLocal(ctx context.Context, spec *BlobSpec, fname string) error

ToLocal creates file named fname from spec.

type LocalCache Uses

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 Uses

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 Uses

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 Uses

type Service struct {
    // Cache is a fileblob storage.
    Cache cachepb.CacheServiceClient
}

Service represents goma file service.

func (*Service) LookupFile Uses

func (s *Service) LookupFile(ctx context.Context, req *gomapb.LookupFileReq) (*gomapb.LookupFileResp, error)

LookupFile looks up FileBlob.

func (*Service) StoreFile Uses

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 3 packages. Updated 2019-09-21. Refresh now. Tools for package owners.