Documentation ¶
Index ¶
- func Migrate(conf config.Database) (err error)
- func MigrateDown(engine, uri string) (err error)
- func MigrateDownTo(engine, uri string, p int64) (err error)
- func MigrateReset(engine, uri string) (err error)
- func MigrateStatus(engine, uri string) (err error)
- func MigrateUp(engine, uri string) (err error)
- func MigrateUpTo(engine, uri string, p int64) (err error)
- type Attribute
- type Bundle
- type BundleReader
- type BundleWriter
- type DataReader
- type DataWriter
- type NoopBundleReader
- type NoopBundleWriter
- type NoopDataReader
- func (f *NoopDataReader) HeadSnapshot(_ context.Context, _ string) (token.SnapToken, error)
- func (f *NoopDataReader) QueryAttributes(_ context.Context, _ string, _ *base.AttributeFilter, _ string) (*database.AttributeIterator, error)
- func (f *NoopDataReader) QueryRelationships(_ context.Context, _ string, _ *base.TupleFilter, _ string) (*database.TupleIterator, error)
- func (f *NoopDataReader) QuerySingleAttribute(_ context.Context, _ string, _ *base.AttributeFilter, _ string) (*base.Attribute, error)
- func (f *NoopDataReader) QueryUniqueEntities(_ context.Context, _, _, _ string, _ database.Pagination) ([]string, database.EncodedContinuousToken, error)
- func (f *NoopDataReader) QueryUniqueSubjectReferences(_ context.Context, _ string, _ *base.RelationReference, _ string, ...) ([]string, database.EncodedContinuousToken, error)
- func (f *NoopDataReader) ReadAttributes(_ context.Context, _ string, _ *base.AttributeFilter, _ string, ...) (*database.AttributeCollection, database.EncodedContinuousToken, error)
- func (f *NoopDataReader) ReadRelationships(_ context.Context, _ string, _ *base.TupleFilter, _ string, ...) (*database.TupleCollection, database.EncodedContinuousToken, error)
- type NoopDataWriter
- func (n *NoopDataWriter) Delete(_ context.Context, _ string, _ *base.TupleFilter, _ *base.AttributeFilter) (token.EncodedSnapToken, error)
- func (n *NoopDataWriter) RunBundle(_ context.Context, _ string, _ map[string]string, _ *base.DataBundle) (token.EncodedSnapToken, error)
- func (n *NoopDataWriter) Write(_ context.Context, _ string, _ *database.TupleCollection, ...) (token.EncodedSnapToken, error)
- type NoopSchemaReader
- func (n *NoopSchemaReader) HeadVersion(_ context.Context, _ string) (string, error)
- func (n *NoopSchemaReader) ListSchemas(_ context.Context, _ string, _ database.Pagination) (tenants []*base.SchemaList, ct database.EncodedContinuousToken, err error)
- func (n *NoopSchemaReader) ReadEntityDefinition(_ context.Context, _, _, _ string) (*base.EntityDefinition, string, error)
- func (n *NoopSchemaReader) ReadRuleDefinition(_ context.Context, _, _, _ string) (*base.RuleDefinition, string, error)
- func (n *NoopSchemaReader) ReadSchema(_ context.Context, _, _ string) (*base.SchemaDefinition, error)
- type NoopSchemaWriter
- type NoopTenantReader
- type NoopTenantWriter
- type NoopWatcher
- type RelationTuple
- type SchemaDefinition
- type SchemaReader
- type SchemaWriter
- type Tenant
- type TenantReader
- type TenantWriter
- type Watcher
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MigrateDown ¶ added in v0.5.4
MigrateDown undoes all database migrations, reverting the schema to the initial state.
func MigrateDownTo ¶ added in v0.5.4
MigrateDownTo undoes database migrations down to a specific version.
func MigrateReset ¶ added in v0.5.4
MigrateReset roll back all migrations.
func MigrateStatus ¶ added in v0.5.4
MigrateStatus displays the status of all migrations.
func MigrateUp ¶ added in v0.5.4
MigrateUp performs all available database migrations to update the schema to the latest version.
func MigrateUpTo ¶ added in v0.5.4
MigrateUpTo performs database migrations up to a specific version.
Types ¶
type Attribute ¶ added in v0.5.0
type Attribute struct { ID uint64 TenantID string EntityType string EntityID string Attribute string Value *anypb.Any }
func (Attribute) ToAttribute ¶ added in v0.5.0
type Bundle ¶ added in v0.6.5
type Bundle struct { Name string DataBundle *base.DataBundle TenantID string }
Bundle - Structure for Bundle
type BundleReader ¶ added in v0.6.0
type BundleReader interface { // Read retrieves a data bundle based on tenant ID and name. Read(ctx context.Context, tenantID, name string) (bundle *base.DataBundle, err error) }
BundleReader - Reads data bundles from storage.
func NewNoopBundleReader ¶ added in v0.6.0
func NewNoopBundleReader() BundleReader
type BundleWriter ¶ added in v0.6.0
type BundleWriter interface { // Write stores bundles in storage for a tenant. Write(ctx context.Context, bundles []Bundle) (names []string, err error) // Delete removes a bundle from storage for a tenant. Delete(ctx context.Context, tenantID, name string) (err error) }
BundleWriter - Manages writing and deletion of data bundles.
func NewNoopBundleWriter ¶ added in v0.6.0
func NewNoopBundleWriter() BundleWriter
type DataReader ¶ added in v0.5.0
type DataReader interface { // QueryRelationships reads relation tuples from the storage based on the given filter. // It returns an iterator to iterate over the tuples and any error encountered. QueryRelationships(ctx context.Context, tenantID string, filter *base.TupleFilter, snap string) (iterator *database.TupleIterator, err error) // ReadRelationships reads relation tuples from the storage based on the given filter and pagination. // It returns a collection of tuples, a continuous token indicating the position in the data set, and any error encountered. ReadRelationships(ctx context.Context, tenantID string, filter *base.TupleFilter, snap string, pagination database.Pagination) (collection *database.TupleCollection, ct database.EncodedContinuousToken, err error) // QuerySingleAttribute retrieves a single attribute from the storage based on the given filter. // It returns the retrieved attribute and any error encountered. QuerySingleAttribute(ctx context.Context, tenantID string, filter *base.AttributeFilter, snap string) (attribute *base.Attribute, err error) // QueryAttributes reads multiple attributes from the storage based on the given filter. // It returns an iterator to iterate over the attributes and any error encountered. QueryAttributes(ctx context.Context, tenantID string, filter *base.AttributeFilter, snap string) (iterator *database.AttributeIterator, err error) // ReadAttributes reads multiple attributes from the storage based on the given filter and pagination. // It returns a collection of attributes, a continuous token indicating the position in the data set, and any error encountered. ReadAttributes(ctx context.Context, tenantID string, filter *base.AttributeFilter, snap string, pagination database.Pagination) (collection *database.AttributeCollection, ct database.EncodedContinuousToken, err error) // QueryUniqueEntities reads unique entities from the storage based on the given filter and pagination. // It returns a slice of entity IDs, a continuous token indicating the position in the data set, and any error encountered. QueryUniqueEntities(ctx context.Context, tenantID, name, snap string, pagination database.Pagination) (ids []string, ct database.EncodedContinuousToken, err error) // QueryUniqueSubjectReferences reads unique subject references from the storage based on the given filter and pagination. // It returns a slice of subject reference IDs, a continuous token indicating the position in the data set, and any error encountered. QueryUniqueSubjectReferences(ctx context.Context, tenantID string, subjectReference *base.RelationReference, snap string, pagination database.Pagination) (ids []string, ct database.EncodedContinuousToken, err error) // HeadSnapshot reads the latest version of the snapshot from the storage for a specific tenant. // It returns the snapshot token representing the version of the snapshot and any error encountered. HeadSnapshot(ctx context.Context, tenantID string) (token.SnapToken, error) }
DataReader - Interface for reading Data from the storage.
func NewNoopRelationshipReader ¶ added in v0.4.4
func NewNoopRelationshipReader() DataReader
type DataWriter ¶ added in v0.5.0
type DataWriter interface { // Write inserts a new TupleCollection and AttributeCollection into the database for a specified tenant. // Returns an encoded snapshot token representing the state of the database after the write operation and any error encountered. Write(ctx context.Context, tenantID string, tupleCollection *database.TupleCollection, attributesCollection *database.AttributeCollection) (token token.EncodedSnapToken, err error) // Delete removes data from the database based on the provided tuple and attribute filters for a specified tenant. // Returns an encoded snapshot token representing the state of the database after the delete operation and any error encountered. Delete(ctx context.Context, tenantID string, tupleFilter *base.TupleFilter, attributeFilter *base.AttributeFilter) (token token.EncodedSnapToken, err error) // RunBundle executes a specified data bundle for a given tenant. // Returns an encoded snapshot token representing the state of the database after running the bundle and any error encountered. RunBundle(ctx context.Context, tenantID string, arguments map[string]string, bundle *base.DataBundle) (token token.EncodedSnapToken, err error) }
func NewNoopDataWriter ¶ added in v0.5.0
func NewNoopDataWriter() DataWriter
type NoopBundleReader ¶ added in v0.6.0
type NoopBundleReader struct{}
func (*NoopBundleReader) Read ¶ added in v0.6.0
func (n *NoopBundleReader) Read(_ context.Context, _, _ string) (*base.DataBundle, error)
type NoopBundleWriter ¶ added in v0.6.0
type NoopBundleWriter struct{}
type NoopDataReader ¶ added in v0.5.0
type NoopDataReader struct{}
func (*NoopDataReader) HeadSnapshot ¶ added in v0.5.0
func (*NoopDataReader) QueryAttributes ¶ added in v0.5.0
func (f *NoopDataReader) QueryAttributes(_ context.Context, _ string, _ *base.AttributeFilter, _ string) (*database.AttributeIterator, error)
func (*NoopDataReader) QueryRelationships ¶ added in v0.5.0
func (f *NoopDataReader) QueryRelationships(_ context.Context, _ string, _ *base.TupleFilter, _ string) (*database.TupleIterator, error)
func (*NoopDataReader) QuerySingleAttribute ¶ added in v0.5.0
func (f *NoopDataReader) QuerySingleAttribute(_ context.Context, _ string, _ *base.AttributeFilter, _ string) (*base.Attribute, error)
func (*NoopDataReader) QueryUniqueEntities ¶ added in v0.5.0
func (f *NoopDataReader) QueryUniqueEntities(_ context.Context, _, _, _ string, _ database.Pagination) ([]string, database.EncodedContinuousToken, error)
func (*NoopDataReader) QueryUniqueSubjectReferences ¶ added in v0.5.0
func (f *NoopDataReader) QueryUniqueSubjectReferences(_ context.Context, _ string, _ *base.RelationReference, _ string, _ database.Pagination) ([]string, database.EncodedContinuousToken, error)
func (*NoopDataReader) ReadAttributes ¶ added in v0.5.0
func (f *NoopDataReader) ReadAttributes(_ context.Context, _ string, _ *base.AttributeFilter, _ string, _ database.Pagination) (*database.AttributeCollection, database.EncodedContinuousToken, error)
func (*NoopDataReader) ReadRelationships ¶ added in v0.5.0
func (f *NoopDataReader) ReadRelationships(_ context.Context, _ string, _ *base.TupleFilter, _ string, _ database.Pagination) (*database.TupleCollection, database.EncodedContinuousToken, error)
type NoopDataWriter ¶ added in v0.5.0
type NoopDataWriter struct{}
func (*NoopDataWriter) Delete ¶ added in v0.5.0
func (n *NoopDataWriter) Delete(_ context.Context, _ string, _ *base.TupleFilter, _ *base.AttributeFilter) (token.EncodedSnapToken, error)
func (*NoopDataWriter) RunBundle ¶ added in v0.6.0
func (n *NoopDataWriter) RunBundle(_ context.Context, _ string, _ map[string]string, _ *base.DataBundle) (token.EncodedSnapToken, error)
func (*NoopDataWriter) Write ¶ added in v0.5.0
func (n *NoopDataWriter) Write(_ context.Context, _ string, _ *database.TupleCollection, _ *database.AttributeCollection) (token.EncodedSnapToken, error)
type NoopSchemaReader ¶ added in v0.4.4
type NoopSchemaReader struct{}
func (*NoopSchemaReader) HeadVersion ¶ added in v0.4.4
func (*NoopSchemaReader) ListSchemas ¶ added in v0.7.5
func (n *NoopSchemaReader) ListSchemas(_ context.Context, _ string, _ database.Pagination) (tenants []*base.SchemaList, ct database.EncodedContinuousToken, err error)
func (*NoopSchemaReader) ReadEntityDefinition ¶ added in v0.5.0
func (n *NoopSchemaReader) ReadEntityDefinition(_ context.Context, _, _, _ string) (*base.EntityDefinition, string, error)
func (*NoopSchemaReader) ReadRuleDefinition ¶ added in v0.5.0
func (n *NoopSchemaReader) ReadRuleDefinition(_ context.Context, _, _, _ string) (*base.RuleDefinition, string, error)
func (*NoopSchemaReader) ReadSchema ¶ added in v0.4.4
func (n *NoopSchemaReader) ReadSchema(_ context.Context, _, _ string) (*base.SchemaDefinition, error)
type NoopSchemaWriter ¶ added in v0.4.4
type NoopSchemaWriter struct{}
func (*NoopSchemaWriter) WriteSchema ¶ added in v0.4.4
func (n *NoopSchemaWriter) WriteSchema(_ context.Context, _ []SchemaDefinition) error
type NoopTenantReader ¶ added in v0.4.4
type NoopTenantReader struct{}
func (*NoopTenantReader) ListTenants ¶ added in v0.4.4
func (n *NoopTenantReader) ListTenants(_ context.Context, _ database.Pagination) ([]*base.Tenant, database.EncodedContinuousToken, error)
type NoopTenantWriter ¶ added in v0.4.4
type NoopTenantWriter struct{}
func (*NoopTenantWriter) CreateTenant ¶ added in v0.4.4
func (*NoopTenantWriter) DeleteTenant ¶ added in v0.4.4
type NoopWatcher ¶ added in v0.4.4
type NoopWatcher struct{}
func (*NoopWatcher) Watch ¶ added in v0.4.4
func (n *NoopWatcher) Watch(_ context.Context, _, _ string) (<-chan *base.DataChanges, <-chan error)
type RelationTuple ¶
type RelationTuple struct { ID uint64 TenantID string EntityType string EntityID string Relation string SubjectType string SubjectID string SubjectRelation string }
RelationTuple - Structure for Relational Tuple
func (RelationTuple) ToTuple ¶
func (r RelationTuple) ToTuple() *base.Tuple
ToTuple - Convert database relation tuple to base relation tuple
type SchemaDefinition ¶
type SchemaDefinition struct { TenantID string Name string SerializedDefinition []byte Version string }
SchemaDefinition - Structure for Schema Definition
func (SchemaDefinition) Serialized ¶
func (e SchemaDefinition) Serialized() string
Serialized - get schema serialized definition
type SchemaReader ¶
type SchemaReader interface { // ReadSchema reads entity config from the storage. ReadSchema(ctx context.Context, tenantID, version string) (schema *base.SchemaDefinition, err error) // ReadEntityDefinition reads entity config from the storage. ReadEntityDefinition(ctx context.Context, tenantID, entityName, version string) (definition *base.EntityDefinition, v string, err error) // ReadRuleDefinition reads rule config from the storage. ReadRuleDefinition(ctx context.Context, tenantID, ruleName, version string) (definition *base.RuleDefinition, v string, err error) // HeadVersion reads the latest version of the schema from the storage. HeadVersion(ctx context.Context, tenantID string) (version string, err error) // ListSchemas lists all schemas from the storage ListSchemas(ctx context.Context, tenantID string, pagination database.Pagination) (schemas []*base.SchemaList, ct database.EncodedContinuousToken, err error) }
SchemaReader - Reads schema definitions from the storage.
func NewNoopSchemaReader ¶ added in v0.4.4
func NewNoopSchemaReader() SchemaReader
type SchemaWriter ¶
type SchemaWriter interface { // WriteSchema writes schema to the storage. WriteSchema(ctx context.Context, definitions []SchemaDefinition) (err error) }
SchemaWriter - Writes schema definitions to the storage.
func NewNoopSchemaWriter ¶ added in v0.4.4
func NewNoopSchemaWriter() SchemaWriter
type TenantReader ¶
type TenantReader interface { // ListTenants reads tenants from the storage. ListTenants(ctx context.Context, pagination database.Pagination) (tenants []*base.Tenant, ct database.EncodedContinuousToken, err error) }
TenantReader - Reads tenants from the storage.
func NewNoopTenantReader ¶ added in v0.4.4
func NewNoopTenantReader() TenantReader
type TenantWriter ¶
type TenantWriter interface { // CreateTenant writes tenant to the storage. CreateTenant(ctx context.Context, id, name string) (tenant *base.Tenant, err error) // DeleteTenant deletes tenant from the storage. DeleteTenant(ctx context.Context, tenantID string) (tenant *base.Tenant, err error) }
TenantWriter - Writes tenants to the storage.
func NewNoopTenantWriter ¶ added in v0.4.4
func NewNoopTenantWriter() TenantWriter
type Watcher ¶ added in v0.4.4
type Watcher interface { // Watch watches relation tuple changes from the storage. Watch(ctx context.Context, tenantID, snap string) (<-chan *base.DataChanges, <-chan error) }
Watcher - Watches relation tuple changes from the storage.
func NewNoopWatcher ¶ added in v0.4.4
func NewNoopWatcher() Watcher