core

package module
v0.0.0-...-0964e5d Latest Latest
Warning

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

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

README

core-go

Go Reference GoReportCard codecov

core-go contains the definitions for both the client and the server.

The client delegates all communication tasks, such as sending commands, receiving results, and closing the connection to the client.Delegate.

The server uses a configurable number of workers to manage client connections via the server.Delegate.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AsyncResult

type AsyncResult struct {
	Seq       Seq
	BytesRead int
	Result    Result
	Error     error
}

AsyncResult represents an asynchronous result.

Seq is the sequence number of the Command, Error != nil if something went wrong with the connection.

type Cmd

type Cmd[T any] interface {
	Exec(ctx context.Context, seq Seq, at time.Time, receiver T, proxy Proxy) error
}

Cmd defines the general Command interface.

The Exec method is invoked by the server's Invoker and is responsible for executing the Command with the following parameters:

  • ctx: Execution context.
  • seq: Sequence number uniquely identifying the Command.
  • at: Timestamp when the server received the Command.
  • receiver: The Receiver of type T, which handles the Command's execution logic.
  • proxy: A server transport proxy used to send Results back to the client.

type Listener

type Listener interface {
	Addr() net.Addr
	SetDeadline(time.Time) error
	Accept() (net.Conn, error)
	Close() error
}

Listener is a server network listener.

On Close, it should not close already accepted connections.

type Proxy

type Proxy interface {
	LocalAddr() net.Addr
	RemoteAddr() net.Addr
	Send(seq Seq, result Result) (n int, err error)
	SendWithDeadline(seq Seq, result Result, deadline time.Time) (n int, err error)
}

Proxy represents a server transport proxy, enabling Commands to send Results back.

Implementation of this interface must be thread-safe.

type Result

type Result interface {
	LastOne() bool
}

Result represents the outcome of the Сommand execution.

LastOne method indicates the final Result of the Command.

type Seq

type Seq int64

Seq represents the sequence number of a Command.

The sequence number ensures that each Command can be uniquely identified and mapped to its corresponding Results.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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