perkeep/pkg/blobserver/noimpl.go

55 lines
1.6 KiB
Go
Raw Normal View History

/*
Copyright 2011 The Perkeep Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package blobserver
import (
"context"
"errors"
"io"
"os"
"perkeep.org/pkg/blob"
)
// NoImplStorage is an implementation of Storage that returns a not
// implemented error for all operations.
type NoImplStorage struct{}
var _ Storage = NoImplStorage{}
func (NoImplStorage) Fetch(context.Context, blob.Ref) (file io.ReadCloser, size uint32, err error) {
return nil, 0, os.ErrNotExist
}
func (NoImplStorage) ReceiveBlob(context.Context, blob.Ref, io.Reader) (sb blob.SizedRef, err error) {
err = errors.New("ReceiveBlob not implemented")
return
}
func (NoImplStorage) StatBlobs(ctx context.Context, blobs []blob.Ref, fn func(blob.SizedRef) error) error {
return errors.New("Stat not implemented")
}
func (NoImplStorage) EnumerateBlobs(ctx context.Context, dest chan<- blob.SizedRef, after string, limit int) error {
improve proxycache and stats blobservers improving proxycache - added fuller sample config to the package documentation - switched the stats caching from sorted.kv to the stats blobserver - added a cleaning mechanism to evict the least recently used blobs - implemented StatBlobs to actually inspect the local cache. It still always consults the origin, but only for the blobs necessary after giving the cache a 50ms headstart. - logging a few errors that were previously ignored - added tests modeled after the tests for the localdisk blobstore - added a method to verify the cache, and call it on initialization - added a strictStats option to always get stats from the origin - filling in cacheBytes on initialization improving stats blobserver - implemented a few more of the blobserver interfaces, Enumerator and Remover - Fixed a bug(?) in ReceiveBlob that seemed to prevent it from actually storing stats - added a test minor improvements include: - blobserver/memory: allowing the memory blobserver to hold actually infinite items, if desired - blobserver: closing dest in the NoImpl blobserver, as required by the BlobEnumerator interface - storagetest: not closing dest leads to deadlock - lru: max entries of 0 now means infinite (maybe do anything <0?) - test: a helper function to create a random blob using a global random source that is, by default, deterministic, to make test results more consistent. In the future, an improved BlobHub or similar interface could allow a tighter feedback loop in providing cache consistency. i.e. the cache could register with backend stores to be notified of content updates, minimizing the time between backend changes and cache correction. The proxycache will verify itself at startup, reporting an error if any of its blobs do not exist in the backend storage or if the backend storage has a different size for the content than the cache. Fixes #443 Change-Id: I9ee1efd8c1d0eed49bb82930c2489a64122d3e00
2016-12-05 06:27:52 +00:00
close(dest)
return errors.New("EnumerateBlobs not implemented")
}
func (NoImplStorage) RemoveBlobs(ctx context.Context, blobs []blob.Ref) error {
return errors.New("Remove not implemented")
}