Documentation
¶
Index ¶
- func Apply(ops []SetOption, o *Options)
- type Codec
- type Options
- type Reader
- type SetOption
- type Transport
- func (tn *Transport[T, V]) Close() error
- func (tn *Transport[T, V]) Flush() (err error)
- func (tn *Transport[T, V]) LocalAddr() net.Addr
- func (tn *Transport[T, V]) Receive() (seq core.Seq, v V, n int, err error)
- func (tn *Transport[T, V]) RemoteAddr() net.Addr
- func (tn *Transport[T, V]) Send(seq core.Seq, t T) (n int, err error)
- func (tn *Transport[T, V]) SetReceiveDeadline(deadline time.Time) error
- func (tn *Transport[T, V]) SetSendDeadline(deadline time.Time) error
- type Writer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Codec ¶
type Codec[T, V any] interface { Encode(seq core.Seq, t T, w Writer) (n int, err error) Decode(r Reader) (seq core.Seq, v V, n int, err error) }
Codec is responsible for encoding and decoding data transmitted over a connection:
- On the client side: encodes Commands to send and decodes Results received from the server.
- On the server side: decodes Commands from clients, validates them, and encodes Results to send back.
type Reader ¶
type Reader interface { io.Reader io.ByteReader }
Reader is an interface that extends io.Reader and io.ByteReader.
type SetOption ¶
type SetOption func(o *Options)
func WithReaderBufSize ¶
WithReaderBufSize sets the buffer size for the Reader. If set to 0, the default bufio.Reader size is used.
func WithWriterBufSize ¶
WithWriterBufSize sets the buffer size for the Writer. If set to 0, the default bufio.Writer size is used.
type Transport ¶
Transport is a common transport for both client and server.
It uses a user-defined codec to encode and decode data over the connection.
func (*Transport[T, V]) RemoteAddr ¶
RemoteAddr returns the connection remote network address.
func (*Transport[T, V]) SetReceiveDeadline ¶
SetReceiveDeadline sets a receive deadline.
type Writer ¶
type Writer interface { io.ByteWriter io.Writer io.StringWriter Flush() error }
Writer is an interface that extends io.ByteWriter, io.Writer, and io.StringWriter. It also includes a Flush method to ensure buffered data is written out.