Documentation ¶
Index ¶
- Constants
- Variables
- type Chain
- type Chainer
- type FailMarker
- type Filter
- type Node
- type NodeGroup
- type Route
- func (r *Route) Bind(ctx context.Context, network, address string, opts ...connector.BindOption) (net.Listener, error)
- func (r *Route) Dial(ctx context.Context, network, address string) (net.Conn, error)
- func (r *Route) GetNode(index int) *Node
- func (r *Route) Len() int
- func (r *Route) Path() (path []*Node)
- type Router
- func (r *Router) Bind(ctx context.Context, network, address string, opts ...connector.BindOption) (ln net.Listener, err error)
- func (r *Router) Dial(ctx context.Context, network, address string) (conn net.Conn, err error)
- func (r *Router) Hosts() hosts.HostMapper
- func (r *Router) WithChain(chain Chainer) *Router
- func (r *Router) WithHosts(hosts hosts.HostMapper) *Router
- func (r *Router) WithInterface(ifceName string) *Router
- func (r *Router) WithLogger(logger logger.Logger) *Router
- func (r *Router) WithResolver(resolver resolver.Resolver) *Router
- func (r *Router) WithRetries(retries int) *Router
- func (r *Router) WithTimeout(timeout time.Duration) *Router
- type Selector
- type Strategy
- type Transport
- func (tr *Transport) Bind(ctx context.Context, conn net.Conn, network, address string, ...) (net.Listener, error)
- func (tr *Transport) Connect(ctx context.Context, conn net.Conn, network, address string) (net.Conn, error)
- func (tr *Transport) Copy() *Transport
- func (tr *Transport) Dial(ctx context.Context, addr string) (net.Conn, error)
- func (tr *Transport) Handshake(ctx context.Context, conn net.Conn) (net.Conn, error)
- func (tr *Transport) Multiplex() bool
- func (tr *Transport) WithAddr(addr string) *Transport
- func (tr *Transport) WithConnector(connector connector.Connector) *Transport
- func (tr *Transport) WithDialer(dialer dialer.Dialer) *Transport
- func (tr *Transport) WithInterface(ifceName string) *Transport
- func (tr *Transport) WithRoute(r *Route) *Transport
Constants ¶
View Source
const (
DefaultFailTimeout = 30 * time.Second
)
default options for FailFilter
Variables ¶
View Source
var (
DefaultSelector = NewSelector(RoundRobinStrategy())
)
View Source
var (
ErrEmptyRoute = errors.New("empty route")
)
Functions ¶
This section is empty.
Types ¶
type Chain ¶
type Chain struct {
// contains filtered or unexported fields
}
func (*Chain) AddNodeGroup ¶
type FailMarker ¶
type FailMarker struct {
// contains filtered or unexported fields
}
func (*FailMarker) FailCount ¶
func (m *FailMarker) FailCount() int64
func (*FailMarker) FailTime ¶
func (m *FailMarker) FailTime() int64
func (*FailMarker) Mark ¶
func (m *FailMarker) Mark()
func (*FailMarker) Reset ¶
func (m *FailMarker) Reset()
type Filter ¶
func FailFilter ¶
FailFilter filters the dead node. A node is marked as dead if its failed count is greater than MaxFails.
func InvalidFilter ¶
func InvalidFilter() Filter
InvalidFilter filters the invalid node. A node is invalid if its port is invalid (negative or zero value).
type Node ¶
type Node struct { Name string Addr string Transport *Transport Bypass bypass.Bypass Resolver resolver.Resolver Hosts hosts.HostMapper Marker *FailMarker }
type NodeGroup ¶
type NodeGroup struct {
// contains filtered or unexported fields
}
func NewNodeGroup ¶
func (*NodeGroup) WithSelector ¶
type Route ¶
type Route struct {
// contains filtered or unexported fields
}
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
func (*Router) Hosts ¶
func (r *Router) Hosts() hosts.HostMapper
func (*Router) WithInterface ¶
func (*Router) WithRetries ¶
type Selector ¶
func NewSelector ¶
type Strategy ¶
func FIFOStrategy ¶
func FIFOStrategy() Strategy
FIFOStrategy is a strategy for node selector. The node will be selected from first to last, and will stick to the selected node until it is failed.
func RandomStrategy ¶
func RandomStrategy() Strategy
RandomStrategy is a strategy for node selector. The node will be selected randomly.
func RoundRobinStrategy ¶
func RoundRobinStrategy() Strategy
RoundRobinStrategy is a strategy for node selector. The node will be selected by round-robin algorithm.
Click to show internal directories.
Click to hide internal directories.