Documentation ¶
Index ¶
- Constants
- Variables
- type BatchDownloader
- type Client
- type DatasetOpts
- type DatasetRef
- func (d *DatasetRef) AddFile(ctx context.Context, filename string, digest []byte) error
- func (d *DatasetRef) Delete(ctx context.Context) error
- func (d *DatasetRef) DeleteFile(ctx context.Context, filename string) error
- func (d *DatasetRef) DownloadBatch(ctx context.Context, files Iterator) *BatchDownloader
- func (d *DatasetRef) FileInfo(ctx context.Context, filename string) (*api.FileInfo, error)
- func (d *DatasetRef) Files(ctx context.Context, opts *FileIteratorOptions) *FileIterator
- func (d *DatasetRef) Info(ctx context.Context) (*api.Dataset, error)
- func (d *DatasetRef) Name() string
- func (d *DatasetRef) NewDeleteBatch() *DeleteBatch
- func (d *DatasetRef) NewUploadBatch() *UploadBatch
- func (d *DatasetRef) ReadFile(ctx context.Context, filename string) (io.ReadCloser, error)
- func (d *DatasetRef) ReadFileRange(ctx context.Context, filename string, offset, length int64) (io.ReadCloser, error)
- func (d *DatasetRef) Seal(ctx context.Context) error
- func (d *DatasetRef) URL() string
- func (d *DatasetRef) WriteFile(ctx context.Context, filename string, source io.Reader, size int64) error
- type DeleteBatch
- type FileBatch
- type FileIterator
- type FileIteratorOptions
- type Iterator
- type Option
- type TraceResult
- type UploadBatch
Constants ¶
const ClientHostnameHeader = "Client-Hostname"
Variables ¶
var ( // ErrDone indicates an iterator is expended. ErrDone = errors.New("no more items in iterator") // ErrUploaded indicates a file upload is unnecessary as the service already // has the required data. ErrUploaded = errors.New("file is already uploaded") // ErrFileNotFound indicates that a file doesn't exist. ErrFileNotFound = errors.New("file not found") )
Functions ¶
This section is empty.
Types ¶
type BatchDownloader ¶
type BatchDownloader struct {
// contains filtered or unexported fields
}
BatchDownloader is an iterator over file batches.
func (*BatchDownloader) Next ¶
func (d *BatchDownloader) Next() (*FileBatch, error)
Next gets the next batch of files. If the iterator is expended it will return the sentinel error Done.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client provides an API interface to FileHeap.
func New ¶
New creates a new client connected the given address.
Address should be in the form [scheme://]host[:port], where scheme defaults to "https" and port defaults to the standard port for the given scheme, i.e. 80 for http and 443 for https.
func (*Client) Dataset ¶
func (c *Client) Dataset(id string) *DatasetRef
Dataset creates a reference to an existing dataset by ID.
func (*Client) NewDataset ¶
func (c *Client) NewDataset(ctx context.Context) (*DatasetRef, error)
NewDataset creates a new collection of files.
type DatasetOpts ¶
type DatasetOpts struct{}
DatasetOpts allows clients to set options during creation of a new dataset.
type DatasetRef ¶
type DatasetRef struct {
// contains filtered or unexported fields
}
DatasetRef is a reference to a dataset.
Callers should not assume the ref is valid.
func (*DatasetRef) Delete ¶
func (d *DatasetRef) Delete(ctx context.Context) error
Delete deletes a dataset and all of its files.
This invalidates the DatasetRef and all associated file references.
func (*DatasetRef) DeleteFile ¶
func (d *DatasetRef) DeleteFile(ctx context.Context, filename string) error
DeleteFile deletes a file in the dataset.
func (*DatasetRef) DownloadBatch ¶
func (d *DatasetRef) DownloadBatch(ctx context.Context, files Iterator) *BatchDownloader
DownloadBatch creates a BatchDownloader.
func (*DatasetRef) FileInfo ¶
FileInfo returns metadata about a file in the dataset. Returns ErrFileNotFound if the file does not exist.
func (*DatasetRef) Files ¶
func (d *DatasetRef) Files(ctx context.Context, opts *FileIteratorOptions) *FileIterator
Files returns an iterator over all files in the dataset.
func (*DatasetRef) Name ¶
func (d *DatasetRef) Name() string
Name returns the dataset's unique identifier.
func (*DatasetRef) NewDeleteBatch ¶
func (d *DatasetRef) NewDeleteBatch() *DeleteBatch
NewDeleteBatch creates a DeleteBatch.
func (*DatasetRef) NewUploadBatch ¶
func (d *DatasetRef) NewUploadBatch() *UploadBatch
NewUploadBatch creates an UploadBatch.
func (*DatasetRef) ReadFile ¶
func (d *DatasetRef) ReadFile(ctx context.Context, filename string) (io.ReadCloser, error)
ReadFile reads the contents of a stored file.
If the file doesn't exist, this returns ErrFileNotFound.
The caller must call Close on the returned Reader when finished reading.
func (*DatasetRef) ReadFileRange ¶
func (d *DatasetRef) ReadFileRange( ctx context.Context, filename string, offset, length int64, ) (io.ReadCloser, error)
ReadFileRange reads at most length bytes from a file starting at the given offset. If length is negative, the file is read until the end. Length must not be zero.
If the file doesn't exist, this returns ErrFileNotFound.
The caller must call Close on the returned Reader when finished reading.
func (*DatasetRef) Seal ¶
func (d *DatasetRef) Seal(ctx context.Context) error
Seal makes a dataset read-only. This operation is not reversible.
func (*DatasetRef) WriteFile ¶
func (d *DatasetRef) WriteFile( ctx context.Context, filename string, source io.Reader, size int64, ) error
WriteFile writes the source to the filename in this dataset.
The file will be replaced if it exists or created if not. The file becomes available when Close returns successfully. The previous file is readable until the new file replaces it.
It is the caller's responsibility to call Close when writing is complete.
type DeleteBatch ¶
type DeleteBatch struct {
// contains filtered or unexported fields
}
DeleteBatch contains a list of files to delete from a dataset.
func (*DeleteBatch) AddFile ¶
func (b *DeleteBatch) AddFile(path string) error
AddFile adds a file to the batch.
func (*DeleteBatch) Delete ¶
func (b *DeleteBatch) Delete(ctx context.Context) error
Delete all paths in the batch.
func (*DeleteBatch) HasCapacity ¶
func (b *DeleteBatch) HasCapacity() bool
HasCapacity checks whether the batch has capacity for another file.
func (*DeleteBatch) Length ¶
func (b *DeleteBatch) Length() int
Length gets the number of files in a batch.
type FileBatch ¶
type FileBatch struct {
// contains filtered or unexported fields
}
FileBatch is a batch of files with readers.
type FileIterator ¶
type FileIterator struct {
// contains filtered or unexported fields
}
FileIterator is an iterator over files within a dataset.
type FileIteratorOptions ¶
type FileIteratorOptions struct { // Include presigned URLs to download each file. Note that this may result in slower response times. IncludeURLs bool // Maximum number of files to fetch in a single request. PageSize int // Prefix within the dataset. Only files that start with the prefix will be included. Prefix string }
FileIteratorOptions provides optional configuration to a file iterator.
type Option ¶
type Option interface {
Apply(c *Client)
}
Option allows a caller to configure additional options on a client.
type TraceResult ¶
type TraceResult struct { Start time.Time DNSStart time.Time DNSDone time.Time ConnectStart time.Time ConnectDone time.Time TLSHandshakeStart time.Time TLSHandshakeDone time.Time GotFirstResponseByte time.Time }
func NewResult ¶
func NewResult() *TraceResult
func (*TraceResult) Fields ¶
func (r *TraceResult) Fields() logrus.Fields
type UploadBatch ¶
type UploadBatch struct {
// contains filtered or unexported fields
}
UploadBatch contains files and their readers.
func (*UploadBatch) HasCapacity ¶
func (b *UploadBatch) HasCapacity(size int64) bool
HasCapacity checks whether the batch has capacity for a file with the given size.
func (*UploadBatch) Length ¶
func (b *UploadBatch) Length() int
Length gets the number of files in a batch.