const ( // MaxBufSize is the maximum buffer size (in bytes) received in a read chunk or sent in a write chunk. MaxBufSize = 2 * 1024 * 1024 )
Client is the go wrapper around a ByteStreamClient and provides an interface to it.
type Client struct {
// contains filtered or unexported fields
}
func NewClient(cc *grpc.ClientConn, options ...grpc.CallOption) *Client
NewClient creates a new bytestream.Client.
func (c *Client) Close()
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (c *Client) NewReader(ctx context.Context, resourceName string) (*Reader, error)
NewReader creates a new Reader to read a resource.
func (c *Client) NewReaderAt(ctx context.Context, resourceName string, offset int64) (*Reader, error)
NewReaderAt creates a new Reader to read a resource from the given offset.
func (c *Client) NewWriter(ctx context.Context, resourceName string) (*Writer, error)
NewWriter creates a new Writer to write a resource.
resourceName specifies the name of the resource. The resource will be available after Close has been called.
It is the caller's responsibility to call Close when writing is done.
TODO: There is currently no way to resume a write. Maybe NewWriter should begin with a call to QueryWriteStatus.
Reader reads from a byte stream.
type Reader struct {
// contains filtered or unexported fields
}
func (r *Reader) Close() error
Close implements io.Closer.
func (r *Reader) Read(p []byte) (int, error)
Read implements io.Reader. Read buffers received bytes that do not fit in p.
func (r *Reader) ResourceName() string
ResourceName gets the resource name this Reader is reading.
Writer writes to a byte stream.
type Writer struct {
// contains filtered or unexported fields
}
func (w *Writer) Close() error
Close implements io.Closer. It is the caller's responsibility to call Close() when writing is done.
func (w *Writer) ResourceName() string
ResourceName gets the resource name this Writer is writing.
func (w *Writer) Write(p []byte) (int, error)
Write implements io.Writer.
Name | Synopsis |
---|---|
.. |