delegate

package module
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: 7 Imported by: 4

README

delegate-go

Go Reference GoReportCard codecov

delegate-go facilitates communication between the cmd-stream client and server. It provides implementations of the core.ClientDelegate and core.ServerDelegate interfaces, both of which rely on an abstract transport layer for data exchange.

This module allows the server to initialize the client connection by sending a ServerInfo byte slice, typically used to indicate a set of supported commands. Client creation may fail with an error if it's ServerInfo doen't match the one received from the server.

Additionally, the client package includes KeepaliveDelegate and ReconnectDelegate:

  • KeepaliveDelegate initiates a ping-pong exchange with the server when no commands are pending. It sends the Ping command and expects the Pong result, both transmitted as a single zero byte (like a ball).
  • ReconnectDelegate implements the core.ClientReconnectDelegate interface, providing a Reconnect method that should be invoked by the client if the connection to the server is lost.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ServerInfoMUS = serverInfoMUS{}

ServerInfoMUS is a ServerInfo MUS serializer.

Functions

This section is empty.

Types

type PingCmd

type PingCmd[T any] struct{}

func (PingCmd[T]) Exec

func (c PingCmd[T]) Exec(ctx context.Context, seq core.Seq, at time.Time,
	receiver T, proxy core.Proxy) (err error)

type PongResult

type PongResult struct{}

func (PongResult) LastOne

func (r PongResult) LastOne() bool

type ServerInfo

type ServerInfo []byte

ServerInfo allows the client to identify a compatible server.

type Transport

type Transport[T, V any] interface {
	LocalAddr() net.Addr
	RemoteAddr() net.Addr

	SetSendDeadline(deadline time.Time) error
	Send(seq core.Seq, t T) (n int, err error)
	Flush() error

	SetReceiveDeadline(deadline time.Time) error
	Receive() (seq core.Seq, v V, n int, err error)

	Close() error
}

Transport is a common transport for the client and server delegates.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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