models

package
v0.0.0-...-a9ca43d Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2019 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ActionNothing   = ""
	ActionPending   = "pending"
	ActionPreparing = "preparing"
	ActionPrepared  = "prepared"
	ActionMigrating = "migrating"
	ActionFinished  = "finished"
	ActionSyncing   = "syncing"
)
View Source
const (
	ForwardSync = iota
	ForwardSemiAsync
)
View Source
const CodisDir = "/codis3"
View Source
const JodisDir = "/jodis"
View Source
const MaxGroupId = 9999
View Source
const MaxSlotNum = 1024

Variables

This section is empty.

Functions

func GroupDir

func GroupDir(product string) string

func GroupPath

func GroupPath(product string, gid int) string

func JodisPath

func JodisPath(product string, token string) string

func LockPath

func LockPath(product string) string

func ParseForwardMethod

func ParseForwardMethod(s string) (int, bool)

func ProductDir

func ProductDir(product string) string

func ProxyDir

func ProxyDir(product string) string

func ProxyPath

func ProxyPath(product string, token string) string

func SentinelPath

func SentinelPath(product string) string

func SlotPath

func SlotPath(product string, sid int) string

func ValidateProduct

func ValidateProduct(name string) error

Types

type Client

type Client interface {
	Create(path string, data []byte) error
	Update(path string, data []byte) error
	Delete(path string) error

	Read(path string, must bool) ([]byte, error)
	List(path string, must bool) ([]string, error)

	Close() error

	WatchInOrder(path string) (<-chan struct{}, []string, error)

	CreateEphemeral(path string, data []byte) (<-chan struct{}, error)
	CreateEphemeralInOrder(path string, data []byte) (<-chan struct{}, string, error)
}

func NewClient

func NewClient(coordinator string, addrlist string, auth string, timeout time.Duration) (Client, error)

type Group

type Group struct {
	Id      int            `json:"id"`
	Servers []*GroupServer `json:"servers"`

	Promoting struct {
		Index int    `json:"index,omitempty"`
		State string `json:"state,omitempty"`
	} `json:"promoting"`

	OutOfSync bool `json:"out_of_sync"`
}

func SortGroup

func SortGroup(group map[int]*Group) []*Group

func (*Group) Encode

func (g *Group) Encode() []byte

type GroupServer

type GroupServer struct {
	Addr       string `json:"server"`
	DataCenter string `json:"datacenter"`

	Action struct {
		Index int    `json:"index,omitempty"`
		State string `json:"state,omitempty"`
	} `json:"action"`

	ReplicaGroup bool `json:"replica_group"`
}

type GroupSlice

type GroupSlice []*Group

func (GroupSlice) Len

func (s GroupSlice) Len() int

func (GroupSlice) Less

func (s GroupSlice) Less(i, j int) bool

func (GroupSlice) Swap

func (s GroupSlice) Swap(i, j int)

type Proxy

type Proxy struct {
	Id        int    `json:"id,omitempty"`
	Token     string `json:"token"`
	StartTime string `json:"start_time"`
	AdminAddr string `json:"admin_addr"`

	ProtoType string `json:"proto_type"`
	ProxyAddr string `json:"proxy_addr"`

	JodisPath string `json:"jodis_path,omitempty"`

	ProductName string `json:"product_name"`

	Pid int    `json:"pid"`
	Pwd string `json:"pwd"`
	Sys string `json:"sys"`

	Hostname   string `json:"hostname"`
	DataCenter string `json:"datacenter"`
}

func SortProxy

func SortProxy(proxy map[string]*Proxy) []*Proxy

func (*Proxy) Encode

func (p *Proxy) Encode() []byte

type ProxySlice

type ProxySlice []*Proxy

func (ProxySlice) Len

func (s ProxySlice) Len() int

func (ProxySlice) Less

func (s ProxySlice) Less(i, j int) bool

func (ProxySlice) Swap

func (s ProxySlice) Swap(i, j int)

