proxy

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2018 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrConfigServerFormat = errs.New("servers config format error")
	ErrExecutorHashNoNode = errs.New("executor hash no hit node")
	ErrExecutorClosed     = errs.New("executor already closed")
)

errors

View Source
var (
	ErrProxyMoreMaxConns = errs.New("Proxy accept more than max connextions")
)

proxy errors

Functions

func Listen

func Listen(proto string, addr string) (net.Listener, error)

Listen listen.

func NewExecutor added in v1.3.2

func NewExecutor(cc *ClusterConfig) (c proto.Executor)

NewExecutor new a executor by cluster config.

Types

type ClusterConfig

type ClusterConfig struct {
	Name             string
	HashMethod       string          `toml:"hash_method"`
	HashDistribution string          `toml:"hash_distribution"`
	HashTag          string          `toml:"hash_tag"`
	CacheType        proto.CacheType `toml:"cache_type"`
	ListenProto      string          `toml:"listen_proto"`
	ListenAddr       string          `toml:"listen_addr"`
	RedisAuth        string          `toml:"redis_auth"`
	DialTimeout      int             `toml:"dial_timeout"`
	ReadTimeout      int             `toml:"read_timeout"`
	WriteTimeout     int             `toml:"write_timeout"`
	NodeConnections  int32           `toml:"node_connections"`
	PingFailLimit    int             `toml:"ping_fail_limit"`
	PingAutoEject    bool            `toml:"ping_auto_eject"`
	Servers          []string
}

ClusterConfig cluster config.

func (*ClusterConfig) Validate

func (cc *ClusterConfig) Validate() error

Validate validate config field value.

type ClusterConfigs

type ClusterConfigs struct {
	Clusters []*ClusterConfig
}

ClusterConfigs cluster configs.

func (*ClusterConfigs) LoadFromFile

func (ccs *ClusterConfigs) LoadFromFile(path string) error

LoadFromFile load from file.

type Config

type Config struct {
	Pprof string
	Debug bool
	Log   string
	LogVL int `toml:"log_vl"`
	Proxy struct {
		ReadTimeout    int   `toml:"read_timeout"`
		WriteTimeout   int   `toml:"write_timeout"`
		MaxConnections int32 `toml:"max_connections"`
		UseMetrics     bool  `toml:"use_metrics"`
	}
}

Config proxy config.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig new config by defalut string.

func (*Config) LoadFromFile

func (c *Config) LoadFromFile(path string) error

LoadFromFile load from file.

func (*Config) Validate

func (c *Config) Validate() error

Validate validate config field value.

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler handle conn.

func NewHandler

func NewHandler(p *Proxy, cc *ClusterConfig, conn net.Conn, executor proto.Executor) (h *Handler)

NewHandler new a conn handler.

func (*Handler) Handle

func (h *Handler) Handle()

Handle reads Msg from client connection and dispatchs Msg back to cache servers, then reads response from cache server and writes response into client connection.

type Proxy

type Proxy struct {
	// contains filtered or unexported fields
}

Proxy is proxy.

func New

func New(c *Config) (p *Proxy, err error)

New new a proxy by config.

func (*Proxy) Close

func (p *Proxy) Close() error

Close close proxy resource.

func (*Proxy) Serve

func (p *Proxy) Serve(ccs []*ClusterConfig)

Serve is the main accept() loop of a server.

Jump to

Keyboard shortcuts

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