Documentation ¶
Index ¶
- Variables
- type BufferedDownload
- type BufferedUpload
- type Client
- func (client *Client) Close() error
- func (client *Client) Delete(ctx context.Context, limit *pb.OrderLimit, privateKey storj.PiecePrivateKey) (err error)
- func (client *Client) Download(ctx context.Context, limit *pb.OrderLimit, ...) (_ Downloader, err error)
- func (client *Client) Retain(ctx context.Context, req *pb.RetainRequest) (err error)
- func (client *Client) Upload(ctx context.Context, limit *pb.OrderLimit, ...) (_ Uploader, err error)
- func (client *Client) VerifyPieceHash(ctx context.Context, peer *identity.PeerIdentity, limit *pb.OrderLimit, ...) (err error)
- type Config
- type Download
- type Downloader
- type LockingDownload
- type LockingUpload
- type ReadBuffer
- type Upload
- type Uploader
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInternal is an error class for internal errors. ErrInternal = errs.Class("internal") // ErrProtocol is an error class for unexpected protocol sequence. ErrProtocol = errs.Class("protocol") // ErrVerifyUntrusted is an error in case there is a trust issue. ErrVerifyUntrusted = errs.Class("untrusted") // ErrStorageNodeInvalidResponse is an error when a storage node returns a response with invalid data ErrStorageNodeInvalidResponse = errs.Class("storage node has returned an invalid response") )
var DefaultConfig = Config{ UploadBufferSize: 256 * memory.KiB.Int64(), DownloadBufferSize: 256 * memory.KiB.Int64(), InitialStep: 64 * memory.KiB.Int64(), MaximumStep: 1 * memory.MiB.Int64(), }
DefaultConfig are the default params used for upload and download.
var Error = errs.Class("piecestore")
Error is the default error class for piecestore client.
Functions ¶
This section is empty.
Types ¶
type BufferedDownload ¶
type BufferedDownload struct {
// contains filtered or unexported fields
}
BufferedDownload implements buffering for download.
func (*BufferedDownload) Close ¶
func (download *BufferedDownload) Close() error
Close closes the buffered download.
func (*BufferedDownload) GetHashAndLimit ¶ added in v0.19.0
func (download *BufferedDownload) GetHashAndLimit() (*pb.PieceHash, *pb.OrderLimit)
GetHashAndLimit gets the download's hash and original order limit.
type BufferedUpload ¶
type BufferedUpload struct {
// contains filtered or unexported fields
}
BufferedUpload implements buffering for an Upload.
func (*BufferedUpload) Cancel ¶
func (upload *BufferedUpload) Cancel(ctx context.Context) (err error)
Cancel aborts the upload.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client implements uploading, downloading and deleting content from a piecestore.
func Dial ¶ added in v0.14.8
func Dial(ctx context.Context, dialer rpc.Dialer, target *pb.Node, log *zap.Logger, config Config) (*Client, error)
Dial dials the target piecestore endpoint.
func (*Client) Delete ¶
func (client *Client) Delete(ctx context.Context, limit *pb.OrderLimit, privateKey storj.PiecePrivateKey) (err error)
Delete uses delete order limit to delete a piece on piece store.
func (*Client) Download ¶
func (client *Client) Download(ctx context.Context, limit *pb.OrderLimit, piecePrivateKey storj.PiecePrivateKey, offset, size int64) (_ Downloader, err error)
Download starts a new download using the specified order limit at the specified offset and size.
func (*Client) Retain ¶ added in v0.15.0
Retain uses a bloom filter to tell the piece store which pieces to keep.
func (*Client) Upload ¶
func (client *Client) Upload(ctx context.Context, limit *pb.OrderLimit, piecePrivateKey storj.PiecePrivateKey) (_ Uploader, err error)
Upload initiates an upload to the storage node.
func (*Client) VerifyPieceHash ¶
func (client *Client) VerifyPieceHash(ctx context.Context, peer *identity.PeerIdentity, limit *pb.OrderLimit, hash *pb.PieceHash, expectedHash []byte) (err error)
VerifyPieceHash verifies piece hash which is sent by peer.
type Config ¶
type Config struct { UploadBufferSize int64 DownloadBufferSize int64 InitialStep int64 MaximumStep int64 }
Config defines piecestore client parameters fro upload and download.
type Download ¶
type Download struct {
// contains filtered or unexported fields
}
Download implements downloading from a piecestore.
func (*Download) GetHashAndLimit ¶ added in v0.19.0
func (client *Download) GetHashAndLimit() (*pb.PieceHash, *pb.OrderLimit)
GetHashAndLimit gets the download's hash and original order limit.
type Downloader ¶
type Downloader interface { Read([]byte) (int, error) Close() error GetHashAndLimit() (*pb.PieceHash, *pb.OrderLimit) }
Downloader is interface that can be used for downloading content. It matches signature of `io.ReadCloser`, with one extra function, GetHashAndLimit(), used for accessing information during GET_REPAIR.
func NewBufferedDownload ¶
func NewBufferedDownload(download *Download, size int) Downloader
NewBufferedDownload creates a buffered download with the specified size.
type LockingDownload ¶
type LockingDownload struct {
// contains filtered or unexported fields
}
LockingDownload adds a lock around download making it safe to use concurrently. TODO: this shouldn't be needed.
func (*LockingDownload) Close ¶
func (download *LockingDownload) Close() error
Close closes the deownload.
func (*LockingDownload) GetHashAndLimit ¶ added in v0.19.0
func (download *LockingDownload) GetHashAndLimit() (*pb.PieceHash, *pb.OrderLimit)
GetHashAndLimit gets the download's hash and original order limit
type LockingUpload ¶
type LockingUpload struct {
// contains filtered or unexported fields
}
LockingUpload adds a lock around upload making it safe to use concurrently. TODO: this shouldn't be needed.
func (*LockingUpload) Cancel ¶
func (upload *LockingUpload) Cancel(ctx context.Context) (err error)
Cancel aborts the upload.
type ReadBuffer ¶
type ReadBuffer struct {
// contains filtered or unexported fields
}
ReadBuffer implements buffered reading with an error.
func (*ReadBuffer) Empty ¶
func (buffer *ReadBuffer) Empty() bool
Empty checks whether buffer needs to be filled.
func (*ReadBuffer) Error ¶
func (buffer *ReadBuffer) Error() error
Error returns an error if it was encountered.
func (*ReadBuffer) Errored ¶
func (buffer *ReadBuffer) Errored() bool
Errored returns whether the buffer contains an error.
func (*ReadBuffer) Fill ¶
func (buffer *ReadBuffer) Fill(data []byte)
Fill fills the buffer with the specified bytes.
func (*ReadBuffer) IncludeError ¶
func (buffer *ReadBuffer) IncludeError(err error)
IncludeError adds error at the end of the buffer.
type Upload ¶
type Upload struct {
// contains filtered or unexported fields
}
Upload implements uploading to the storage node.
type Uploader ¶
type Uploader interface { // Write uploads data to the storage node. Write([]byte) (int, error) // Cancel cancels the upload. Cancel(context.Context) error // Commit finalizes the upload. Commit(context.Context) (*pb.PieceHash, error) }
Uploader defines the interface for uploading a piece.
func NewBufferedUpload ¶
NewBufferedUpload creates buffered upload with the specified size.