Documentation
¶
Index ¶
- Constants
- Variables
- func Apply(ops []SetOption, o *Options)
- func ApplyKeepAlive(ops []SetKeepaliveOption, o *KeepaliveOptions)
- type Delegate
- func (d Delegate[T]) Close() error
- func (d Delegate[T]) Flush() error
- func (d Delegate[T]) LocalAddr() net.Addr
- func (d Delegate[T]) Options() Options
- func (d Delegate[T]) Receive() (seq core.Seq, result core.Result, n int, err error)
- func (d Delegate[T]) RemoteAddr() net.Addr
- func (d Delegate[T]) Send(seq core.Seq, cmd core.Cmd[T]) (n int, err error)
- func (d Delegate[T]) SetReceiveDeadline(deadline time.Time) error
- func (d Delegate[T]) SetSendDeadline(deadline time.Time) error
- type KeepaliveDelegate
- type KeepaliveOptions
- type Options
- type ReconnectDelegate
- func (d ReconnectDelegate[T]) Close() (err error)
- func (d ReconnectDelegate[T]) Flush() error
- func (d ReconnectDelegate[T]) LocalAddr() net.Addr
- func (d ReconnectDelegate[T]) Options() Options
- func (d ReconnectDelegate[T]) Receive() (seq core.Seq, result core.Result, n int, err error)
- func (d ReconnectDelegate[T]) Reconnect() (err error)
- func (d ReconnectDelegate[T]) RemoteAddr() net.Addr
- func (d ReconnectDelegate[T]) Send(seq core.Seq, cmd core.Cmd[T]) (n int, err error)
- func (d ReconnectDelegate[T]) SetReceiveDeadline(deadline time.Time) error
- func (d ReconnectDelegate[T]) SetSendDeadline(deadline time.Time) error
- func (d ReconnectDelegate[T]) Transport() Transport[T]
- type SetKeepaliveOption
- type SetOption
- type Transport
- type TransportFactory
Constants ¶
const ( KeepaliveTime = 3 * time.Second KeepaliveIntvl = time.Second )
Variables ¶
var ErrServerInfoMismatch = errors.New("server info mismatch")
ErrServerInfoMismatch happens when ServerInfo of the client and server does not match.
Functions ¶
func ApplyKeepAlive ¶
func ApplyKeepAlive(ops []SetKeepaliveOption, o *KeepaliveOptions)
Types ¶
type Delegate ¶
type Delegate[T any] struct { // contains filtered or unexported fields }
Delegate implements the core.ClientDelegate interface.
func New ¶
func New[T any](info delegate.ServerInfo, transport Transport[T], ops ...SetOption) (d Delegate[T], err error)
New creates a new Delegate.
The Delegate expects to receive ServerInfo from the server upon creation.
Returns ErrServerInfoMismatch if the received ServerInfo does not match the specified one.
func NewWithoutInfo ¶
NewWithoutInfo for tests only.
func (Delegate[T]) RemoteAddr ¶
func (Delegate[T]) SetReceiveDeadline ¶
type KeepaliveDelegate ¶
KeepaliveDelegate implements the core.ClientDelegate interface.
When there are no Commands to send, it initiates a Ping-Pong exchange with the server. It sends a Ping Command and expects a Pong Result, both represented as a single zero byte (like a ball being passed).
func NewKeepalive ¶
func NewKeepalive[T any](d ccln.Delegate[T], ops ...SetKeepaliveOption) ( kd KeepaliveDelegate[T])
NewKeepalive creates a new KeepaliveDelegate.
func (KeepaliveDelegate[T]) Close ¶
func (d KeepaliveDelegate[T]) Close() (err error)
func (KeepaliveDelegate[T]) Flush ¶
func (d KeepaliveDelegate[T]) Flush() (err error)
func (KeepaliveDelegate[T]) Keepalive ¶
func (d KeepaliveDelegate[T]) Keepalive(muSn *sync.Mutex)
func (KeepaliveDelegate[T]) Receive ¶
func (d KeepaliveDelegate[T]) Receive() (seq core.Seq, result core.Result, n int, err error)
type KeepaliveOptions ¶
type ReconnectDelegate ¶
type ReconnectDelegate[T any] struct { // contains filtered or unexported fields }
ReconnectDelegate implements the core.ClientReconnectDelegate interface.
func NewReconnect ¶
func NewReconnect[T any](info delegate.ServerInfo, factory TransportFactory[T], ops ...SetOption) (d ReconnectDelegate[T], err error)
NewReconnect creates a new ReconnectDelegate.
func NewReconnectWithoutInfo ¶
func NewReconnectWithoutInfo[T any](factory TransportFactory[T], closedFlag *uint32, transport *atomic.Value, options Options, ) ReconnectDelegate[T]
NewReconnectWithoutInfo for tests only.
func (ReconnectDelegate[T]) Close ¶
func (d ReconnectDelegate[T]) Close() (err error)
func (ReconnectDelegate[T]) Flush ¶
func (d ReconnectDelegate[T]) Flush() error
func (ReconnectDelegate[T]) LocalAddr ¶
func (d ReconnectDelegate[T]) LocalAddr() net.Addr
func (ReconnectDelegate[T]) Options ¶
func (d ReconnectDelegate[T]) Options() Options
func (ReconnectDelegate[T]) Receive ¶
func (d ReconnectDelegate[T]) Receive() (seq core.Seq, result core.Result, n int, err error)
func (ReconnectDelegate[T]) Reconnect ¶
func (d ReconnectDelegate[T]) Reconnect() (err error)
func (ReconnectDelegate[T]) RemoteAddr ¶
func (d ReconnectDelegate[T]) RemoteAddr() net.Addr
func (ReconnectDelegate[T]) Send ¶
func (d ReconnectDelegate[T]) Send(seq core.Seq, cmd core.Cmd[T]) (n int, err error)
func (ReconnectDelegate[T]) SetReceiveDeadline ¶
func (d ReconnectDelegate[T]) SetReceiveDeadline(deadline time.Time) error
func (ReconnectDelegate[T]) SetSendDeadline ¶
func (d ReconnectDelegate[T]) SetSendDeadline(deadline time.Time) error
func (ReconnectDelegate[T]) Transport ¶
func (d ReconnectDelegate[T]) Transport() Transport[T]
type SetKeepaliveOption ¶
type SetKeepaliveOption func(o *KeepaliveOptions)
func WithKeepaliveIntvl ¶
func WithKeepaliveIntvl(d time.Duration) SetKeepaliveOption
WithKeepaliveIntvl sets the interval between consecutive Ping Commands sent by the client.
func WithKeepaliveTime ¶
func WithKeepaliveTime(d time.Duration) SetKeepaliveOption
WithKeepaliveTime sets the inactivity period after which the client starts sending Ping Commands to the server if no Commands have been sent.
type SetOption ¶
type SetOption func(o *Options)
func WithServerInfoReceiveDuration ¶
WithServerInfoReceiveDuration sets the duration the client will wait for the ServerInfo. If set to 0, the client waits indefinitely.
type Transport ¶
type Transport[T any] interface { delegate.Transport[core.Cmd[T], core.Result] ReceiveServerInfo() (info delegate.ServerInfo, err error) }
Transport is a transport for the client delegate.
It is used by the delegate to send Commands and receive Results.
type TransportFactory ¶
TransportFactory is a factory which creates a ClientTransport.