proxy

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2018 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrClusterServerFormat = errs.New("cluster servers format error")
	ErrClusterHashNoNode   = errs.New("cluster hash no hit node")
)

cluster 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.

Types

type Cluster

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

Cluster is cache cluster.

func NewCluster

func NewCluster(ctx context.Context, cc *ClusterConfig) (c *Cluster)

NewCluster new a cluster by cluster config.

func (*Cluster) Close

func (c *Cluster) Close() error

Close closes resources.

func (*Cluster) DispatchBatch

func (c *Cluster) DispatchBatch(mbs []*proto.MsgBatch, slice []*proto.Message)

DispatchBatch delivers all the messages to batch execute by hash

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(ctx context.Context, c *Config, conn net.Conn, cluster *Cluster) (h *Handler)

NewHandler new a conn handler.

func (*Handler) Closed

func (h *Handler) Closed() bool

Closed return handler whether or not closed.

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