Documentation
¶
Index ¶
- Constants
- Variables
- func AliasKey(aliasName string) string
- func DBKeyBody(id int64) string
- func DBKeyId(id int64) string
- func DBKeyName(name string) string
- func FailServerKey(nodeID uint64) string
- func HasPrivi(userPrivi PrivilegeType, checkPrivi PrivilegeType) bool
- func LockAliasKey(aliasName string) string
- func LockDBKey(db string) string
- func LockRoleKey(rolename string) string
- func LockSpaceKey(db, space string) string
- func LockUserKey(username string) string
- func MasterMemberKey(ID uint64) string
- func ParseResources(endpoint string, method string) (resource Resource, privilege Privilege)
- func PartitionKey(partitionID uint32) string
- func RoleKey(rolename string) string
- func RouterConfigKey(key string) string
- func RouterKey(key, value string) string
- func ServerKey(name NodeID) string
- func SetPrefixAndSequence(cluster_id string)
- func SetRequestLimit(router *RouterLimitCfg)
- func SetRouterCount(add bool)
- func SpaceConfigKey(dbID, spaceId int64) string
- func SpaceKey(dbID, spaceId int64) string
- func ToTimestamp(value string) (int64, error)
- func UnmarshalPropertyJSON(propertity []byte) (map[string]*SpaceProperties, error)
- func UserKey(username string) string
- func ValidateName(name string, name_type NameType, check_root bool) error
- type AddMemberRequest
- type Alias
- type BackupSpaceRequest
- type BackupSpaceResponse
- type BuildVersion
- type CTX_KEY
- type ChangeMember
- type ChangeMembers
- type DB
- type DBID
- type DBModify
- type EngineStatus
- type FailServer
- type Field
- type FlushEntity
- type Index
- type IndexParams
- type List
- type MemberInfoRequest
- type NameType
- type NodeID
- type OperatorType
- type Partition
- type PartitionForSearch
- type PartitionID
- type PartitionInfo
- type PartitionRule
- type PartitionStatus
- type PartitionType
- type Privilege
- type PrivilegeType
- type Range
- type RecoverFailServer
- type Replica
- type Resource
- type ResourceLimit
- type Role
- type Router
- type RouterLimitCfg
- type Server
- type SlotID
- type Space
- type SpaceConfig
- type SpaceID
- type SpaceInfo
- type SpaceProperties
- type SpaceSchema
- type User
- type UserRole
- type Version
Constants ¶
const ( ReplicasOK = 1 ReplicasNotReady = 2 )
const ( Drop string = "DROP" Add string = "ADD" )
const ( ReplicaStateProbe = "ReplicaStateProbe" ReplicaStateReplicate = "ReplicaStateReplicate" )
const ( Create = 0 Restore = 1 )
const ( DefaultReadRequestLimitCount = 1000000.0 DefaultWriteRequestLimitCount = 1000000.0 )
const ( IdField = "_id" ScoreField = "_score" )
const ( FieldOption_Null vearchpb.FieldOption = 0 FieldOption_Index vearchpb.FieldOption = 1 FieldOption_Index_False vearchpb.FieldOption = 2 )
const ClusterCleanJobKey = "/cluster/cleanjob"
when master running clean job , it will set value to this key, when other got key , now time less than this they will skip this job
const ClusterWatchServerKeyDelete = "watch/server/delete"
const ClusterWatchServerKeyPut = "watch/server/put"
ClusterWatchServerKey for server job lock
const ClusterWatchServerKeyScan = "watch/server/scan"
const MaxPartitions = 1024
const MaxTotalPartitions = 1024 * 16
const RESTART = "restart.txt"
const RootName = "root"
Variables ¶
var ( NodeIdSequence = "/id/node" SpaceIdSequence = "/id/space" DBIdSequence = "/id/db" PartitionIdSequence = "/id/partition" )
sids sequence key for etcd
var ( Prefix = "/" PrefixUser = "/user/" PrefixLock = "/lock/" PrefixLockCluster = "/lock/cluster" PrefixServer = "/server/" PrefixSpace = "/space/" PrefixSpaceConfig = "/space_config/" PrefixPartition = "/partition/" PrefixDataBase = "/db/" PrefixDataBaseBody = "/db/body/" PrefixFailServer = "/fail/server/" PrefixRouter = "/router/" PrefixNodeId = "/id/node" PrefixSpaceId = "/id/space" PrefixDBId = "/id/db" PrefixPartitionId = "/id/partition" PrefixAlias = "/alias/" PrefixRole = "/role/" PrefixMasterMember = "/member/" )
var ( ReadLimiter = rate.NewLimiter(rate.Limit(rate.Inf), 0) WriteLimiter = rate.NewLimiter(rate.Limit(rate.Inf), 0) )
var ( MinNlinks = 8 MaxNlinks = 96 MinEfConstruction = 16 MaxEfConstruction = 1024 DefaultMetricType = "InnerProduct" MinNcentroids = 1 MaxNcentroids = 262144 DefaultTrainingThreshold = 0 MinTrainingThreshold = 256 DefaultMaxPointsPerCentroid = 256 DefaultMinPointsPerCentroid = 39 DefaultRefreshInterval = 1000 // 1s DefaultEnableIdCache = false )
var ClusterAdminRole = Role{Name: "defaultClusterAdmin", Privileges: ClusterPrivilege}
var ClusterPrivilege = map[Resource]Privilege{ "ResourceCluster": WriteRead, "ResourceServer": WriteRead, "ResourcePartition": WriteRead, "ResourceDB": WriteRead, "ResourceSpace": WriteRead, "ResourceDocument": WriteRead, "ResourceIndex": WriteRead, "ResourceAlias": WriteRead, "ResourceConfig": WriteRead, "ResourceUser": WriteRead, "ResourceRole": WriteRead, }
var DocumentAdminPrivilege = map[Resource]Privilege{ "ResourceDocument": WriteRead, "ResourceIndex": WriteRead, }
var DocumentAdminRole = Role{Name: "defaultDocumentAdmin", Privileges: DocumentAdminPrivilege}
var DocumentReadPrivilege = map[Resource]Privilege{ "ResourceDocument": ReadOnly, "ResourceIndex": ReadOnly, }
var PrefixEtcdClusterID = "/vearch/default/"
var PriviMap = map[Privilege]string{ None: "None", WriteOnly: "WriteOnly", ReadOnly: "ReadOnly", WriteRead: "WriteRead", }
var ReadDBSpaceEditDocumentPrivilege = map[Resource]Privilege{ "ResourceCluster": ReadOnly, "ResourceDB": ReadOnly, "ResourceSpace": ReadOnly, "ResourceDocument": WriteRead, "ResourceIndex": WriteRead, "ResourceAlias": ReadOnly, }
var ReadDBSpaceEditDocumentRole = Role{Name: "defaultReadDBSpaceEditDocument", Privileges: ReadDBSpaceEditDocumentPrivilege}
var ReadSpaceEditDocumentPrivilege = map[Resource]Privilege{ "ResourceSpace": ReadOnly, "ResourceDocument": WriteRead, "ResourceIndex": WriteRead, "ResourceAlias": ReadOnly, }
var ReadSpaceEditDocumentRole = Role{Name: "defaultReadSpaceEditDocument", Privileges: ReadSpaceEditDocumentPrivilege}
var ResourceMap = map[Resource]string{ ResourceAll: "ResourceAll", ResourceCluster: "ResourceCluster", ResourceServer: "ResourceServer", ResourcePartition: "ResourcePartition", ResourceDB: "ResourceDB", ResourceSpace: "ResourceSpace", ResourceDocument: "ResourceDocument", ResourceIndex: "ResourceIndex", ResourceAlias: "ResourceAlias", ResourceUser: "ResourceUser", ResourceRole: "ResourceRole", ResourceConfig: "ResourceConfig", ResourceCache: "ResourceCache", }
var RoleMap = map[string]Role{ "root": RootRole, "defaultClusterAdmin": ClusterAdminRole, "defaultSpaceAdmin": SpaceAdminRole, "defaultDocumentAdmin": DocumentAdminRole, "defaultReadDBSpaceEditDocument": ReadDBSpaceEditDocumentRole, "defaultReadSpaceEditDocument": ReadSpaceEditDocumentRole, }
var RootPrivilege = map[Resource]Privilege{ "ResourceAll": WriteRead, }
var RootRole = Role{Name: "root", Privileges: RootPrivilege}
var SpaceAdminPrivilege = map[Resource]Privilege{ "ResourceSpace": WriteRead, "ResourceDocument": WriteRead, "ResourceIndex": WriteRead, "ResourceAlias": ReadOnly, }
var SpaceAdminRole = Role{Name: "defaultSpaceAdmin", Privileges: SpaceAdminPrivilege}
Functions ¶
func FailServerKey ¶
FailServerKey generate fail server key
func HasPrivi ¶
func HasPrivi(userPrivi PrivilegeType, checkPrivi PrivilegeType) bool
func LockAliasKey ¶
func LockRoleKey ¶ added in v3.5.2
func LockSpaceKey ¶
func LockUserKey ¶ added in v3.5.2
func MasterMemberKey ¶ added in v3.5.5
func ParseResources ¶ added in v3.5.2
func PartitionKey ¶
func RouterConfigKey ¶ added in v3.5.8
func SetPrefixAndSequence ¶
func SetPrefixAndSequence(cluster_id string)
func SetRequestLimit ¶ added in v3.5.8
func SetRequestLimit(router *RouterLimitCfg)
func SetRouterCount ¶ added in v3.5.8
func SetRouterCount(add bool)
func SpaceConfigKey ¶ added in v3.5.5
func ToTimestamp ¶ added in v3.5.2
func UnmarshalPropertyJSON ¶
func UnmarshalPropertyJSON(propertity []byte) (map[string]*SpaceProperties, error)
Types ¶
type AddMemberRequest ¶ added in v3.5.5
type AddMemberRequest struct {
PeerAddrs []string `json:"peer_addrs,omitempty"`
}
type Alias ¶
type Alias struct {
Name string `json:"name,omitempty"`
DbName string `json:"db_name,omitempty"`
SpaceName string `json:"space_name,omitempty"`
}
alias/dbName/spaceName
type BackupSpaceRequest ¶ added in v3.5.7
type BackupSpaceRequest struct {
Command string `json:"command,omitempty"`
BackupID int `json:"backup_id,omitempty"`
Part PartitionID `json:"part"`
S3Param struct {
Region string `json:"region"`
BucketName string `json:"bucket_name"`
EndPoint string `json:"endpoint"`
AccessKey string `json:"access_key"`
SecretKey string `json:"secret_key"`
UseSSL bool `json:"use_ssl"`
} `json:"s3_param,omitempty"`
}
type BackupSpaceResponse ¶ added in v3.5.7
type BuildVersion ¶
type CTX_KEY ¶
type CTX_KEY string
rpc time out, default 10 * 1000 ms
var (
RPC_TIME_OUT CTX_KEY = "rpc_timeout"
)
type ChangeMember ¶
type ChangeMember struct {
PartitionID PartitionID `json:"partition_id"`
NodeID NodeID `json:"node_id"`
Method proto.ConfChangeType `json:"method"`
}
type ChangeMembers ¶
type ChangeMembers struct {
PartitionIDs []PartitionID `json:"partition_ids"`
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"`
}
type EngineStatus ¶ added in v3.5.2
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 Field ¶
type Field struct {
Name string `json:"name"`
Type string `json:"type"`
Dimension int `json:"dimension,omitempty"`
StoreType *string `json:"store_type,omitempty"`
Format *string `json:"format,omitempty"`
Index *Index `json:"index,omitempty"`
StoreParam *struct {
CacheSize int `json:"cache_size,omitempty"`
} `json:"store_param,omitempty"`
}
type FlushEntity ¶
type Index ¶
type Index struct {
Name string `json:"name"`
Type string `json:"type,omitempty"`
Params json.RawMessage `json:"params,omitempty"`
}
func NewDefaultIndex ¶
func NewDefaultIndex() *Index
func (*Index) UnmarshalJSON ¶
type IndexParams ¶
type IndexParams struct {
Nlinks int `json:"nlinks,omitempty"`
EfSearch int `json:"efSearch,omitempty"`
EfConstruction int `json:"efConstruction,omitempty"`
MetricType string `json:"metric_type,omitempty"`
Ncentroids int `json:"ncentroids,omitempty"`
Nprobe int `json:"nprobe,omitempty"`
Nsubvector int `json:"nsubvector,omitempty"`
TrainingThreshold int `json:"training_threshold,omitempty"`
}
type MemberInfoRequest ¶ added in v3.5.5
type OperatorType ¶ added in v3.5.2
type OperatorType string
const ( Grant OperatorType = "Grant" Revoke OperatorType = "Revoke" )
type Partition ¶
type Partition struct {
Id PartitionID `json:"id"`
Name string `json:"name"`
SpaceId SpaceID `json:"space_id"`
DBId DBID `json:"db_id"`
Slot SlotID `json:"partition_slot"` // Slot stores the lower limit of the slot range
LeaderID NodeID `json:"leader_name,omitempty"`
Replicas []NodeID `json:"replicas,omitempty"` // leader in replicas
UpdateTime int64 `json:"update_time,omitempty"`
AddNum int64 `json:"add_num,omitempty"`
ResourceExhausted bool `json:"resourceExhausted"`
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"`
Name string `json:"name"`
DocNum uint64 `json:"doc_num"`
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"`
BackupStatus int `json:"backup_status"`
IndexNum int `json:"index_num"`
MaxDocid int `json:"max_docid"`
Error string `json:"error,omitempty"`
}
get partition from every partitions
type PartitionRule ¶ added in v3.5.2
type PartitionRule struct {
Type PartitionType `json:"type"`
Field string `json:"field,omitempty"`
Partitions int `json:"partitions,omitempty"`
Ranges []Range `json:"ranges,omitempty"`
}
func (*PartitionRule) AddRanges ¶ added in v3.5.2
func (pr *PartitionRule) AddRanges(ranges []Range) ([]Range, error)
func (*PartitionRule) RangeIsSame ¶ added in v3.5.2
func (pr *PartitionRule) RangeIsSame(ranges []Range) (bool, error)
func (*PartitionRule) Validate ¶ added in v3.5.2
func (pr *PartitionRule) Validate(space *Space, check_field bool) error
func (*PartitionRule) ValidateRange ¶ added in v3.5.2
func (pr *PartitionRule) ValidateRange(space *Space) error
type PartitionStatus ¶
type PartitionStatus uint8
const ( PA_UNKNOW PartitionStatus = iota PA_INVALID PA_CLOSED PA_READONLY PA_READWRITE )
type PartitionType ¶ added in v3.5.2
type PartitionType string
const ( RangePartition PartitionType = "RANGE" HashPartition PartitionType = "HASH" ListPartition PartitionType = "LIST" KeyPartition PartitionType = "KEY" CompositePartition PartitionType = "COMPOSITE" )
type PrivilegeType ¶ added in v3.5.2
type PrivilegeType uint64
func LackPrivi ¶
func LackPrivi(userPrivi PrivilegeType, checkPrivi PrivilegeType) PrivilegeType
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 Resource ¶ added in v3.5.2
type Resource string
const ( ResourceAll Resource = "ResourceAll" ResourceCluster Resource = "ResourceCluster" ResourceServer Resource = "ResourceServer" ResourcePartition Resource = "ResourcePartition" ResourceDB Resource = "ResourceDB" ResourceSpace Resource = "ResourceSpace" ResourceDocument Resource = "ResourceDocument" ResourceIndex Resource = "ResourceIndex" ResourceAlias Resource = "ResourceAlias" ResourceUser Resource = "ResourceUser" ResourceRole Resource = "ResourceRole" ResourceConfig Resource = "ResourceConfig" ResourceCache Resource = "ResourceCache" )
type ResourceLimit ¶ added in v3.5.2
type Role ¶ added in v3.5.2
type Role struct {
Name string `json:"name,omitempty"`
Operator OperatorType `json:"operator,omitempty"`
Privileges map[Resource]Privilege `json:"privileges,omitempty"`
}
func (*Role) HasPermissionForResources ¶ added in v3.5.2
type Router ¶ added in v3.5.8
type Router struct {
Count float64
LimitConfig *RouterLimitCfg
}
type RouterLimitCfg ¶ added in v3.5.8
type Server ¶
type Server struct {
ID NodeID `json:"name,omitempty"` //unique name for raft
ResourceName string `toml:"resource_name,omitempty" json:"resource_name"`
RpcPort uint16 `json:"rpc_port"`
RaftHeartbeatPort uint16 `json:"raft_heartbeat_port"`
RaftReplicatePort uint16 `json:"raft_replicate_port"`
Ip string `json:"ip,omitempty"`
HostIp string `json:"host_ip,omitempty"`
HostRack string `json:"host_rack,omitempty"`
HostZone string `json:"host_zone,omitempty"`
PartitionIds []PartitionID `json:"p_ids,omitempty"`
Spaces []*Space `json:"spaces,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"`
Desc string `json:"desc,omitempty"` // user setting
Name string `json:"name,omitempty"` // user setting
ResourceName string `toml:"resource_name,omitempty" json:"resource_name"`
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"`
Fields json.RawMessage `json:"fields"`
Index *Index `json:"index,omitempty"`
PartitionRule *PartitionRule `json:"partition_rule,omitempty"`
SpaceProperties map[string]*SpaceProperties `json:"space_properties,omitempty"`
RefreshInterval *int32 `json:"refresh_interval,omitempty"`
PartitionName *string `json:"partition_name,omitempty"` // partition name for partition rule
PartitionOperatorType *string `json:"operator_type,omitempty"` // partition rule operator type
EnableIdCache *bool `json:"enable_id_cache,omitempty"` // whether enable map docid to _id value in cache
}
space/[dbId]/[spaceId]:[spaceBody]
func (*Space) GetPartition ¶
func (s *Space) GetPartition(id PartitionID) *Partition
func (*Space) PartitionId ¶
func (s *Space) PartitionId(slotID SlotID) PartitionID
func (*Space) PartitionIdsByRangeField ¶ added in v3.5.2
type SpaceConfig ¶ added in v3.5.8
type SpaceConfig struct {
Id SpaceID `json:"id,omitempty"`
DBId DBID `json:"db_id,omitempty"`
EngineCacheSize *int64 `json:"engine_cache_size,omitempty"`
Path *string `json:"path,omitempty"`
LongSearchTime *int64 `json:"long_search_time,omitempty"`
RefreshInterval *int32 `json:"refresh_interval,omitempty"`
EnableIdCache *bool `json:"enable_id_cache,omitempty"`
}
TODO separete space config and mapping space_config/[dbId]/[spaceId]:[spaceConfigBody]
type SpaceInfo ¶
type SpaceInfo struct {
SpaceName string `json:"space_name,omitempty"`
Name string `json:"name,omitempty"` // for compitable with old version before v3.5.5, cluster health api use it
DbName string `json:"db_name"`
DocNum uint64 `json:"doc_num"`
PartitionNum int `json:"partition_num"`
ReplicaNum uint8 `json:"replica_num"`
Schema *SpaceSchema `json:"schema"`
PartitionRule *PartitionRule `json:"partition_rule,omitempty"`
Status string `json:"status,omitempty"`
Partitions []*PartitionInfo `json:"partitions"`
Errors []string `json:"errors,omitempty"`
}
type SpaceProperties ¶
type SpaceProperties struct {
FieldType vearchpb.FieldType `json:"field_type"`
Type string `json:"type"`
Index *Index `json:"index,omitempty"`
Format *string `json:"format,omitempty"`
Dimension int `json:"dimension,omitempty"`
StoreType *string `json:"store_type,omitempty"`
StoreParam json.RawMessage `json:"store_param,omitempty"`
Option vearchpb.FieldOption `json:"option,omitempty"`
}
type SpaceSchema ¶
type SpaceSchema struct {
Fields json.RawMessage `json:"fields"`
Index *Index `json:"index,omitempty"`
}