dataconn

package
v0.7.9 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EndpointPing string = "/v1/ping"
	EndpointSend string = "/v1/send"
	EndpointRecv string = "/v1/recv"
)
View Source
const (
	ReqHeader uint32 = 1 + iota
	ReqStructured
	ResHeader
	ResStructured
	ZFSStream
)
View Source
const (
	HeartbeatInterval         = 5 * time.Second
	HeartbeatPeerTimeout      = 10 * time.Second
	RequestHeaderMaxSize      = 1 << 15
	RequestStructuredMaxSize  = 1 << 22
	ResponseHeaderMaxSize     = 1 << 15
	ResponseStructuredMaxSize = 1 << 23
)

Note that changing theses constants may break interop with other clients Aggressive with timing, conservative (future compatible) with buffer sizes

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func NewClient

func NewClient(connecter transport.Connecter, log Logger) *Client

func (*Client) ReqPing

func (c *Client) ReqPing(ctx context.Context, req *pdu.PingReq) (*pdu.PingRes, error)

func (*Client) ReqRecv

func (c *Client) ReqRecv(ctx context.Context, req *pdu.ReceiveReq, stream io.ReadCloser) (*pdu.ReceiveRes, error)

func (*Client) ReqSend

func (c *Client) ReqSend(ctx context.Context, req *pdu.SendReq) (*pdu.SendRes, io.ReadCloser, error)

type ContextInterceptor added in v0.7.4

type ContextInterceptor = func(ctx context.Context, data ContextInterceptorData, handler func(ctx context.Context))

type ContextInterceptorData added in v0.7.4

type ContextInterceptorData interface {
	FullMethod() string
	ClientIdentity() string
}

type Handler

type Handler interface {
	// Send handles a SendRequest.
	// The returned io.ReadCloser is allowed to be nil, for example if the requested Send is a dry-run.
	Send(ctx context.Context, r *pdu.SendReq) (*pdu.SendRes, io.ReadCloser, error)
	// Receive handles a ReceiveRequest.
	// It is guaranteed that Server calls Receive with a stream that holds the IdleConnTimeout
	// configured in ServerConfig.Shared.IdleConnTimeout.
	Receive(ctx context.Context, r *pdu.ReceiveReq, receive io.ReadCloser) (*pdu.ReceiveRes, error)
	// PingDataconn handles a PingReq
	PingDataconn(ctx context.Context, r *pdu.PingReq) (*pdu.PingRes, error)
}

Handler implements the functionality that is exposed by Server to the Client.

type Logger

type Logger = logger.Logger

type ProtocolError

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

func (*ProtocolError) Error

func (e *ProtocolError) Error() string

type RemoteHandlerError

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

func (*RemoteHandlerError) Error

func (e *RemoteHandlerError) Error() string

type Server

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

func NewServer

func NewServer(wi WireInterceptor, ci ContextInterceptor, logger Logger, handler Handler) *Server

wi and ci may be nil

func (*Server) Serve

Serve consumes the listener, closes it as soon as ctx is closed. No accept errors are returned: they are logged to the Logger passed to the constructor.

type WireInterceptor

type WireInterceptor func(ctx context.Context, rawConn *transport.AuthConn) (context.Context, *transport.AuthConn)

WireInterceptor has a chance to exchange the context and connection on each client connection.

Directories

Path Synopsis
integration_test_variablereceiverate
This integration test exercises the behavior of heartbeatconn where the server is slow at handling the data received over the connection.
This integration test exercises the behavior of heartbeatconn where the server is slow at handling the data received over the connection.
microbenchmark to manually test rpc/dataconn performance
microbenchmark to manually test rpc/dataconn performance
package timeoutconn wraps a Wire to provide idle timeouts based on Set{Read,Write}Deadline.
package timeoutconn wraps a Wire to provide idle timeouts based on Set{Read,Write}Deadline.
internal/wireevaluator
a tool to test whether a given transport implements the timeoutconn.Wire interface
a tool to test whether a given transport implements the timeoutconn.Wire interface

Jump to

Keyboard shortcuts

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