Documentation ¶
Overview ¶
The storage package implements a simple distributed blob store.
It's a very simple blob store that expects hex-encoded keys and uses the filesystem as the backend. It implements the PartitionedService interface.
It offers a simple HTTP API (with HMAC authentication using a shared secret), which supports PUT and GET operations on keys. Read operations actually support the full feature set of Go's http.FileServer, including caching headers and ranged requests. These are not exposed in the DistributedStorageClient API, but are rather meant for directly proxying the blob store to clients.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewAuthKeyFromConfig ¶
func NewPartitionMapFromConfig ¶
func NewPartitionMapFromConfig() *partition.PartitionMap
func RegisterService ¶
func RegisterService(ss *StorageService)
func Write ¶
func Write(ss *StorageService, w http.ResponseWriter, req *http.Request)
Types ¶
type DistributedStorageClient ¶
type DistributedStorageClient struct { // The partition map. P *partition.PartitionMap // contains filtered or unexported fields }
func NewDistributedStorageClient ¶
func NewDistributedStorageClient(pmap *partition.PartitionMap, authKey *api.AuthKey) *DistributedStorageClient
func NewDistributedStorageClientFromConfig ¶
func NewDistributedStorageClientFromConfig() *DistributedStorageClient
func (*DistributedStorageClient) GetUrl ¶
func (c *DistributedStorageClient) GetUrl(key, mode string) string
GetUrl returns the URL where a blob can be accessed.
func (*DistributedStorageClient) Open ¶
func (c *DistributedStorageClient) Open(key string) (io.ReadCloser, error)
Open returns a ReadCloser object that yields blob data.
func (*DistributedStorageClient) ReverseProxyDirector ¶
func (c *DistributedStorageClient) ReverseProxyDirector() func(string, *http.Request)
ReverseProxyDirector gives you a function to be used as the director of an httputil.ReverseProxy (providing authenticated access to the read-only tree).
type FileSystemStorage ¶
The filesystem-based storage backend, implemented using directory hashing of the key.
func NewFileSystemStorage ¶
func NewFileSystemStorage(root string, hashDepth int) *FileSystemStorage
func (*FileSystemStorage) Delete ¶
func (fs *FileSystemStorage) Delete(key string)
Delete removes a file from the local filesystem.
func (*FileSystemStorage) Open ¶
func (fs *FileSystemStorage) Open(key string) (*os.File, error)
Open returns a ReadCloser pointing at the file contents.
func (*FileSystemStorage) Scan ¶
func (fs *FileSystemStorage) Scan(out chan string) error
Scan the local filesystem for files and write keys to a channel.
type StorageService ¶
type StorageService struct { partition.PartitionedServiceBase // Authentication credentials. AuthKey *api.AuthKey // The backend filesystem-based storage. Fs *FileSystemStorage // Client interface for rebalancing. Client *DistributedStorageClient // contains filtered or unexported fields }
func NewStorageService ¶
func NewStorageService(fsRoot string, authKey *api.AuthKey, pmap *partition.PartitionMap, selfTarget string) *StorageService
func (*StorageService) HandlerFunc ¶
func (ss *StorageService) HandlerFunc(f func(*StorageService, http.ResponseWriter, *http.Request)) http.HandlerFunc
func (*StorageService) Move ¶
func (ss *StorageService) Move(key string) error
func (*StorageService) Open ¶
func (ss *StorageService) Open(name string) (http.File, error)
Open implements the http.FileSystem interface.
func (*StorageService) Scan ¶
func (ss *StorageService) Scan() <-chan string