bytestream

package
v0.207.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 19, 2024 License: BSD-3-Clause Imports: 6 Imported by: 2

Documentation

Overview

Package bytestream provides a client for any service that exposes a ByteStream API.

Note: This package is a work-in-progress. Backwards-incompatible changes should be expected.

Index

Constants

View Source
const (
	// MaxBufSize is the maximum buffer size (in bytes) received in a read chunk or sent in a write chunk.
	MaxBufSize = 2 * 1024 * 1024
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is the go wrapper around a ByteStreamClient and provides an interface to it.

func NewClient

func NewClient(cc *grpc.ClientConn, options ...grpc.CallOption) *Client

NewClient creates a new bytestream.Client.

func (*Client) Close added in v0.37.0

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 (*Client) NewReader

func (c *Client) NewReader(ctx context.Context, resourceName string) (*Reader, error)

NewReader creates a new Reader to read a resource.

func (*Client) NewReaderAt

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 (*Client) NewWriter

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.

type Reader

type Reader struct {
	// contains filtered or unexported fields
}

Reader reads from a byte stream.

func (*Reader) Close

func (r *Reader) Close() error

Close implements io.Closer.

func (*Reader) Read

func (r *Reader) Read(p []byte) (int, error)

Read implements io.Reader. Read buffers received bytes that do not fit in p.

func (*Reader) ResourceName

func (r *Reader) ResourceName() string

ResourceName gets the resource name this Reader is reading.

type Writer

type Writer struct {
	// contains filtered or unexported fields
}

Writer writes to a byte stream.

func (*Writer) Close

func (w *Writer) Close() error

Close implements io.Closer. It is the caller's responsibility to call Close() when writing is done.

func (*Writer) ResourceName

func (w *Writer) ResourceName() string

ResourceName gets the resource name this Writer is writing.

func (*Writer) Write

func (w *Writer) Write(p []byte) (int, error)

Write implements io.Writer.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL