postgres

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2023 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RelationTuplesTable   = "relation_tuples"
	AttributesTable       = "attributes"
	SchemaDefinitionTable = "schema_definitions"
	TransactionsTable     = "transactions"
	TenantsTable          = "tenants"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DataReader added in v0.5.0

type DataReader struct {
	// contains filtered or unexported fields
}

DataReader is a struct which holds a reference to the database, transaction options and a logger. It is responsible for reading data from the database.

func NewDataReader added in v0.5.0

func NewDataReader(database *db.Postgres, logger logger.Interface) *DataReader

NewDataReader is a constructor function for DataReader. It initializes a new DataReader with a given database, a logger, and sets transaction options to be read-only with Repeatable Read isolation level.

func (*DataReader) HeadSnapshot added in v0.5.0

func (r *DataReader) HeadSnapshot(ctx context.Context, tenantID string) (token.SnapToken, error)

HeadSnapshot retrieves the latest snapshot token associated with the tenant.

func (*DataReader) QueryAttributes added in v0.5.0

func (r *DataReader) QueryAttributes(ctx context.Context, tenantID string, filter *base.AttributeFilter, snap string) (it *database.AttributeIterator, err error)

QueryAttributes reads multiple attributes from the storage based on the given filter.

func (*DataReader) QueryRelationships added in v0.5.0

func (r *DataReader) QueryRelationships(ctx context.Context, tenantID string, filter *base.TupleFilter, snap string) (it *database.TupleIterator, err error)

QueryRelationships reads relation tuples from the storage based on the given filter.

func (*DataReader) QuerySingleAttribute added in v0.5.0

func (r *DataReader) QuerySingleAttribute(ctx context.Context, tenantID string, filter *base.AttributeFilter, snap string) (attribute *base.Attribute, err error)

QuerySingleAttribute retrieves a single attribute from the storage based on the given filter.

func (*DataReader) QueryUniqueEntities added in v0.5.0

func (r *DataReader) QueryUniqueEntities(ctx context.Context, tenantID, name, snap string, pagination database.Pagination) (ids []string, ct database.EncodedContinuousToken, err error)

QueryUniqueEntities reads unique entities from the storage based on the given filter and pagination.

func (*DataReader) QueryUniqueSubjectReferences added in v0.5.0

func (r *DataReader) QueryUniqueSubjectReferences(ctx context.Context, tenantID string, subjectReference *base.RelationReference, 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.

func (*DataReader) ReadAttributes added in v0.5.0

func (r *DataReader) ReadAttributes(ctx context.Context, tenantID string, filter *base.AttributeFilter, snap string, pagination database.Pagination) (collection *database.AttributeCollection, ct database.EncodedContinuousToken, err error)

ReadAttributes reads multiple attributes from the storage based on the given filter and pagination.

func (*DataReader) ReadRelationships added in v0.5.0

func (r *DataReader) ReadRelationships(ctx context.Context, tenantID string, filter *base.TupleFilter, snap string, pagination database.Pagination) (collection *database.TupleCollection, ct database.EncodedContinuousToken, err error)

ReadRelationships reads relation tuples from the storage based on the given filter and pagination.

type DataWriter added in v0.5.0

type DataWriter struct {
	// contains filtered or unexported fields
}

DataWriter - Structure for Data Writer

func NewDataWriter added in v0.5.0

func NewDataWriter(database *db.Postgres, logger logger.Interface) *DataWriter

func (*DataWriter) Delete added in v0.5.0

func (w *DataWriter) Delete(ctx context.Context, tenantID string, tupleFilter *base.TupleFilter, attributeFilter *base.AttributeFilter) (token token.EncodedSnapToken, err error)

func (*DataWriter) Write added in v0.5.0

func (w *DataWriter) Write(ctx context.Context, tenantID string, tupleCollection *database.TupleCollection, attributeCollection *database.AttributeCollection) (token token.EncodedSnapToken, err error)

type SchemaReader

type SchemaReader struct {
	// contains filtered or unexported fields
}

SchemaReader - Structure for SchemaReader

func NewSchemaReader

func NewSchemaReader(database *db.Postgres, logger logger.Interface) *SchemaReader

NewSchemaReader - Creates a new SchemaReader

func (*SchemaReader) HeadVersion

func (r *SchemaReader) HeadVersion(ctx context.Context, tenantID string) (version string, err error)

HeadVersion - Finds the latest version of the schema.

func (*SchemaReader) ReadEntityDefinition added in v0.5.0

func (r *SchemaReader) ReadEntityDefinition(ctx context.Context, tenantID, name, version string) (definition *base.EntityDefinition, v string, err error)

ReadEntityDefinition - Reads entity config from the repository.

func (*SchemaReader) ReadRuleDefinition added in v0.5.0

func (r *SchemaReader) ReadRuleDefinition(ctx context.Context, tenantID, name, version string) (definition *base.RuleDefinition, v string, err error)

ReadRuleDefinition - Reads rule config from the repository.

func (*SchemaReader) ReadSchema

func (r *SchemaReader) ReadSchema(ctx context.Context, tenantID, version string) (sch *base.SchemaDefinition, err error)

ReadSchema - Reads entity config from the repository.

type SchemaWriter

type SchemaWriter struct {
	// contains filtered or unexported fields
}

SchemaWriter - Structure for SchemaWriter

func NewSchemaWriter

func NewSchemaWriter(database *db.Postgres, logger logger.Interface) *SchemaWriter

NewSchemaWriter creates a new SchemaWriter

func (*SchemaWriter) WriteSchema

func (w *SchemaWriter) WriteSchema(ctx context.Context, schemas []storage.SchemaDefinition) (err error)

WriteSchema writes a schema to the database

type TenantReader

type TenantReader struct {
	// contains filtered or unexported fields
}

func NewTenantReader

func NewTenantReader(database *db.Postgres, logger logger.Interface) *TenantReader

NewTenantReader - Creates a new TenantReader

func (*TenantReader) ListTenants

func (r *TenantReader) ListTenants(ctx context.Context, pagination database.Pagination) (tenants []*base.Tenant, ct database.EncodedContinuousToken, err error)

ListTenants - Lists all Tenants

type TenantWriter

type TenantWriter struct {
	// contains filtered or unexported fields
}

TenantWriter - Structure for Tenant Writer

func NewTenantWriter

func NewTenantWriter(database *db.Postgres, logger logger.Interface) *TenantWriter

NewTenantWriter - Creates a new TenantWriter

func (*TenantWriter) CreateTenant

func (w *TenantWriter) CreateTenant(ctx context.Context, id, name string) (result *base.Tenant, err error)

CreateTenant - Creates a new Tenant

func (*TenantWriter) DeleteTenant

func (w *TenantWriter) DeleteTenant(ctx context.Context, tenantID string) (result *base.Tenant, err error)

DeleteTenant - Deletes a Tenant

type Watch added in v0.4.4

type Watch struct {
	// contains filtered or unexported fields
}

Watch is an implementation of the storage.Watch interface, which is used

func NewWatcher added in v0.4.4

func NewWatcher(database *db.Postgres, logger logger.Interface) *Watch

NewWatcher returns a new instance of the Watch.

func (*Watch) Watch added in v0.4.4

func (w *Watch) Watch(ctx context.Context, tenantID, snap string) (<-chan *base.DataChanges, <-chan error)

Watch returns a channel that emits a stream of changes to the relationship tuples in the database.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL