entity

package
v0.0.0-...-7b3ddb2 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2019 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NodeIdSequence      = "/id/node"
	SpaceIdSequence     = "/id/space"
	DBIdSequence        = "/id/db"
	PartitionIdSequence = "/id/partition"
)

ids sequence key for etcd

View Source
const (
	PrefixUser         = "/user/"
	PrefixLock         = "/lock/"
	PrefixLockCluster  = "/lock/_cluster"
	PrefixServer       = "/server/"
	PrefixSpace        = "/space/"
	PrefixPartition    = "/partition/"
	PrefixDataBase     = "/db/"
	PrefixDataBaseBody = "/db/body/"
)
View Source
const ClusterCleanJobKey = "/cluster/cleanjob"

when master runing clean job , it will set value to this key, when other got key , now time less than this they will skip this job

View Source
const (
	Gamma = "gamma"
)

Variables

View Source
var PriviMap = map[string]UserPrivi{
	"select": PrivilegeSelect,
	"insert": PrivilegeInsert,
	"update": PrivilegeUpdate,
	"delete": PrivilegeDelete,

	"create":   PrivilegeCreate,
	"alter":    PrivilegeAlter,
	"drop":     PrivilegeDrop,
	"truncate": PrivilegeTruncate,

	"grant": PrivilegeGrant,
}

Functions

func DBKeyBody

func DBKeyBody(id int64) string

func DBKeyId

func DBKeyId(id int64) string

func DBKeyName

func DBKeyName(name string) string

func HasPrivi

func HasPrivi(userPrivi UserPrivi, checkPrivi UserPrivi) bool

func LockSpaceKey

func LockSpaceKey(db, space string) string

func PartitionKey

func PartitionKey(partitionID uint32) string

func ServerKey

func ServerKey(name NodeID) string

func SpaceKey

func SpaceKey(dbID, spaceId int64) string

func UserKey

func UserKey(username string) string

Types

type BuildVersion

type BuildVersion struct {
	BuildVersion string `json:"build_version"`
	BuildTime    string `json:"build_time"`
	CommitID     string `json:"commit_id"`
}

type ChangeMember

type ChangeMember struct {
	PartitionID PartitionID          `json:"partition_id"`
	NodeID      NodeID               `json:"node_id"`
	Method      proto.ConfChangeType `json:"method"`
}

type DB

type DB struct {
	Id   DBID     `json:"id,omitempty"`
	Name string   `json:"name,omitempty"`
	Ps   []string `json:"ps,omitempty"` //if set this , your db only use you config ps
}

db/id/[dbId]:[dbName] db/name/[dbName]:[dbId] db/body/[dbId]:[dbBody]

func (*DB) Validate

func (db *DB) Validate() error

type DBID

type DBID = int64

DBID is a custom type for database ID

type Engine

type Engine struct {
	Name        string `json:"name"`
	IndexSize   int64  `json:"index_size"`
	MaxSize     int64  `json:"max_size"`
	Nprobe      *int   `json:"nprobe,omitempty"`
	MetricType  *int   `json:"metric_type,omitempty"`
	Ncentroids  *int   `json:"ncentroids,omitempty"`
	Nsubvector  *int   `json:"nsubvector,omitempty"`
	NbitsPerIdx *int   `json:"nbits_per_idx,omitempty"`
}

func NewDefaultEngine

func NewDefaultEngine() *Engine

func (*Engine) UnmarshalJSON

func (engine *Engine) UnmarshalJSON(bs []byte) error

type FlushEntity

type FlushEntity struct {
	F      func() error
	FlushC chan error
}

type NodeID

type NodeID = uint64

node id for ps

type Partition

type Partition struct {
	Id      PartitionID `json:"id,omitempty"`
	SpaceId SpaceID     `json:"space_id,omitempty"`
	DBId    DBID        `json:"db_id,omitempty"`
	//Slot stores the lower limit of the slot range
	Slot       SlotID   `json:"partition_slot"`
	LeaderID   NodeID   `json:"leader_name,omitempty"`
	Replicas   []NodeID `json:"replicas,omitempty"` //leader in replicas
	UpdateTime int64    `json:"update_time,omitempty"`
	Path       string   `json:"-"`
	// contains filtered or unexported fields
}

partition/[id]:[body]

func (*Partition) GetStatus

func (p *Partition) GetStatus() PartitionStatus

this is safe method for get status

func (*Partition) SetStatus

func (p *Partition) SetStatus(s PartitionStatus)

this is safe method for set status

type PartitionForSearch

type PartitionForSearch struct {
	*Partition
	DBName, SpaceName string
}

type PartitionID

type PartitionID = uint32

