Documentation ¶
Index ¶
Constants ¶
const (
// PartSize is the number of bytes that a object part has, currently 5MB per part.
PartSize = 5 << 20
)
Variables ¶
var ErrBufferLength error = fmt.Errorf("len(p) is required to be at least %d", PartSize)
ErrBufferLength is the error returned by StreamReadCloser.Read when len(p) <= PartSize.
Functions ¶
This section is empty.
Types ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is a structure used for downloading objects from S3.
func NewService ¶
NewService creates a Service and returns it.
func (Service) Download ¶
func (s Service) Download(req *pb.DownloadRequest, stream pb.Download_DownloadServer) error
Download is the request to download a object from S3. It receives a request for a object. Responds with a stream of the object bytes in chunks.
func (Service) GetS3Client ¶
GetS3Client returns the internal s3 client.
type StreamReadCloser ¶
type StreamReadCloser struct {
// contains filtered or unexported fields
}
StreamReadCloser is a structure that implements io.Reader to read a object's bytes from stream.
func NewStreamReadCloser ¶
func NewStreamReadCloser(stream pb.Download_DownloadClient) StreamReadCloser
NewStreamReadCloser returns a StreamReadCloser initialized with stream to read the object's bytes from.
func (StreamReadCloser) Close ¶
func (r StreamReadCloser) Close() error
Close closes the send direction of the underlying r.stream.
func (StreamReadCloser) Read ¶
func (r StreamReadCloser) Read(p []byte) (n int, err error)
Read implements io.Reader to read object's bytes into p, len(p) MUST be >= PartSize, otherwise Read wouldn't read the chunk into p, Read doesn't call r.stream.Recv() unless len(p) >= PartSize. If Read would've read the chunk into p where len(p) < PartSize, it would read incomplete object bytes into p and the reader would miss bytes from the object stream. Implementation does not retain p.