client

package
v0.1.0-rc.5 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package client is the Go end of a connection, which the server's tests and measurements use: calls from many goroutines, each a stream of its own, and their answers in any order. A Go program embeds the store instead.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotTheServer = errors.New("client: the endpoint SERVE names cannot prove it read SERVE")

ErrNotTheServer is an endpoint whose WELCOME does not prove it read SERVE: the server that wrote SERVE is gone, and another process holds its endpoint.

Functions

This section is empty.

Types

type Conn

type Conn struct {
	Welcome wire.Welcome
	// contains filtered or unexported fields
}

Conn is a client's connection. Its reader never waits for the program: what the server sends waits on its stream, within the credit the client granted.

func Dial

func Dial(ctx context.Context, endpoint string, hello wire.Hello) (*Conn, error)

Dial connects to an endpoint, unix://, tcp:// or pipe:, and shakes hands.

func Found

func Found(ctx context.Context, dir string, hello wire.Hello) (*Conn, error)

Found reaches the sidecar that SERVE in <dir>/server/ names, as an SDK does. Its HELLO carries a fresh challenge, and no call goes before the WELCOME's proof checks.

func New

func New(conn io.ReadWriteCloser, hello wire.Hello) (*Conn, error)

New shakes hands over conn: HELLO, then the server's WELCOME, or its GOAWAY as an error.

func (*Conn) Adopt

func (c *Conn) Adopt(id uint32) (*Stream, error)

Adopt watches a stream a test opens with frames of its own.

func (*Conn) Call

func (c *Conn) Call(ctx context.Context, method wire.Method, request Message) ([]byte, error)

Call sends a request and waits for its answer's body; an ERROR is a *wire.Error.

func (*Conn) Close

func (c *Conn) Close() error

Close ends the connection and waits for its reader.

func (*Conn) CloseWrite

func (c *Conn) CloseWrite() error

CloseWrite ends what the client sends, as a private child's parent closes its stdin, and leaves the answers to come.

func (*Conn) Done

func (c *Conn) Done() <-chan struct{}

Done is closed once the connection ends.

func (*Conn) GoAway

func (c *Conn) GoAway() *wire.GoAway

func (*Conn) Open

func (c *Conn) Open(ctx context.Context, method wire.Method, request Message, end bool) (*Stream, error)

Open opens a stream with its REQUEST; end says the client sends nothing after it.

func (*Conn) SendFrame

func (c *Conn) SendFrame(frame []byte) error

SendFrame writes a frame as it is, for a test that breaks the protocol on purpose.

type Message

type Message interface {
	Append(dst []byte) []byte
}

type Stream

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

Stream is one stream as the client sees it: what it uploads, and the RESPONSE and DATA the server sends on it, waiting until they are taken.

func (*Stream) Cancel

func (st *Stream) Cancel() error

Cancel asks the server to stop the stream, which still ends with its final frame.

func (*Stream) ID

func (st *Stream) ID() uint32

func (*Stream) Next

func (st *Stream) Next(ctx context.Context) (body []byte, last bool, err error)

Next waits for the next DATA: its body, and whether it ended the stream. It grants back what it takes, as a consumer that has room again.

func (*Stream) Response

func (st *Stream) Response(ctx context.Context) ([]byte, error)

Response waits for the stream's RESPONSE: its body, or the *wire.Error it ends the stream with.

func (*Stream) Send

func (st *Stream) Send(ctx context.Context, body []byte, end bool) error

Send uploads one DATA body, within the stream's credit and the connection's; end says it is the last.

Jump to

Keyboard shortcuts

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