PartitionID is a custom type for partition ID

type PartitionInfo

type PartitionInfo struct {
	PartitionID PartitionID     `json:"pid,omitempty"`
	DocNum      uint64          `json:"doc_num,omitempty"`
	Size        int64           `json:"size,omitempty"`
	ReplicaNum  int             `json:"replica_num,omitempty"`
	Path        string          `json:"path,omitempty"`
	Unreachable []uint64        `json:"unreachable,omitempty"`
	Status      PartitionStatus `json:"status,omitempty"`
	Color       string          `json:"color,omitempty"`
	Ip          string          `json:"ip,omitempty"`
	NodeID      uint64          `json:"node_id,omitempty"`
}

get partition from every partitions

type PartitionStatus

type PartitionStatus uint8
const (
	PA_UNKNOW PartitionStatus = iota
	PA_INVALID
	PA_CLOSED
	PA_READONLY
	PA_READWRITE
)

type Replica

type Replica struct {
	NodeID        NodeID `json:"nodeID,omitempty"`
	HeartbeatAddr string `json:"heartbeat_addr,omitempty"`
	ReplicateAddr string `json:"replicate_addr,omitempty"`
	RpcAddr       string `json:"rpc_addr,omitempty"`
}

it use for raft add or remove node

func (*Replica) Marshal

func (m *Replica) Marshal() ([]byte, error)

func (Replica) String

func (m Replica) String() string

func (*Replica) Unmarshal

func (m *Replica) Unmarshal(dAtA []byte) error

type Server

type Server struct {
	ID                NodeID        `json:"name,omitempty"` //unique name for raft
	RpcPort           uint16        `json:"rpc_port"`
	RaftHeartbeatPort uint16        `json:"raft_heartbeat_port"`
	RaftReplicatePort uint16        `json:"raft_replicate_port"`
	Ip                string        `json:"ip,omitempty"`
	PartitionIds      []PartitionID `json:"p_ids,omitempty"`
	Size              uint64        `json:"size,omitempty"`
	Private           bool          `json:"private"`
	Version           *BuildVersion `json:"version"`
}

server/id:[body] ttl 3m 3s

func (*Server) Replica

func (s *Server) Replica() *Replica

func (*Server) RpcAddr

func (s *Server) RpcAddr() string

type SlotID

type SlotID = uint32

SlotID is a custom type for slot ID

type Space

type Space struct {
	Id           SpaceID         `json:"id,omitempty"`
	Name         string          `json:"name,omitempty"` //user setting
	Version      Version         `json:"version,omitempty"`
	DBId         DBID            `json:"db_id,omitempty"`
	Enabled      *bool           `json:"enabled"`    //Enabled flag whether the space can work
	Partitions   []*Partition    `json:"partitions"` // partitionids not sorted
	PartitionNum int             `json:"partition_num"`
	ReplicaNum   uint8           `json:"replica_num"`
	Properties   json.RawMessage `json:"properties"`
	Engine       *Engine         `json:"engine"`
	Models       json.RawMessage `json:"models,omitempty"` //json model config for python plugin

}

space/[dbId]/[spaceId]:[spaceBody]

func (*Space) GetPartition

func (this *Space) GetPartition(id PartitionID) *Partition

func (*Space) PartitionId

func (this *Space) PartitionId(slotID SlotID) PartitionID

func (*Space) String

func (this *Space) String() string

func (*Space) Validate

func (space *Space) Validate() error

check params is ok

type SpaceID

type SpaceID = int64

SpaceID is a custom type for space ID

type User

type User struct {
	Name        string
	Password    string
	AllowedHost string
	Privi       UserPrivi
	UserDB      map[string]struct{}
	HeadKey     string
}

type UserPrivi

type UserPrivi uint64
const (
	PrivilegeNone     UserPrivi = 0
	PrivilegeSelect   UserPrivi = 1
	PrivilegeInsert   UserPrivi = 1 << 1
	PrivilegeUpdate   UserPrivi = 1 << 2
	PrivilegeDelete   UserPrivi = 1 << 3
	PrivilegeCreate   UserPrivi = 1 << 4
	PrivilegeAlter    UserPrivi = 1 << 5
	PrivilegeDrop     UserPrivi = 1 << 6
	PrivilegeTruncate UserPrivi = 1 << 7
	PrivilegeGrant    UserPrivi = 1 << 8
)

func LackPrivi

func LackPrivi(userPrivi UserPrivi, checkPrivi UserPrivi) UserPrivi

func (UserPrivi) String

func (userPrivi UserPrivi) String() string

type Version

type Version = uint64

Version is a custom type for Partition

Jump to

Keyboard shortcuts

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