Documentation
¶
Index ¶
- Constants
- Variables
- func Diff(leftLabel string, left *State, rightLabel string, right *State) []string
- func Equal(lhs, rhs *State) error
- func MigrateToHierarchicalFS(rootPath string, s schemaGetter) 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, ...) (created []*models.Tenant, 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, tenant 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) MergeClassObjectProperty(ctx context.Context, principal *models.Principal, class string, ...) error
- 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, nodeMapping map[string]string) 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 (m *Manager) Shutdown(ctx context.Context) error
- func (m *Manager) StartServing(ctx context.Context) error
- func (s *Manager) TenantShard(class, tenant string) (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
- func (m *Manager) UpdateTenants(ctx context.Context, principal *models.Principal, class string, ...) error
- type MergeObjectPropertyPayload
- type ModuleConfig
- type ReadSchemaPayload
- type RefFinder
- type SchemaGetter
- type SchemaStore
- type State
- type TenantCreate
- type TenantUpdate
- type UpdateClassPayload
- type UpdateTenantsPayload
- 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" // repairs RepairClass cluster.TransactionType = "repair_class" RepairProperty cluster.TransactionType = "repair_property" RepairTenant cluster.TransactionType = "repair_tenant" 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 MigrateToHierarchicalFS ¶ added in v1.23.13
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 []TenantCreate `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, configParser VectorConfigParser, vectorizerValidator VectorizerValidator, invertedConfigValidator InvertedConfigValidator, moduleConfig ModuleConfig, clusterState clusterState, txClient cluster.Client, txPersistence cluster.Persistence, 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, ) (created []*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) MergeClassObjectProperty ¶ added in v1.22.0
func (m *Manager) MergeClassObjectProperty(ctx context.Context, principal *models.Principal, class string, property *models.Property, ) error
MergeClassObjectProperty of an existing Class Merges NestedProperties of incoming object/object[] property into existing one
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 update
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
ShardReplicas returns the nodes owning shard in class
func (*Manager) StartServing ¶ added in v1.21.3
StartServing indicates that the schema manager is ready to accept incoming connections in cluster mode, i.e. it will accept opening transactions.
Some transactions are exempt, such as ReadSchema which is required for nodes to start up.
This method should be called when all backends, primarily the DB, are ready to serve.
func (*Manager) TenantShard ¶ added in v1.20.0
TenantShard returns shard name for the provided tenant and its activity status
func (*Manager) UpdateClass ¶
func (*Manager) UpdateShardStatus ¶
type MergeObjectPropertyPayload ¶ added in v1.22.0
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, string) ShardFromUUID(class string, uuid []byte) string ShardReplicas(class, shard string) ([]string, error) }
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 // UpdateShards updates (replaces) shards of on existing class // Error is returned if class or shard does not exist UpdateShards(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 TenantCreate ¶ added in v1.21.0
type TenantCreate struct { Name string `json:"name"` Nodes []string `json:"nodes"` Status string `json:"status"` }
TenantCreate represents properties of a specific tenant (physical shard)
type TenantUpdate ¶ added in v1.21.0
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 UpdateTenantsPayload ¶ added in v1.21.0
type UpdateTenantsPayload struct { Class string `json:"class_name"` Tenants []TenantUpdate `json:"tenants"` }
type VectorConfigParser ¶
type VectorConfigParser func(in interface{}, vectorIndexType string) (schema.VectorIndexConfig, error)
type VectorizerValidator ¶
Source Files
¶
- add.go
- add_property.go
- cache.go
- delete.go
- delete_property.go
- errors.go
- file_structure_migration.go
- get.go
- incoming_commit.go
- manager.go
- read_consensus.go
- ref_finder.go
- remove_duplicate_props.go
- schema_comparison.go
- schema_repair.go
- startup_cluster_sync.go
- tenant.go
- transactions.go
- update.go
- update_property.go
- validation.go
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 |