entity

package
v3.2.7+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2021 License: Apache-2.0, MIT Imports: 13 Imported by: 14

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/"
	PrefixFailServer   = "/fail/server/"
	PrefixRouter       = "/router/"
)
View Source
const (
	ReplicasOK       = 1
	ReplicasNotReady = 2
)
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 ClusterWatchServerKey = "watch/server"

ClusterWatchServerKey for server job lock

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 FailServerKey

func FailServerKey(nodeID uint64) string

FailServerKey generate fail server key

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 RouterKey

func RouterKey(key, value string) string

RouterKey Router key

func ServerKey

func ServerKey(name NodeID) string

func SpaceKey

func SpaceKey(dbID, spaceId int64) string

func UnmarshalPropertyJSON

func UnmarshalPropertyJSON(propertity []byte) (map[string]*SpaceProperties, error)

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 CacheModel

type CacheModel struct {
	Name      string `json:"name,omitempty"` //user setting
	CacheSize int32  `json:"cache_size,omitempty"`
}

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 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

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

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 FieldType

type FieldType int32
const (
	FieldType_INT FieldType = iota
	FieldType_LONG
	FieldType_FLOAT
	FieldType_DOUBLE
	FieldType_STRING
	FieldType_VECTOR
	FieldType_BOOL
	FieldType_GEOPOINT
	FieldType_DATE
)

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:"-"`

	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 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"`
	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

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 RetrievalParam

type RetrievalParam struct {
	Nlinks         int    `json:"nlinks"`
	EfSearch       int    `json:"efSearch"`
	EfConstruction int    `json:"efConstruction"`
	MetricType     string `json:"metric_type,omitempty"`
	Ncentroids     int    `json:"ncentroids"`
	Nprobe         int    `json:"nprobe"`
	Nsubvector     int    `json:"nsubvector"`
}

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

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
	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

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 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 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