Documentation ¶
Index ¶
Constants ¶
const MB = 1 << 20
MB is 1 Megabyte. (Silly comment to make the lint warning go away)
const MtimeMetadataKey = "gcsfuse_mtime"
MtimeMetadataKey objects are created by Syncer.SyncObject and contain a metadata field with this key and with a UTC mtime in the format defined by time.RFC3339Nano.
const ReadOp = "readOp"
"readOp" is the value used in read context to store pointer to the read operation.
Variables ¶
This section is empty.
Functions ¶
func NewContentTypeBucket ¶
NewContentTypeBucket creates a wrapper bucket that guesses MIME types for newly created or composed objects when an explicit type is not already set.
func NewPrefixBucket ¶
NewPrefixBucket creates a view on the wrapped bucket that pretends as if only the objects whose names contain the supplied string as a strict prefix exist, and that strips the prefix from the names of those objects before exposing them.
In order to preserve the invariant that object names are valid UTF-8, prefix must be valid UTF-8.
Types ¶
type BucketConfig ¶
type BucketConfig struct { BillingProject string OnlyDir string EgressBandwidthLimitBytesPerSecond float64 OpRateLimitHz float64 StatCacheMaxSizeMB uint64 StatCacheTTL time.Duration EnableMonitoring bool DebugGCS bool // Files backed by on object of length at least AppendThreshold that have // only been appended to (i.e. none of the object's contents have been // dirtied) will be written out by "appending" to the object in GCS with this // process: // // 1. Write out a temporary object containing the appended contents whose // name begins with TmpObjectPrefix. // // 2. Compose the original object and the temporary object on top of the // original object. // // 3. Delete the temporary object. // // Note that if the process fails or is interrupted the temporary object will // not be cleaned up, so the user must ensure that TmpObjectPrefix is // periodically garbage collected. AppendThreshold int64 TmpObjectPrefix string }
type BucketManager ¶
type BucketManager interface { SetUpBucket( ctx context.Context, name string, isMultibucketMount bool) (b SyncerBucket, err error) // Shuts down the bucket manager and its buckets ShutDown() }
BucketManager manages the lifecycle of buckets.
func NewBucketManager ¶
func NewBucketManager(config BucketConfig, storageHandle storage.StorageHandle) BucketManager
type RandomReader ¶
type RandomReader interface { // Panic if any internal invariants are violated. CheckInvariants() // ReadAt Matches the semantics of io.ReaderAt, with the addition of context // support and cache support. It returns a boolean which represent either // content is read from fileCache (cacheHit = true) or gcs (cacheHit = false) ReadAt(ctx context.Context, p []byte, offset int64) (n int, cacheHit bool, err error) // Return the record for the object to which the reader is bound. Object() (o *gcs.MinObject) // Clean up any resources associated with the reader, which must not be used // again. Destroy() }
RandomReader is an object that knows how to read ranges within a particular generation of a particular GCS object. Optimised for (large) sequential reads.
Not safe for concurrent access.
TODO - (raj-prince) - Rename this with appropriate name as it also started fulfilling the responsibility of reading object's content from cache.
func NewRandomReader ¶
func NewRandomReader(o *gcs.MinObject, bucket gcs.Bucket, sequentialReadSizeMb int32, fileCacheHandler *file.CacheHandler, cacheFileForRangeRead bool) RandomReader
NewRandomReader create a random reader for the supplied object record that reads using the given bucket.
type StatResult ¶
type StatResult struct { // The current size in bytes of the content. Size int64 // The largest value T such that we are sure that the range of bytes [0, T) // is unmodified from the original content with which the temp file was // created. DirtyThreshold int64 // The mtime of the temp file is updated according to the temp file's clock // with each call to a method that modified its content, and is also updated // when the user explicitly calls SetMtime. // // If neither of those things has ever happened, it is nil. This implies that // DirtyThreshold == Size. Mtime *time.Time }
StatResult stores the result of a stat operation.
type Syncer ¶
type Syncer interface { // Given an object record and content that was originally derived from that // object's contents (and potentially modified): // // * If the temp file has not been modified, return a nil new object. // // * Otherwise, write out a new generation in the bucket (failing with // *gcs.PreconditionError if the source generation is no longer current). SyncObject( ctx context.Context, fileName string, srcObject *gcs.Object, content TempFile) (o *gcs.Object, err error) }
Syncer is safe for concurrent access.
func NewSyncer ¶
NewSyncer creates a syncer that syncs into the supplied bucket.
When the source object has been changed only by appending, and the source object's size is at least appendThreshold, we will "append" to it by writing out a temporary blob and composing it with the source object.
Temporary blobs have names beginning with tmpObjectPrefix. We make an effort to delete them, but if we are interrupted for some reason we may not be able to do so. Therefore the user should arrange for garbage collection.
type SyncerBucket ¶
func NewSyncerBucket ¶
func NewSyncerBucket( appendThreshold int64, tmpObjectPrefix string, bucket gcs.Bucket, ) SyncerBucket
NewSyncerBucket creates a SyncerBucket, which can be used either as a gcs.Bucket, or as a Syncer.
type TempFile ¶
type TempFile interface { // Panic if any internal invariants are violated. CheckInvariants() // Semantics matching os.File. io.ReadSeeker io.ReaderAt io.WriterAt Truncate(n int64) (err error) // Retrieve the file name Name() string // Return information about the current state of the content. May invalidate // the seek position. Stat() (sr StatResult, err error) // Explicitly set the mtime that will return in stat results. This will stick // until another method that modifies the file is called. SetMtime(mtime time.Time) // Throw away the resources used by the temporary file. The object must not // be used again. Destroy() }
TempFile is a temporary file that keeps track of the lowest offset at which it has been modified.
Not safe for concurrent access.
func NewCacheFile ¶
func NewCacheFile( source io.ReadCloser, f *os.File, dir string, clock timeutil.Clock) (tf TempFile)
NewCacheFile creates a wrapper temp file whose initial contents are given by the supplied source. dir is a directory on whose file system the file will live, or the system default temporary location if empty.
func NewTempFile ¶
NewTempFile creates a temp file whose initial contents are given by the supplied reader. dir is a directory on whose file system the inode will live, or the system default temporary location if empty.