From 59e577c0230cdf3b807446322022f0ef64d63297 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Sat, 4 Jun 2011 08:56:03 -0700 Subject: [PATCH] Rename blobref.Fetcher to blobref.SeekFetcher --- clients/go/cammount/cacher.go | 2 +- clients/go/cammount/fs.go | 4 ++-- lib/go/camli/blobref/fetcher.go | 11 +++++------ lib/go/camli/blobserver/interface.go | 2 +- lib/go/camli/client/config.go | 2 +- lib/go/camli/jsonsign/sign.go | 2 +- lib/go/camli/schema/filereader.go | 6 +++--- server/go/camlistored/ui.go | 2 +- 8 files changed, 15 insertions(+), 16 deletions(-) diff --git a/clients/go/cammount/cacher.go b/clients/go/cammount/cacher.go index 434481dd5..954abf19b 100644 --- a/clients/go/cammount/cacher.go +++ b/clients/go/cammount/cacher.go @@ -23,7 +23,7 @@ import ( "os" ) -func NewCachingFetcher(cacheTarget blobserver.Cache, sfetcher blobref.StreamingFetcher) blobref.Fetcher { +func NewCachingFetcher(cacheTarget blobserver.Cache, sfetcher blobref.StreamingFetcher) blobref.SeekFetcher { return &CachingFetcher{cacheTarget, sfetcher} } diff --git a/clients/go/cammount/fs.go b/clients/go/cammount/fs.go index 15aa891b4..799ebe153 100644 --- a/clients/go/cammount/fs.go +++ b/clients/go/cammount/fs.go @@ -38,7 +38,7 @@ var _ = log.Println type CamliFileSystem struct { fuse.DefaultPathFilesystem - fetcher blobref.Fetcher + fetcher blobref.SeekFetcher root *blobref.BlobRef blobToSchema *lru.Cache // ~map[blobstring]*schema.Superset @@ -46,7 +46,7 @@ type CamliFileSystem struct { nameToAttr *lru.Cache // ~map[string]*fuse.Attr } -func NewCamliFileSystem(fetcher blobref.Fetcher, root *blobref.BlobRef) *CamliFileSystem { +func NewCamliFileSystem(fetcher blobref.SeekFetcher, root *blobref.BlobRef) *CamliFileSystem { return &CamliFileSystem{ fetcher: fetcher, blobToSchema: lru.New(1024), // arbitrary; TODO: tunable/smarter? diff --git a/lib/go/camli/blobref/fetcher.go b/lib/go/camli/blobref/fetcher.go index afc4dfa2e..726eebb5e 100644 --- a/lib/go/camli/blobref/fetcher.go +++ b/lib/go/camli/blobref/fetcher.go @@ -32,13 +32,12 @@ import ( var _ = log.Printf -// TODO: rename StreamingFetcher to be Fetch (the common case) and -// make a new interface for FetchSeeker (the rare case) +// TODO: rename StreamingFetcher to be Fetcher (the common case) // TODO: add FetcherAt / FetchAt (for HTTP range requests). But then how -// to make all FetchSeeker also be a FetchAt? By hand? +// to make all SeekFetcer also be a FetchAt? By hand? -type Fetcher interface { +type SeekFetcher interface { // Fetch returns a blob. If the blob is not found then // os.ENOENT should be returned for the error (not a wrapped // error with a ENOENT inside) @@ -52,7 +51,7 @@ type StreamingFetcher interface { FetchStreaming(*BlobRef) (file io.ReadCloser, size int64, err os.Error) } -func NewSerialFetcher(fetchers ...Fetcher) Fetcher { +func NewSerialFetcher(fetchers ...SeekFetcher) SeekFetcher { return &serialFetcher{fetchers} } @@ -70,7 +69,7 @@ func NewConfigDirFetcher() *DirFetcher { } type serialFetcher struct { - fetchers []Fetcher + fetchers []SeekFetcher } func (sf *serialFetcher) Fetch(b *BlobRef) (file ReadSeekCloser, size int64, err os.Error) { diff --git a/lib/go/camli/blobserver/interface.go b/lib/go/camli/blobserver/interface.go index 2fe7976ca..2d35e705a 100644 --- a/lib/go/camli/blobserver/interface.go +++ b/lib/go/camli/blobserver/interface.go @@ -75,7 +75,7 @@ type BlobEnumerator interface { // Cache is the minimal interface expected of a blob cache. type Cache interface { - blobref.Fetcher + blobref.SeekFetcher // TODO: change this to be just a normal StreamingFetcher BlobReceiver BlobStatter } diff --git a/lib/go/camli/client/config.go b/lib/go/camli/client/config.go index ea22905dc..e78bb6a44 100644 --- a/lib/go/camli/client/config.go +++ b/lib/go/camli/client/config.go @@ -194,7 +194,7 @@ func SignerPublicKeyBlobref() *blobref.BlobRef { return br } -func (c *Client) GetBlobFetcher() blobref.Fetcher { +func (c *Client) GetBlobFetcher() blobref.SeekFetcher { // Use blobref.NewSeriesFetcher(...all configured fetch paths...) return blobref.NewConfigDirFetcher() } diff --git a/lib/go/camli/jsonsign/sign.go b/lib/go/camli/jsonsign/sign.go index b47cfcf22..f4c8f1427 100644 --- a/lib/go/camli/jsonsign/sign.go +++ b/lib/go/camli/jsonsign/sign.go @@ -225,7 +225,7 @@ func (sr *SignRequest) Sign() (signedJson string, err os.Error) { var pubkeyReader io.ReadCloser switch fetcher := sr.Fetcher.(type) { - case blobref.Fetcher: + case blobref.SeekFetcher: pubkeyReader, _, err = fetcher.Fetch(signerBlob) case blobref.StreamingFetcher: pubkeyReader, _, err = fetcher.FetchStreaming(signerBlob) diff --git a/lib/go/camli/schema/filereader.go b/lib/go/camli/schema/filereader.go index 658e83729..30b331aed 100644 --- a/lib/go/camli/schema/filereader.go +++ b/lib/go/camli/schema/filereader.go @@ -28,7 +28,7 @@ import ( var _ = log.Printf type FileReader struct { - fetcher blobref.Fetcher + fetcher blobref.SeekFetcher ss *Superset ci int // index into contentparts ccon uint64 // bytes into current chunk already consumed @@ -38,7 +38,7 @@ type FileReader struct { } // TODO: make this take a blobref.FetcherAt instead? -func NewFileReader(fetcher blobref.Fetcher, fileBlobRef *blobref.BlobRef) (*FileReader, os.Error) { +func NewFileReader(fetcher blobref.SeekFetcher, fileBlobRef *blobref.BlobRef) (*FileReader, os.Error) { ss := new(Superset) rsc, _, err := fetcher.Fetch(fileBlobRef) if err != nil { @@ -53,7 +53,7 @@ func NewFileReader(fetcher blobref.Fetcher, fileBlobRef *blobref.BlobRef) (*File return ss.NewFileReader(fetcher), nil } -func (ss *Superset) NewFileReader(fetcher blobref.Fetcher) *FileReader { +func (ss *Superset) NewFileReader(fetcher blobref.SeekFetcher) *FileReader { // TODO: return an error if ss isn't a Type "file" ? // TODO: return some error if the redundant ss.Size field doesn't match ContentParts? return &FileReader{fetcher: fetcher, ss: ss} diff --git a/server/go/camlistored/ui.go b/server/go/camlistored/ui.go index e7e41ff23..a5a756e59 100644 --- a/server/go/camlistored/ui.go +++ b/server/go/camlistored/ui.go @@ -236,7 +236,7 @@ func (ui *UIHandler) serveDownload(rw http.ResponseWriter, req *http.Request) { return } - fetchSeeker, ok := ui.Storage.(blobref.Fetcher) + fetchSeeker, ok := ui.Storage.(blobref.SeekFetcher) if !ok { // TODO: wrap ui.Storage in disk-caching wrapper so it can seek http.Error(rw, "TODO: configured BlobRoot doesn't support seeking and disk cache wrapping not yet implemented", 500)