type Sentinel

type Sentinel struct {
	Servers []string `json:"servers,omitempty"`

	OutOfSync bool `json:"out_of_sync"`
}

func (*Sentinel) Encode

func (p *Sentinel) Encode() []byte

type Slot

type Slot struct {
	Id     int  `json:"id"`
	Locked bool `json:"locked,omitempty"`

	BackendAddr        string `json:"backend_addr,omitempty"`
	BackendAddrGroupId int    `json:"backend_addr_group_id,omitempty"`
	MigrateFrom        string `json:"migrate_from,omitempty"`
	MigrateFromGroupId int    `json:"migrate_from_group_id,omitempty"`

	ForwardMethod int `json:"forward_method,omitempty"`

	ReplicaGroups [][]string `json:"replica_groups,omitempty"`
}

type SlotMapping

type SlotMapping struct {
	Id      int `json:"id"`
	GroupId int `json:"group_id"`

	Action struct {
		Index    int    `json:"index,omitempty"`
		State    string `json:"state,omitempty"`
		TargetId int    `json:"target_id,omitempty"`
	} `json:"action"`
}

func (*SlotMapping) Encode

func (m *SlotMapping) Encode() []byte

type Store

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

func NewStore

func NewStore(client Client, product string) *Store

func (*Store) Acquire

func (s *Store) Acquire(topom *Topom) error

func (*Store) Client

func (s *Store) Client() Client

func (*Store) Close

func (s *Store) Close() error

func (*Store) DeleteGroup

func (s *Store) DeleteGroup(gid int) error

func (*Store) DeleteProxy

func (s *Store) DeleteProxy(token string) error

func (*Store) GroupDir

func (s *Store) GroupDir() string

func (*Store) GroupPath

func (s *Store) GroupPath(gid int) string

func (*Store) ListGroup

func (s *Store) ListGroup() (map[int]*Group, error)

func (*Store) ListProxy

func (s *Store) ListProxy() (map[string]*Proxy, error)

func (*Store) LoadGroup

func (s *Store) LoadGroup(gid int, must bool) (*Group, error)

func (*Store) LoadProxy

func (s *Store) LoadProxy(token string, must bool) (*Proxy, error)

func (*Store) LoadSentinel

func (s *Store) LoadSentinel(must bool) (*Sentinel, error)

func (*Store) LoadSlotMapping

func (s *Store) LoadSlotMapping(sid int, must bool) (*SlotMapping, error)

func (*Store) LoadTopom

func (s *Store) LoadTopom(must bool) (*Topom, error)

func (*Store) LockPath

func (s *Store) LockPath() string

func (*Store) ProxyDir

func (s *Store) ProxyDir() string

func (*Store) ProxyPath

func (s *Store) ProxyPath(token string) string

func (*Store) Release

func (s *Store) Release() error

func (*Store) SentinelPath

func (s *Store) SentinelPath() string

func (*Store) SlotMappings

func (s *Store) SlotMappings() ([]*SlotMapping, error)

func (*Store) SlotPath

func (s *Store) SlotPath(sid int) string

func (*Store) UpdateGroup

func (s *Store) UpdateGroup(g *Group) error

func (*Store) UpdateProxy

func (s *Store) UpdateProxy(p *Proxy) error

func (*Store) UpdateSentinel

func (s *Store) UpdateSentinel(p *Sentinel) error

func (*Store) UpdateSlotMapping

func (s *Store) UpdateSlotMapping(m *SlotMapping) error

type Topom

type Topom struct {
	Token     string `json:"token"`
	StartTime string `json:"start_time"`
	AdminAddr string `json:"admin_addr"`

	ProductName string `json:"product_name"`

	Pid int    `json:"pid"`
	Pwd string `json:"pwd"`
	Sys string `json:"sys"`
}

func LoadTopom

func LoadTopom(client Client, product string, must bool) (*Topom, error)

func (*Topom) Encode

func (t *Topom) Encode() []byte

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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