Documentation
¶
Index ¶
- Constants
- Variables
- func Diff(leftLabel string, left *State, rightLabel string, right *State) []string
- func Equal(lhs, rhs *State) error
- func UnmarshalTransaction(txType cluster.TransactionType, payload json.RawMessage) (interface{}, error)
- type AddClassPayload
- type AddPropertyPayload
- type AddTenantsPayload
- type ClassPayload
- type DeleteClassPayload
- type DeleteTenantsPayload
- type InvertedConfigValidator
- type KeyValuePair
- type Manager
- func (m *Manager) AddClass(ctx context.Context, principal *models.Principal, class *models.Class) error
- func (m *Manager) AddClassProperty(ctx context.Context, principal *models.Principal, class string, ...) error
- func (m *Manager) AddTenants(ctx context.Context, principal *models.Principal, class string, ...) (err error)
- func (m *Manager) ClusterHealthScore() int
- func (m *Manager) ClusterStatus(ctx context.Context) (*models.SchemaClusterStatus, error)
- func (s *Manager) CopyShardingState(className string) *sharding.State
- func (m *Manager) DeleteClass(ctx context.Context, principal *models.Principal, class string) error
- func (m *Manager) DeleteClassProperty(ctx context.Context, principal *models.Principal, class string, ...) error
- func (m *Manager) DeleteTenants(ctx context.Context, principal *models.Principal, class string, ...) error
- func (m *Manager) GetClass(ctx context.Context, principal *models.Principal, name string) (*models.Class, error)
- func (m *Manager) GetSchema(principal *models.Principal) (schema.Schema, error)
- func (m *Manager) GetSchemaSkipAuth() schema.Schema
- func (m *Manager) GetShardsStatus(ctx context.Context, principal *models.Principal, className string) (models.ShardStatusList, error)
- func (m *Manager) GetTenants(ctx context.Context, principal *models.Principal, class string) ([]*models.Tenant, error)
- func (m *Manager) IndexedInverted(className, propertyName string) bool
- func (s *Manager) LockGuard(mutate func())
- func (m *Manager) NodeName() string
- func (m *Manager) Nodes() []string
- func (s *Manager) RLockGuard(reader func() error) error
- func (m *Manager) RegisterSchemaUpdateCallback(callback func(updatedSchema schema.Schema))
- func (m *Manager) ResolveParentNodes(class, shardName string) (map[string]string, error)
- func (m *Manager) RestoreClass(ctx context.Context, d *backup.ClassDescriptor) error
- func (s *Manager) ShardFromUUID(class string, uuid []byte) string
- func (s *Manager) ShardOwner(class, shard string) (string, error)
- func (s *Manager) ShardReplicas(class, shard string) ([]string, error)
- func (s *Manager) TenantShard(class, tenant string) string
- func (m *Manager) TxManager() *cluster.TxManager
- func (m *Manager) UpdateClass(ctx context.Context, principal *models.Principal, className string, ...) error
- func (m *Manager) UpdateShardStatus(ctx context.Context, principal *models.Principal, ...) error
- type ModuleConfig
- type ReadSchemaPayload
- type RefFinder
- type SchemaGetter
- type SchemaStore
- type State
- type Tenant
- type UpdateClassPayload
- type VectorConfigParser
- type VectorizerValidator
Constants ¶
const ( // write-only AddClass cluster.TransactionType = "add_class" AddProperty cluster.TransactionType = "add_property" DeleteClass cluster.TransactionType = "delete_class" UpdateClass cluster.TransactionType = "update_class" // read-only ReadSchema cluster.TransactionType = "read_schema" DefaultTxTTL = 60 * time.Second )
Variables ¶
var ErrNotFound = errors.New("not found")
Functions ¶
func Diff ¶ added in v1.17.4
Diff creates human-readable information about the difference in two schemas, returns a len=0 slice if schemas are identical
func Equal ¶
Equal compares two schema states for equality First the object classes are sorted, because they are unordered. Then we can make the comparison using DeepEqual
func UnmarshalTransaction ¶
func UnmarshalTransaction(txType cluster.TransactionType, payload json.RawMessage, ) (interface{}, error)
Types ¶
type AddClassPayload ¶
type AddPropertyPayload ¶
type AddTenantsPayload ¶ added in v1.20.0
type AddTenantsPayload struct { Class string `json:"class_name"` Tenants []Tenant `json:"tenants"` }
AddTenantsPayload allows for adding multiple tenants to a class
type ClassPayload ¶ added in v1.20.0
type ClassPayload struct { Name string Metadata []byte ShardingState []byte Shards []KeyValuePair ReplaceShards bool Error error }
ClassPayload is used to serialize class updates
func CreateClassPayload ¶ added in v1.20.0
type DeleteClassPayload ¶
type DeleteClassPayload struct {
ClassName string `json:"className"`
}
type DeleteTenantsPayload ¶ added in v1.20.0
type DeleteTenantsPayload struct { Class string `json:"class_name"` Tenants []string `json:"tenants"` }
DeleteTenantsPayload allows for removing multiple tenants from a class
type InvertedConfigValidator ¶
type InvertedConfigValidator func(in *models.InvertedIndexConfig) error
type KeyValuePair ¶ added in v1.20.0
KeyValuePair is used to serialize shards updates
type Manager ¶
type Manager struct { Authorizer authorizer RestoreStatus sync.Map RestoreError sync.Map sync.RWMutex // contains filtered or unexported fields }
Manager Manages schema changes at a use-case level, i.e. agnostic of underlying databases or storage providers
func NewManager ¶
func NewManager(migrator migrate.Migrator, repo SchemaStore, logger logrus.FieldLogger, authorizer authorizer, config config.Config, hnswConfigParser VectorConfigParser, vectorizerValidator VectorizerValidator, invertedConfigValidator InvertedConfigValidator, moduleConfig ModuleConfig, clusterState clusterState, txClient cluster.Client, scaleoutManager scaleOut, ) (*Manager, error)
NewManager creates a new manager
func (*Manager) AddClass ¶
func (m *Manager) AddClass(ctx context.Context, principal *models.Principal, class *models.Class, ) error
AddClass to the schema
func (*Manager) AddClassProperty ¶
func (m *Manager) AddClassProperty(ctx context.Context, principal *models.Principal, class string, property *models.Property, ) error
AddClassProperty to an existing Class
func (*Manager) AddTenants ¶ added in v1.20.0
func (m *Manager) AddTenants(ctx context.Context, principal *models.Principal, class string, tenants []*models.Tenant, ) (err error)
AddTenants is used to add new tenants to a class Class must exist and has partitioning enabled
func (*Manager) ClusterHealthScore ¶
func (*Manager) ClusterStatus ¶ added in v1.19.10
func (*Manager) CopyShardingState ¶ added in v1.20.0
func (*Manager) DeleteClass ¶
DeleteClass from the schema
func (*Manager) DeleteClassProperty ¶
func (m *Manager) DeleteClassProperty(ctx context.Context, principal *models.Principal, class string, property string, ) error
DeleteClassProperty from existing Schema
func (*Manager) DeleteTenants ¶ added in v1.20.0
func (m *Manager) DeleteTenants(ctx context.Context, principal *models.Principal, class string, tenants []string) error
DeleteTenants is used to delete tenants of a class.
Class must exist and has partitioning enabled
func (*Manager) GetSchemaSkipAuth ¶
GetSchemaSkipAuth can never be used as a response to a user request as it could leak the schema to an unauthorized user, is intended to be used for non-user triggered processes, such as regular updates / maintenance / etc
func (*Manager) GetShardsStatus ¶
func (*Manager) GetTenants ¶ added in v1.20.0
func (m *Manager) GetTenants(ctx context.Context, principal *models.Principal, class string) ([]*models.Tenant, error)
GetTenants is used to get tenants of a class.
Class must exist and has partitioning enabled
func (*Manager) IndexedInverted ¶
func (*Manager) LockGuard ¶ added in v1.20.0
func (s *Manager) LockGuard(mutate func())
LockGuard provides convenient mechanism for owning mutex by function which mutates the state
func (*Manager) RLockGuard ¶ added in v1.20.0
RLockGuard provides convenient mechanism for owning mutex function which doesn't mutates the state
func (*Manager) RegisterSchemaUpdateCallback ¶
RegisterSchemaUpdateCallback allows other usecases to register a primitive type update callback. The callbacks will be called any time we persist a schema upadate
func (*Manager) ResolveParentNodes ¶ added in v1.18.0
ResolveParentNodes gets all replicas for a specific class shard and resolves their names
it returns map[node_name] node_address where node_address = "" if can't resolve node_name
func (*Manager) RestoreClass ¶
func (*Manager) ShardFromUUID ¶ added in v1.20.0
ShardFromUUID returns shard name of the provided uuid
func (*Manager) ShardOwner ¶ added in v1.20.0
ShardOwner returns the node owner of the specified shard
func (*Manager) ShardReplicas ¶ added in v1.20.0
ShardOwner returns the node owner of the specified shard
func (*Manager) TenantShard ¶ added in v1.20.0
TenantShard returns shard name for the provided tenant
func (*Manager) UpdateClass ¶
type ModuleConfig ¶
type ReadSchemaPayload ¶
type ReadSchemaPayload struct {
Schema *State `json:"schema"`
}
type RefFinder ¶
type RefFinder struct {
// contains filtered or unexported fields
}
RefFinder is a helper that lists classes and their possible paths to to a desired target class.
For example if the target class is "car". It might list: - Person, drives, Car - Person, owns, Car - Person, friendsWith, Person, drives, Car etc.
It will stop at a preconfigured depth limit, to avoid infinite results, such as: - Person, friendsWith, Person, friendsWith, Person, ..., drives Car
func NewRefFinder ¶
NewRefFinder with SchemaGetter and depth limit
type SchemaGetter ¶
type SchemaGetter interface { GetSchemaSkipAuth() schema.Schema Nodes() []string NodeName() string ClusterHealthScore() int ResolveParentNodes(string, string) (map[string]string, error) CopyShardingState(class string) *sharding.State ShardOwner(class, shard string) (string, error) TenantShard(class, tenant string) string ShardFromUUID(class string, uuid []byte) string }
type SchemaStore ¶ added in v1.20.0
type SchemaStore interface { // Save saves the complete schema to the persistent storage Save(ctx context.Context, schema State) error // Load loads the complete schema from the persistent storage Load(context.Context) (State, error) // NewClass creates a new class if it doesn't exists, otherwise return an error NewClass(context.Context, ClassPayload) error // UpdateClass if it exists, otherwise return an error UpdateClass(context.Context, ClassPayload) error // DeleteClass deletes class DeleteClass(ctx context.Context, class string) error // NewShards creates new shards of an existing class NewShards(ctx context.Context, class string, shards []KeyValuePair) error // DeleteShards deletes shards from a class // If the class or a shard does not exist then nothing is done and a nil error is returned DeleteShards(ctx context.Context, class string, shards []string) error }
SchemaStore is responsible for persisting the schema by providing support for both partial and complete schema updates
type State ¶
type State struct { ObjectSchema *models.Schema `json:"object"` ShardingState map[string]*sharding.State }
State is a cached copy of the schema that can also be saved into a remote storage, as specified by Repo
type UpdateClassPayload ¶
type UpdateClassPayload struct { ClassName string `json:"className"` Class *models.Class `json:"class"` // For now, the state cannot be updated yet, but this will be a requirement // in the future, for example, with dynamically changing replication, so we // should already make sure that state is part of the transaction payload State *sharding.State `json:"state"` }
type VectorConfigParser ¶
type VectorConfigParser func(in interface{}) (schema.VectorIndexConfig, error)
type VectorizerValidator ¶
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
Package migrate provides a simple composer tool, which implements the Migrator interface and can take in any number of migrators which themselves have to implement the interface
|
Package migrate provides a simple composer tool, which implements the Migrator interface and can take in any number of migrators which themselves have to implement the interface |