api

package
v0.0.0-...-ab7c989 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2021 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CompleteCallback

type CompleteCallback func()

type LoadBalancer

type LoadBalancer interface {
	Strategy(config *ProxyConfig) Next
}

type Next

type Next func() (*RsNode, error)

type NextConn

type NextConn func() (net.Conn, error)

type Option

type Option func(*Options)

type Options

type Options struct {
	Proxy           ProxyConfig
	Lb              LoadBalancer
	RunnableFactory RunnableFactory
}

type ProxyConfig

type ProxyConfig struct {
	// proxy机器启动的本地监听地址,如":8080",如果未指定,则随机一个可用端口
	DsAddr string
	// 后端服务列表(real server)
	Rss []*RsNode
	Ctx context.Context
}

type RsNode

type RsNode struct {
	Addr     string
	Weight   int
	Metadata map[string]string
}

type Runnable

type Runnable interface {
	Run(CompleteCallback) error
	Interrupt()
}

type RunnableFactory

type RunnableFactory func(rw net.Conn, next NextConn) Runnable

type Server

type Server interface {
	Options() Options
	Init(...Option) error
	// add real server
	AddRs(rs ...*RsNode) error
	// del real server
	DelRs(addr ...*RsNode) error
	// 启动
	Start() error
	Stop() error
}

Jump to

Keyboard shortcuts

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