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
- func RegisterHandler(scheme string, builder Builder)
- type Builder
- type Client
- func (c *Client) GetFile(ctx context.Context, id string, filename file.Path) error
- func (c *Client) UploadBytes(ctx context.Context, info Upload, data []byte) (string, error)
- func (c *Client) UploadFile(ctx context.Context, filename file.Path) (string, error)
- func (c *Client) UploadSeekable(ctx context.Context, info Upload, r io.ReadSeeker) (string, error)
- func (c *Client) UploadStream(ctx context.Context, info Upload, r Uploadable) (string, error)
- func (c *Client) UploadString(ctx context.Context, info Upload, content string) (string, error)
- type EntityHandler
- type Service
- type Uploadable
Constants ¶
const ( Unknown = Status_Unknown Uploading = Status_Uploading Present = Status_Present ErrEntityNotFound = fault.Const("Entity not found") )
Variables ¶
This section is empty.
Functions ¶
func RegisterHandler ¶
ReigsterHandler adds a new scheme handler to the factory.
Types ¶
type Client ¶
type Client struct {
Service
}
Client is a wrapper over a Service to provice extended client functionality.
func (*Client) GetFile ¶
GetFile retrieves the data for an entity in the given Store and saves it to a file.
func (*Client) UploadBytes ¶
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 ¶
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 ¶
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 ¶
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.
type EntityHandler ¶
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 ¶
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. |