Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AsyncResult ¶
AsyncResult represents an asynchronous result.
Seq is the sequence number of the Command, Error != nil if something went wrong with the connection.
type ClientDelegate ¶
type ClientDelegate[T any] interface { LocalAddr() net.Addr RemoteAddr() net.Addr SetSendDeadline(deadline time.Time) error Send(seq Seq, cmd Cmd[T]) error Flush() error SetReceiveDeadline(deadline time.Time) error Receive() (seq Seq, result Result, err error) Close() error }
ClientDelegate helps the client to send Commands and receive Results.
type ClientKeepaliveDelegate ¶
type ClientKeepaliveDelegate[T any] interface { ClientDelegate[T] Keepalive(muSn *sync.Mutex) }
ClientKeepaliveDelegate defines the Keepalive method.
This delegate can be used if you want the client to keepalive connection to the server.
type ClientReconnectDelegate ¶
type ClientReconnectDelegate[T any] interface { ClientDelegate[T] Reconnect() error }
ClientReconnectDelegate defines the Reconnect method.
This delegate can be used if you want the client to reconnect to the server in case of a connection loss.
type Cmd ¶
type Cmd[T any] interface { Exec(ctx context.Context, at time.Time, seq Seq, receiver T, proxy Proxy) error }
Cmd defines the general Command interface.
The Exec method is invoked by the server's Invoker. It executes the Command with the following parameters:
- ctx: Execution context.
- at: Timestamp when the server received the Command.
- seq: Sequence number assigned to the Command.
- receiver: The Receiver of type T.
- 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) error SendWithDeadline(deadline time.Time, seq Seq, result Result) 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.