stash

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2017 License: Apache-2.0 Imports: 22 Imported by: 22

Documentation

Overview

Package stash provides the defenition of a service that stores immutable blobs of data keyed by id, and the client helpers for dealing with that service.

Index

Constants

View Source
const (
	Unknown   = Status_Unknown
	Uploading = Status_Uploading
	Present   = Status_Present

	ErrEntityNotFound = fault.Const("Entity not found")
)

Variables

This section is empty.

Functions

func RegisterHandler

func RegisterHandler(scheme string, builder Builder)

ReigsterHandler adds a new scheme handler to the factory.

Types

type Builder

type Builder func(context.Context, *url.URL) (*Client, error)

Builder is the function type that opens a stash from a url.

type Client

type Client struct {
	Service
}

Client is a wrapper over a Service to provice extended client functionality.

func Dial

func Dial(ctx context.Context, location *url.URL) (*Client, error)

Dial returns a new client for the given url.

func (*Client) GetFile

func (c *Client) GetFile(ctx context.Context, id string, filename file.Path) error

GetFile retrieves the data for an entity in the given Store and saves it to a file.

func (*Client) UploadBytes

func (c *Client) UploadBytes(ctx context.Context, info Upload, data []byte) (string, error)

UploadBytes is a helper used to upload a byte array. It will return an error if the upload fails, otherwise it will return the stash id for the file.

func (*Client) UploadFile

func (c *Client) UploadFile(ctx context.Context, filename file.Path) (string, error)

UploadFile is a helper used to upload a single file to the stash. It will return an error if either the file cannot be read, or the upload fails, otherwise it will return the stash id for the file.

func (*Client) UploadSeekable

func (c *Client) UploadSeekable(ctx context.Context, info Upload, r io.ReadSeeker) (string, error)

UploadSeekable is a helper used to upload a single seekable stream. It will return an error if either the stream cannot be read, or the upload fails, otherwise it will return the stash id for the file.

func (*Client) UploadStream

func (c *Client) UploadStream(ctx context.Context, info Upload, r Uploadable) (string, error)

UploadStream is a helper used to upload a stream to the stash. It will return an error if the upload fails, otherwise it will return the stash id for the bytes.

func (*Client) UploadString

func (c *Client) UploadString(ctx context.Context, info Upload, content string) (string, error)

UploadString is a helper used to upload a string. It will return an error if the upload fails, otherwise it will return the stash id for the file.

type EntityHandler

type EntityHandler func(context.Context, *Entity) error

EntityHandler is a fuction that can be invoked for each entry in a stream of entities.

type Service

type Service interface {
	// Close can be called to shut down the store.
	// Behaviour of any other method after close is called is undefined.
	Close()
	// Lookup returns information about a single entity by id from the store.
	Lookup(ctx context.Context, id string) (*Entity, error)
	// Search returns a channel of matching entities from the store.
	// The handler will be invoked once per matching entry.
	// If the handler returns an error, the search will be terminated.
	Search(ctx context.Context, query *search.Query, handler EntityHandler) error
	// Open returns a reader to an entity's data.
	// The reader may be nil if the entity is not present.
	Open(ctx context.Context, id string) (io.ReadSeeker, error)
	// Read returns a complete entity from the store.
	// It may return an empty byte array if the entity is not present.
	Read(ctx context.Context, id string) ([]byte, error)
	// Create is used to add a new entity to the store.
	// It returns a writer that can be used to write the content of the entity.
	Create(ctx context.Context, info *Upload) (io.WriteCloser, error)
}

Service is the interface to a stash storage implementation. It abstracts away the actual storage part from the service logic.

type Uploadable

type Uploadable interface {
	io.Reader
	Reset() error
}

Uploadable is the interface used by the UploadStream helper. It is a standard io reader with the ability to reset to the start.

Directories

Path Synopsis
Package grpc provides the client and server support for communicating with a remote stash using grpc.
Package grpc provides the client and server support for communicating with a remote stash using grpc.
Package local provides implementations of a stash.Service for local storage.
Package local provides implementations of a stash.Service for local storage.

Jump to

Keyboard shortcuts

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