server

package
v0.0.0-...-6d6ed6a Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2025 License: MIT Imports: 6 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrEmptyInfo = errors.New("empty info")

ErrEmptyInfo happens when ServerInfo is empty during Delegate creation.

Functions

func Apply

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

Types

type Delegate

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

Delegate implements the core.ServerDelegate interface.

It initializes the connection by sending ServerInfo to the client.

func New

func New[T any](info delegate.ServerInfo, factory TransportFactory[T],
	handler TransportHandler[T],
	ops ...SetOption,
) (d Delegate[T])

New creates a new Delegate.

Panics with ErrEmptyInfo if ServerInfo is empty.

func (Delegate[T]) Handle

func (d Delegate[T]) Handle(ctx context.Context, conn net.Conn) (err error)

type Options

type Options struct {
	ServerInfoSendDuration time.Duration
}

type SetOption

type SetOption func(o *Options)

func WithServerInfoSendDuration

func WithServerInfoSendDuration(d time.Duration) SetOption

WithServerInfoDuration specifies how long the server will try to send ServerInfo to the client. If == 0, it will try forever.

type Transport

type Transport[T any] interface {
	delegate.Transport[core.Result, core.Cmd[T]]
	SendServerInfo(info delegate.ServerInfo) error
}

Transport is a transport for the server delegate.

It is used by the delegate to receive Commands and send Results.

type TransportFactory

type TransportFactory[T any] interface {
	New(conn net.Conn) Transport[T]
}

TransportFactory is a factory which creates a Transport for the server delegate.

type TransportHandler

type TransportHandler[T any] interface {
	Handle(ctx context.Context, transport Transport[T]) error
}

TransportHandler is a handler of the Transport.

Jump to

Keyboard shortcuts

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