server

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2025 License: MIT Imports: 11 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ServerInfo = []byte("default")

ServerInfo is the default ServerInfo.

Functions

func AdaptCodec added in v0.4.1

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

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.Result, core.Cmd[T]]

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

  • Encode is used by the server to send Results back to the client. If encoding fails, the server closes the corresponding client connection.
  • Decode is used by the server to receive Commands. If decoding fails, the server closes the corresponding client connection.

type Invoker added in v0.1.1

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

Invoker is the default implementation of the handler.Invoker interface.

It performs no additional actions other than executing the provided Command.

func NewInvoker added in v0.4.0

func NewInvoker[T any](receiver T) Invoker[T]

NewInvoker creates a new Invoker.

func (Invoker[T]) Invoke added in v0.1.1

func (i Invoker[T]) Invoke(ctx context.Context, seq core.Seq, at time.Time,
	bytesRead int, cmd core.Cmd[T], proxy core.Proxy) error

type Options added in v0.4.0

type Options struct {
	Info      delegate.ServerInfo
	Base      []csrv.SetOption
	Delegate  []dsrv.SetOption
	Handler   []handler.SetOption
	Transport []transport.SetOption
}

Options defines the configuration settings for initializing a server.

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

type SetOption added in v0.4.0

type SetOption func(o *Options)

func WithCore added in v0.4.1

func WithCore(ops ...csrv.SetOption) SetOption

WithCore applies core-level configuration options.

func WithDelegate added in v0.4.0

func WithDelegate(ops ...dsrv.SetOption) SetOption

WithDelegate applies delegate-specific options.

These options customize the behavior of the server delegate.

func WithHandler added in v0.4.0

func WithHandler(ops ...handler.SetOption) SetOption

WithHandler sets options for the connection handler.

These options customize the behavior of the connection handler.

func WithServerInfo added in v0.4.0

func WithServerInfo(info delegate.ServerInfo) SetOption

WithServerInfo sets the ServerInfo for the server.

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

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

TransportFactory implements the delegate.ServerTransportFactory interface.

It creates Transports that handle encoding Results / decoding Commands over a network connection.

func NewTransportFactory added in v0.4.1

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

NewTransportFactory creates a new TransportFactory using the provided codec and optional transport-level configuration options.

func (TransportFactory[T]) New

func (f TransportFactory[T]) New(conn net.Conn) dsrv.Transport[T]

Jump to

Keyboard shortcuts

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