lease

package
v0.0.0-...-55c251c Latest Latest
Warning

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

Go to latest
Published: May 24, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PingLoop

func PingLoop(ctx context.Context, sess Session, interval time.Duration) error

func TcpDialer

func TcpDialer(addr string) (net.Conn, error)

Types

type Agent

type Agent struct {
	LocalInstance int64
	// contains filtered or unexported fields
}

func NewAgent

func NewAgent(config AgentConfig, listener net.Listener, dial Dialer) (*Agent, error)

func NewTcpListeningAgent

func NewTcpListeningAgent(config AgentConfig, listenAddr string) (*Agent, error)

func (*Agent) Addr

func (a *Agent) Addr() net.Addr

func (*Agent) Close

func (a *Agent) Close() error

func (*Agent) Establish

func (a *Agent) Establish(addr string) (Session, error)

func (*Agent) Find

func (a *Agent) Find(addr string) (Session, bool)

func (*Agent) Wait

func (a *Agent) Wait() error

type AgentConfig

type AgentConfig struct {
	TLS                      *tls.Config
	AppId                    string
	LeaseDuration            time.Duration
	ApplicationLeaseDuration time.Duration
	LeaseSuspendTimeout      time.Duration
	ArbitrationTimeout       time.Duration
}

func (*AgentConfig) SetDefault

func (c *AgentConfig) SetDefault()

type Dialer

type Dialer func(addr string) (net.Conn, error)

type LeaseAgentState

type LeaseAgentState int32
const (
	LeaseAgentStateOpen LeaseAgentState = iota
	LeaseAgentStateSuspended
	LeaseAgentStateFailed
)

type LeaseMessageType

type LeaseMessageType int32
const (
	LeaseMessageTypeLeaseRequest LeaseMessageType = iota
	LeaseMessageTypeLeaseResponse
	LeaseMessageTypePingRequest
	LeaseMessageTypePingResponse
	LeaseMessageTypeForwardRequest
	LeaseMessageTypeForwardResponse
	LeaseMessageTypeRelayRequest
	LeaseMessageTypeRelayResponse
)

type Message

type Message struct {
	Identifier               int64
	Type                     LeaseMessageType
	LeaseInstance            int64
	RemoteLeaseAgentInstance int64
	Duration                 time.Duration
	Expiration               time.Duration
	LeaseSuspendDuration     time.Duration
	ArbitrationDuration      time.Duration
	IsTwoWayTermination      bool
	MessageListenEndpoint    string
	// contains filtered or unexported fields
}

type Session

type Session interface {
	Meta() SessionMetadata
	// State() LeaseAgentState
	Ping(ctx context.Context) error

	LastPongTime() time.Time

	Close() error
}

type SessionMetadata

type SessionMetadata struct {
	LocalInstance  int64
	RemoteInstance int64
	RemoteEndpoint string
}

Jump to

Keyboard shortcuts

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