postgres

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2024 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

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

Variables

This section is empty.

Functions

This section is empty.

Types

type BundleReader added in v0.6.0

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

func NewBundleReader added in v0.6.0

func NewBundleReader(database *db.Postgres) *BundleReader

func (*BundleReader) Read added in v0.6.0

func (b *BundleReader) Read(ctx context.Context, tenantID, name string) (bundle *base.DataBundle, err error)

type BundleWriter added in v0.6.0

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

func NewBundleWriter added in v0.6.0

func NewBundleWriter(database *db.Postgres) *BundleWriter

func (*BundleWriter) Delete added in v0.6.0

func (b *BundleWriter) Delete(ctx context.Context, tenantID, name string) (err error)

func (*BundleWriter) Write added in v0.6.0

func (b *BundleWriter) Write(ctx context.Context, bundles []storage.Bundle) (names []string, err error)

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) *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, pagination database.CursorPagination) (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, pagination database.CursorPagination) (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) QueryUniqueSubjectReferences added in v0.5.0

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

Delete method removes data from the database based on the provided tuple and attribute filters. It returns an EncodedSnapToken upon successful deletion or an error if the deletion fails.

func (*DataWriter) RunBundle added in v0.6.0

func (w *DataWriter) RunBundle(
	ctx context.Context,
	tenantID string,
	arguments map[string]string,
	b *base.DataBundle,
) (token.EncodedSnapToken, error)

RunBundle executes a bundle of operations in the context of a given tenant. It returns an EncodedSnapToken upon successful completion or an error if the operation fails.

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)

Write method writes a collection of tuples and attributes to the database for a specific tenant. It returns an EncodedSnapToken upon successful write or an error if the write fails.

type SchemaReader

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

SchemaReader - Structure for SchemaReader

func NewSchemaReader

func NewSchemaReader(database *db.Postgres) *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) ListSchemas added in v0.7.5

func (r *SchemaReader) ListSchemas(ctx context.Context, tenantID string, pagination database.Pagination) (schemas []*base.SchemaList, ct database.EncodedContinuousToken, err error)

ListSchemas - List all Schemas

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 returns the schema definition for a specific tenant and version as a structured object.

func (*SchemaReader) ReadSchemaString added in v0.7.9

func (r *SchemaReader) ReadSchemaString(ctx context.Context, tenantID, version string) (definitions []string, err error)

ReadSchemaString returns the schema definition for a specific tenant and version as a string.

type SchemaWriter

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

SchemaWriter - Structure for SchemaWriter

func NewSchemaWriter

func NewSchemaWriter(database *db.Postgres) *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) *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) *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) *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