Documentation
¶
Index ¶
- Constants
- Variables
- func DBKeyBody(id int64) string
- func DBKeyId(id int64) string
- func DBKeyName(name string) string
- func FailServerKey(nodeID uint64) string
- func HasPrivi(userPrivi UserPrivi, checkPrivi UserPrivi) bool
- func LockSpaceKey(db, space string) string
- func PartitionKey(partitionID uint32) string
- func RouterKey(key, value string) string
- func ServerKey(name NodeID) string
- func SpaceKey(dbID, spaceId int64) string
- func UnmarshalPropertyJSON(propertity []byte) (map[string]*SpaceProperties, error)
- func UserKey(username string) string
- type BuildVersion
- type CacheModel
- type ChangeMember
- type DB
- type DBID
- type DBModify
- type Engine
- type EngineCfg
- type FailServer
- type FieldOption
- type FieldType
- type FlushEntity
- type NodeID
- type Partition
- type PartitionForSearch
- type PartitionID
- type PartitionInfo
- type PartitionStatus
- type RecoverFailServer
- type Replica
- type RetrievalParam
- type RetrievalParams
- type Server
- type SlotID
- type Space
- type SpaceID
- type SpaceProperties
- type User
- type UserPrivi
- type Version
Constants ¶
const ( NodeIdSequence = "/id/node" SpaceIdSequence = "/id/space" DBIdSequence = "/id/db" PartitionIdSequence = "/id/partition" )
ids sequence key for etcd
const ( PrefixUser = "/user/" PrefixLock = "/lock/" PrefixLockCluster = "/lock/_cluster" PrefixServer = "/server/" PrefixSpace = "/space/" PrefixPartition = "/partition/" PrefixDataBase = "/db/" PrefixDataBaseBody = "/db/body/" PrefixFailServer = "/fail/server/" PrefixRouter = "/router/" )
const ( ReplicasOK = 1 ReplicasNotReady = 2 )
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
const ClusterWatchServerKey = "watch/server"
ClusterWatchServerKey for server job lock
const (
Gamma = "gamma"
)
Variables ¶
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 FailServerKey ¶
FailServerKey generate fail server key
func LockSpaceKey ¶
func PartitionKey ¶
func UnmarshalPropertyJSON ¶
func UnmarshalPropertyJSON(propertity []byte) (map[string]*SpaceProperties, error)
Types ¶
type BuildVersion ¶
type CacheModel ¶
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]
type DBModify ¶
type DBModify struct {
DbName string `json:"db_name"`
SpaceName string `json:"space_name"`
IPAddr string `json:"ip_addr"`
Method proto.ConfChangeType `json:"method"`
}
RecoverFailServer use for recover fail server
type Engine ¶
type Engine struct {
Name string `json:"name"`
IndexSize int64 `json:"index_size"`
MetricType string `json:"metric_type,omitempty"`
RetrievalType string `json:"retrieval_type,omitempty"`
RetrievalTypes []string `json:"retrieval_types,omitempty"`
RetrievalParam json.RawMessage `json:"retrieval_param,omitempty"`
RetrievalParams json.RawMessage `json:"retrieval_params,omitempty"`
IdType string `json:"id_type,omitempty"`
}
func NewDefaultEngine ¶
func NewDefaultEngine() *Engine
func (*Engine) UnmarshalJSON ¶
type EngineCfg ¶
type EngineCfg struct {
CacheModels []*CacheModel `json:"cache_models,omitempty"`
}
cache/[dbId]/[spaceId]:[cacheCfg]
type FailServer ¶
type FailServer struct {
ID NodeID `json:"nodeID,omitempty"` //unique name for raft
TimeStamp int64 `json:"time_stamp,omitempty"`
Node *Server `json:"server,omitempty"`
}
FailServer /fail/server/id:[body] ttl 3m 3s
type FieldOption ¶
type FieldOption int32
const ( FieldOption_Null FieldOption = 0 FieldOption_Index FieldOption = 1 FieldOption_Index_False FieldOption = 2 )
type FlushEntity ¶
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:"-"`
ReStatusMap map[uint64]uint32 `json:"status,omitempty"` //leader in replicas
// 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 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"`
RepStatus map[NodeID]string `json:"replica_status,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"`
RaftStatus *raft.Status `json:"raft_status,omitempty"`
IndexStatus int `json:"index_status"`
Error string `json:"error,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 RecoverFailServer ¶
type RecoverFailServer struct {
FailNodeID NodeID `json:"fail_node_id"`
NewNodeID NodeID `json:"new_node_id"`
FailNodeAddr string `json:"fail_node_addr"`
NewNodeAddr string `json:"new_node_addr"`
}
RecoverFailServer use for recover fail server
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
type RetrievalParam ¶
type RetrievalParams ¶
type RetrievalParams struct {
RetrievalParamArr []RetrievalParam `json:"retrieval_params,omitempty"`
}
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
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
SpaceProperties map[string]*SpaceProperties `json:"space_properties"`
}
space/[dbId]/[spaceId]:[spaceBody]
func (*Space) GetPartition ¶
func (this *Space) GetPartition(id PartitionID) *Partition
func (*Space) PartitionId ¶
func (this *Space) PartitionId(slotID SlotID) PartitionID
type SpaceProperties ¶
type SpaceProperties struct {
FieldType FieldType `json:"field_type"`
Type string `json:"type"`
Index *bool `json:"index,omitempty"`
Format *string `json:"format,omitempty"`
Dimension int `json:"dimension,omitempty"`
ModelId string `json:"model_id,omitempty"`
StoreType *string `json:"store_type,omitempty"`
StoreParam json.RawMessage `json:"store_param,omitempty"`
Array bool `json:"array,omitempty"`
HasSource bool `json:"has_source,omitempty"`
Option FieldOption `json:"option,omitempty"`
}
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 )