storage

package
v0.0.0-...-6217932 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 31, 2016 License: GPL-3.0 Imports: 15 Imported by: 0

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 NewAuthKeyFromConfig() *api.AuthKey

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

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).

func (*DistributedStorageClient) Write

func (c *DistributedStorageClient) Write(key string, r io.Reader) error

Write saves a blob of data to the distributed storage.

type FileSystemStorage

type FileSystemStorage struct {
	Root      string
	HashDepth int
}

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.

func (*FileSystemStorage) Write

func (fs *FileSystemStorage) Write(key string, r io.Reader) error

Write copies data into the filesystem.

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 (*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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL