Documentation ¶
Index ¶
- Constants
- Variables
- func NewMapStore() *mapStore
- func WriteFull(w io.Writer, buf []byte) error
- type AutoScheduler
- type Client
- func (c *Client) Append(key string, value []byte) (ok bool, targets []string, final_err error)
- func (c *Client) Delete(key string) (r bool, targets []string, err error)
- func (c *Client) Get(key string) (r *Item, targets []string, err error)
- func (c *Client) GetMulti(keys []string) (rs map[string]*Item, targets []string, err error)
- func (c *Client) Incr(key string, value int) (result int, targets []string, err error)
- func (c *Client) Len() int
- func (c *Client) Set(key string, item *Item, noreply bool) (ok bool, targets []string, final_err error)
- type ConsistantHashScheduler
- type DistributeStorage
- type Feedback
- type HashMethod
- type Host
- func (host *Host) Append(key string, value []byte) (bool, error)
- func (host *Host) Close()
- func (host *Host) Delete(key string) (bool, error)
- func (host *Host) Get(key string) (*Item, error)
- func (host *Host) GetMulti(keys []string) (map[string]*Item, error)
- func (host *Host) Incr(key string, value int) (int, error)
- func (host *Host) Len() int
- func (host *Host) Set(key string, item *Item, noreply bool) (bool, error)
- func (host *Host) Stat(keys []string) (map[string]string, error)
- type Item
- type ManualScheduler
- type ModScheduler
- type RClient
- func (c *RClient) Append(key string, value []byte) (ok bool, targets []string, final_err error)
- func (c *RClient) Delete(key string) (r bool, targets []string, err error)
- func (c *RClient) Get(key string) (r *Item, targets []string, err error)
- func (c *RClient) GetMulti(keys []string) (rs map[string]*Item, targets []string, err error)
- func (c *RClient) Incr(key string, value int) (result int, target []string, err error)
- func (c *RClient) Len() int
- func (c *RClient) Set(key string, item *Item, noreply bool) (ok bool, targets []string, final_err error)
- type Request
- func (req *Request) Check(resp *Response) error
- func (req *Request) Clear()
- func (req *Request) Process(store DistributeStorage, stat *Stats) (resp *Response, targets []string, err error)
- func (req *Request) Read(b *bufio.Reader) (e error)
- func (req *Request) String() (s string)
- func (req *Request) Write(w io.Writer) (e error)
- type Response
- type Scheduler
- type Stats
- type StdLogger
- type Storage
Constants ¶
View Source
const ( MaxKeyLength = 200 MaxBodyLength = 1024 * 1024 * 50 )
View Source
const FNV1A_INIT uint32 = 0x811c9dc5
View Source
const FNV1A_PRIME uint32 = 0x01000193
View Source
const VERSION = "0.1.0"
View Source
const VIRTUAL_NODES = 100
Variables ¶
View Source
var ConnectTimeout time.Duration = time.Millisecond * 300
View Source
var MaxFreeConns = 20
View Source
var ReadTimeout time.Duration = time.Millisecond * 2000
View Source
var WriteTimeout time.Duration = time.Millisecond * 2000
Functions ¶
func NewMapStore ¶
func NewMapStore() *mapStore
Types ¶
type AutoScheduler ¶
type AutoScheduler struct {
// contains filtered or unexported fields
}
route requests by auto discoved infomation, used in beansdb
func NewAutoScheduler ¶
func NewAutoScheduler(config []string, bs int) *AutoScheduler
func (*AutoScheduler) DivideKeysByBucket ¶
func (c *AutoScheduler) DivideKeysByBucket(keys []string) [][]string
func (*AutoScheduler) Feedback ¶
func (c *AutoScheduler) Feedback(host *Host, key string, adjust float64)
func (*AutoScheduler) GetHostsByKey ¶
func (c *AutoScheduler) GetHostsByKey(key string) []*Host
func (*AutoScheduler) Stats ¶
func (c *AutoScheduler) Stats() map[string][]float64
type Client ¶
type Client struct {
N, W, R int
// contains filtered or unexported fields
}
Client of memcached
type ConsistantHashScheduler ¶
type ConsistantHashScheduler struct {
// contains filtered or unexported fields
}
ConsistantHashScheduler route requests by consistant hash
func (*ConsistantHashScheduler) DivideKeysByBucket ¶
func (c *ConsistantHashScheduler) DivideKeysByBucket(keys []string) [][]string
func (*ConsistantHashScheduler) GetHostsByKey ¶
func (c *ConsistantHashScheduler) GetHostsByKey(key string) []*Host
type DistributeStorage ¶
type DistributeStorage interface { Get(key string) (*Item, []string, error) GetMulti(keys []string) (map[string]*Item, []string, error) Set(key string, item *Item, noreply bool) (bool, []string, error) Append(key string, value []byte) (bool, []string, error) Incr(key string, value int) (int, []string, error) Delete(key string) (bool, []string, error) Len() int }
type HashMethod ¶
type ManualScheduler ¶
type ManualScheduler struct { N int // contains filtered or unexported fields }
ManualScheduler route request by configure by hand
func NewManualScheduler ¶
func NewManualScheduler(config map[string][]string, bs, n int) *ManualScheduler
NewManualScheduler the string is a Hex int string, if it start with -, it means serve the bucket as a backup
func (*ManualScheduler) DivideKeysByBucket ¶
func (c *ManualScheduler) DivideKeysByBucket(keys []string) [][]string
func (*ManualScheduler) Feedback ¶
func (c *ManualScheduler) Feedback(host *Host, key string, adjust float64)
func (*ManualScheduler) GetHostsByKey ¶
func (c *ManualScheduler) GetHostsByKey(key string) (hosts []*Host)
func (*ManualScheduler) Stats ¶
func (c *ManualScheduler) Stats() map[string][]float64
type ModScheduler ¶
type ModScheduler struct {
// contains filtered or unexported fields
}
ModScheduler route request by Mod of HASH
func (*ModScheduler) DivideKeysByBucket ¶
func (c *ModScheduler) DivideKeysByBucket(keys []string) [][]string
func (*ModScheduler) GetHostsByKey ¶
func (c *ModScheduler) GetHostsByKey(key string) []*Host
type RClient ¶
type RClient struct {
N, W, R int
// contains filtered or unexported fields
}
func NewRClient ¶
type Request ¶
type Request struct { Cmd string // get, set, delete, quit, etc. Keys []string // keys Item *Item NoReply bool }
type Response ¶
type Response struct {
// contains filtered or unexported fields
}
func (*Response) CleanBuffer ¶
func (resp *Response) CleanBuffer()
type Scheduler ¶
type Scheduler interface { Feedback(host *Host, key string, adjust float64) // feedback for auto routing GetHostsByKey(key string) []*Host // route a key to hosts DivideKeysByBucket(keys []string) [][]string // route some keys to group of hosts Stats() map[string][]float64 // internal status }
Scheduler : route request to nodes
func NewModScheduler ¶
type Stats ¶
type Stats struct {
// contains filtered or unexported fields
}
func (*Stats) UpdateStat ¶
type StdLogger ¶
type StdLogger interface { Print(v ...interface{}) Printf(format string, v ...interface{}) Println(v ...interface{}) }
Click to show internal directories.
Click to hide internal directories.