Documentation
¶
Overview ¶
Package persistence handles taking content from the temp store and storing it in the persistence store.
Index ¶
- Constants
- func FileDirFromDSN(blobDriverURL string) (string, bool)
- func MoveAllFiles(from, to *blob.Bucket) error
- func Open(blobDriverURL string) (*blob.Bucket, error)
- func SweepStaleTempFiles(ctx context.Context, blobDriverURL string, minAge time.Duration, dryRun bool, ...) (int, int, error)
- type Prefix
Constants ¶
const ( AWS_ACCESS_KEY_ID = "AWS_ACCESS_KEY_ID" AWS_SECRET_ACCESS_KEY = "AWS_SECRET_ACCESS_KEY" AWS_REGION = "AWS_REGION" GOOGLE_APPLICATION_CREDENTIALS = "GOOGLE_APPLICATION_CREDENTIALS" AZURE_STORAGE_ACCOUNT = "AZURE_STORAGE_ACCOUNT" AZURE_STORAGE_KEY = "AZURE_STORAGE_KEY" )
const DefaultStaleTempFileAge = time.Hour
DefaultStaleTempFileAge is how old a fileblob ".tmp" file must be before the sweeper will delete it.
fileblob writes to "<path>.<nanos>.tmp" and renames on a successful Close, so a surviving ".tmp" is an interrupted write — but a write *in progress* looks identical by name. mtime advances as bytes are written, and outbound peer requests are capped at 3 minutes by peerHTTPClient, so an hour is a wide margin against deleting a live write. The cost of guessing too high is only that an orphan survives until the next sweep.
Variables ¶
This section is empty.
Functions ¶
func FileDirFromDSN ¶ added in v1.9.0
FileDirFromDSN returns the filesystem directory backing a file:// blob DSN, stripping any query parameters (e.g. "?no_tmp_dir=true"). It reports false for cloud backends, which have no local tree to sweep.
func MoveAllFiles ¶
func Open ¶
New creates a struct that listens to streamToStoreFrom and downloads content from the temp store to the persistent store.
func SweepStaleTempFiles ¶ added in v1.9.0
func SweepStaleTempFiles(ctx context.Context, blobDriverURL string, minAge time.Duration, dryRun bool, onProgress func(scanned, matched int)) (int, int, error)
SweepStaleTempFiles removes orphaned ".tmp" files left behind by the fileblob driver when a write is interrupted before Close renames it into place. See https://github.com/google/go-cloud/issues/3286 for the original issue and https://github.com/google/go-cloud/issues/3294 for why it isn't truly fixed.
Only files last modified more than minAge ago are removed, so the sweep is safe to run concurrently with live writes. Cloud backends are a no-op.
With dryRun set nothing is deleted and the return value is the number of files that *would* have been -- the prune job defaults to that, so an operator can see the cost before authorising it.
Returns a count that is meaningful even alongside an error, since the walk continues past unreadable entries.