client

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2025 License: MIT Imports: 8 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AdaptCodec added in v0.4.1

func AdaptCodec[T any](codec Codec[T], o Options) transport.Codec[core.Cmd[T], core.Result]

AdaptCodec adapts the provided Codec.

func Apply added in v0.4.0

func Apply(ops []SetOption, o *Options)

Types

type Codec

type Codec[T any] codec.Codec[core.Cmd[T], core.Result]

Codec defines a generic client codec interface for encoding Commands and decoding Results.

  • Encode is used by the client to send Commands to the server. If encoding fails, Client.Send returns the corresponding error.
  • Decode is used by the client to receive Results from the server. If decoding fails, the client is closed automatically.

type ConnFactory

type ConnFactory interface {
	New() (net.Conn, error)
}

ConnFactory establishes a new connection to the server.

type ConnFactoryFn added in v0.4.1

type ConnFactoryFn func() (net.Conn, error)

ConnFactoryFn is a function implementation of the ConnFactory.

func (ConnFactoryFn) New added in v0.4.1

func (f ConnFactoryFn) New() (net.Conn, error)

type Options added in v0.4.0

type Options struct {
	Info      delegate.ServerInfo
	Base      []ccln.SetOption
	Transport []transport.SetOption
	Delegate  []dcln.SetOption
	Keepalive []dcln.SetKeepaliveOption
}

Options defines the configuration settings for initializing a client.

These options are composed of modular components that configure different layers of the client, including transport, keepalive, delegate behavior, and base client setup.

type SetOption added in v0.4.0

type SetOption func(o *Options)

func WithCore added in v0.4.1

func WithCore(ops ...ccln.SetOption) SetOption

WithCore applies base-level configuration options.

func WithDelegate added in v0.4.0

func WithDelegate(ops ...dcln.SetOption) SetOption

WithDelegate applies delegate-specific options.

These options customize the behavior of the client delegate.

func WithKeepalive added in v0.4.0

func WithKeepalive(ops ...dcln.SetKeepaliveOption) SetOption

WithKeepalive applies keepalive-specific options.

These options configure how the client maintains an active connection, including Ping intervals and timeout settings.

func WithServerInfo added in v0.4.0

func WithServerInfo(info delegate.ServerInfo) SetOption

WithServerInfo sets the ServerInfo for the client.

ServerInfo helps the client identify a compatible server.

func WithTransport added in v0.4.0

func WithTransport(ops ...transport.SetOption) SetOption

WithTransport applies transport-specific options.

These options configure the transport layer.

type TransportFactory added in v0.4.1

type TransportFactory[T any] struct {
	// contains filtered or unexported fields
}

TransportFactory creates new Transport instances.

It encapsulates the logic for establishing a new connection and applying optional transport-level configuration.

func NewTransportFactory added in v0.4.1

func NewTransportFactory[T any](codec transport.Codec[core.Cmd[T], core.Result],
	factory ConnFactory, ops ...transport.SetOption,
) *TransportFactory[T]

NewTransportFactory creates a new TransportFactory.

func (TransportFactory[T]) New added in v0.4.1

func (f TransportFactory[T]) New() (transport dcln.Transport[T],
	err error,
)

New creates a Transport by establishing a new connection.

Returns an error if connection creation fails.

Jump to

Keyboard shortcuts

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