config

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: May 26, 2020 License: BSD-3-Clause Imports: 9 Imported by: 7

Documentation

Index

Constants

View Source
const AccessLogVersion = "V1"
View Source
const AnalysisLogVersion = "V2"

Variables

View Source
var (
	ServerConf  ServerConfig = DefaultServerConfig
	Route       RouteTable
	MCConf      MCConfig = DefaultMCConfig
	AllowReload bool
)
View Source
var (
	ZKClient       *zkClient
	LocalRoutePath string
)
View Source
var (
	DefaultMCConfig = MCConfig{
		MaxReq:      16,
		MaxKeyLen:   250,
		BodyMaxStr:  "50M",
		BodyBigStr:  "1M",
		BodyInCStr:  "4K",
		FlushMaxStr: "100M",
		TimeoutMS:   3000,
	}
)
View Source
var DefaultRouteConfig = DBRouteConfig{NumBucket: 16, BucketsStat: make([]int, 16)}

DefaultRouteConfig = route.RouteConfig{NumBucket: 256, Buckets: make([]int, 256)}

View Source
var (
	DefaultServerConfig = ServerConfig{
		Hostname:  "127.0.0.1",
		Listen:    "0.0.0.0",
		Port:      7900,
		WebPort:   7903,
		Threads:   4,
		ZKServers: nil,
		ErrorLog:  "./gobeansdb.log",
		AccessLog: "",
		StaticDir: "./",
	}
)
View Source
var Version = "2.1.0.18"

`Version` can be changed in gobeansproxy.

Functions

func BucketIDHex

func BucketIDHex(id, numBucket int) string

func DumpConfig

func DumpConfig(config interface{})

func IsValidKeySize

func IsValidKeySize(ksz uint32) bool

func IsValidValueSize

func IsValidValueSize(vsz uint32) bool

func LoadYamlConfig

func LoadYamlConfig(config interface{}, path string) error

func NewZK

func NewZK(root string, servers []string) (c *zkClient, err error)

func UpdateLocalRoute

func UpdateLocalRoute(content []byte)

Types

type DBRouteConfig

type DBRouteConfig struct {
	NumBucket   int
	BucketsStat []int `json:"Buckets"` // TODO: `json:"-"`
	BucketsHex  []string
}

type MCConfig

type MCConfig struct {
	MaxKeyLen int `yaml:"max_key_len,omitempty"`
	MaxReq    int `yaml:"max_req,omitempty"` // max num of requsets serve at the same time

	BodyMax int64 `yaml:"-"` // fail set/read_file if larger then this
	BodyBig int64 `yaml:"-"` // set may fail if memory is in shorage (determine by "storage")
	BodyInC int64 `yaml:"-"` // alloc body in cgo if larger then this

	FlushMax int64 `yaml:"-"` // if flush buffer is larger, may fail BIG set request (return NOT_FOUND)

	FlushMaxStr string `yaml:"flush_max_str"`
	BodyMaxStr  string `yaml:"body_max_str,omitempty"`
	BodyBigStr  string `yaml:"body_big_str,omitempty"`

	BodyInCStr string `yaml:"body_c_str,omitempty"`
	TimeoutMS  int    `yaml:"timeout_ms,omitempty"`
}

type RouteTable

type RouteTable struct {
	NumBucket int
	Main      []Server
	Backup    []string

	Buckets map[int]map[string]bool `yaml:"-"`
	Servers map[string]map[int]bool `yaml:"-"`
}

func LoadRouteTableLocal

func LoadRouteTableLocal(path string) (*RouteTable, error)

func LoadRouteTableZK

func LoadRouteTableZK(path, cluster string, zkservers []string) (*RouteTable, error)

func (*RouteTable) GetDBRouteConfig

func (rt *RouteTable) GetDBRouteConfig(addr string) (r DBRouteConfig)

func (*RouteTable) LoadFromYaml

func (rt *RouteTable) LoadFromYaml(data []byte) error

type Server

type Server struct {
	Addr       string
	Buckets    []int    `yaml:"-"`
	BucketsHex []string `yaml:"buckets,flow"`
}

func (*Server) Decode

func (s *Server) Decode() error

type ServerConfig

type ServerConfig struct {
	Hostname    string   `yaml:",omitempty"`
	ZKPath      string   `yaml:",omitempty"` // root path in zk
	ZKServers   []string `yaml:",omitempty"` // e.g. "zk1:2181,zk2:2181"
	Listen      string   `yaml:",omitempty"` // ip
	Port        int      `yaml:",omitempty"`
	WebPort     int      `yaml:",omitempty"`
	Threads     int      `yaml:",omitempty"` // NumCPU
	ErrorLog    string   `yaml:",omitempty"`
	AccessLog   string   `yaml:",omitempty"`
	AnalysisLog string   `yaml:",omitempty"`
	StaticDir   string   `yaml:",omitempty"` // directory for static files, e.g. *.html

}

func (*ServerConfig) Addr

func (c *ServerConfig) Addr() string

Jump to

Keyboard shortcuts

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