stream

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package stream provides a client that can be used on a *uds.Client or *uds.Conn to send streaming binary proto values. This package uses chunk underneath and therefore expects the other side to understand its data format.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client provides a wrapper around an *uds.Client or *uds.Server that can send and receive JSON messages.

func New

func New(rwc io.ReadWriteCloser, options ...Option) (client *Client, err error)

New is the constructor for Client. rwc must be a *uds.Client or *uds.Conn.

func (*Client) CloseSend added in v1.2.2

func (c *Client) CloseSend(ctx context.Context) error

CloseSend closes the send side of the connection. The Context can be used to timeout waiting for the other side to acknowledge the close. This is not thread safe and you cannot call it multiple times.

func (*Client) Read

func (c *Client) Read(ctx context.Context, m proto.Message) error

Read reads the next proto message into message m. This is not thread safe, though you can call Read() and Write() concurrently.

func (*Client) Write

func (c *Client) Write(ctx context.Context, m proto.Message) error

Write writes m as a binary proto message into the socket. This is not thread safe, though you can call Read() and Write() concurrently.

type Option

type Option func(c *Client)

Option is an optional argument to New.

func MaxSize

func MaxSize(size int64) Option

MaxSize is the maximum size a read message is allowed to be. If a message is larger than this, Next() will fail and the underlying connection will be closed.

func SharedPool

func SharedPool(pool *chunk.Pool) Option

SharedPool allows the use of a shared pool of buffers between Client instead of a pool per client. This is useful when clients are short lived and have similar message sizes.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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