common

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultSplitAtEstimatedQuerySize = 8 * units.MiB

DefaultSplitAtEstimatedQuerySize is the default allowed estimated query size before the TupleQuery will split the query into multiple calls.

In Postgres, it appears to be 1GB: https://dba.stackexchange.com/questions/131399/is-there-a-maximum-length-constraint-for-a-postgres-query In CockroachDB, the maximum is 16MiB: https://www.cockroachlabs.com/docs/stable/known-limitations.html#size-limits-on-statement-input-from-sql-clients As a result, we go with half of that to be on the safe side, since the estimate doesn't include the field names or operators.

Variables

View Source
var (
	// ObjNamespaceNameKey is a tracing attribute representing the resource
	// object type.
	ObjNamespaceNameKey = attribute.Key("authzed.com/spicedb/sql/objNamespaceName")

	// ObjRelationNameKey is a tracing attribute representing the resource
	// relation.
	ObjRelationNameKey = attribute.Key("authzed.com/spicedb/sql/objRelationName")

	// ObjIDKey is a tracing attribute representing the resource object ID.
	ObjIDKey = attribute.Key("authzed.com/spicedb/sql/objId")

	// SubNamespaceNameKey is a tracing attribute representing the subject object
	// type.
	SubNamespaceNameKey = attribute.Key("authzed.com/spicedb/sql/subNamespaceName")

	// SubRelationNameKey is a tracing attribute representing the subject
	// relation.
	SubRelationNameKey = attribute.Key("authzed.com/spicedb/sql/subRelationName")

	// SubObjectIDKey is a tracing attribute representing the the subject object
	// ID.
	SubObjectIDKey = attribute.Key("authzed.com/spicedb/sql/subObjectId")
)

Functions

This section is empty.

Types

type ReverseTupleQuery

type ReverseTupleQuery struct {
	TupleQuery
}

ReverseTupleQuery is a common reverse tuple query implementation for SQL datastore implementations.

func (ReverseTupleQuery) WithObjectRelation

func (ctq ReverseTupleQuery) WithObjectRelation(namespaceName string, relationName string) datastore.ReverseTupleQuery

WithObjectRelation implements the datastore ReverseTupleQuery interface.

type SchemaInformation

type SchemaInformation struct {
	TableTuple          string
	ColNamespace        string
	ColObjectID         string
	ColRelation         string
	ColUsersetNamespace string
	ColUsersetObjectID  string
	ColUsersetRelation  string
}

SchemaInformation holds the schema information from the SQL datastore implementation.

type TransactionPreparer

type TransactionPreparer func(ctx context.Context, tx pgx.Tx, revision datastore.Revision) error

TransactionPreparer is a function provided by the datastore to prepare the transaction before the tuple query is run.

type TupleQuery

type TupleQuery struct {
	Conn               *pgxpool.Pool
	Schema             SchemaInformation
	PrepareTransaction TransactionPreparer

	InitialQuery             sq.SelectBuilder
	InitialQuerySizeEstimate int
	Revision                 datastore.Revision

	Tracer           trace.Tracer
	TracerAttributes []attribute.KeyValue

	DebugName                 string
	SplitAtEstimatedQuerySize units.Base2Bytes
	// contains filtered or unexported fields
}

TupleQuery is a tuple query builder and runner shared by SQL implementations of the datastore.

func (TupleQuery) Execute

func (ctq TupleQuery) Execute(ctx context.Context) (datastore.TupleIterator, error)

Execute implements the datastore.CommonTupleQuery interface

func (TupleQuery) Limit

func (ctq TupleQuery) Limit(limit uint64) datastore.CommonTupleQuery

Limit implements the datastore.CommonTupleQuery interface

func (TupleQuery) ReverseQueryTuplesFromSubject

func (ctq TupleQuery) ReverseQueryTuplesFromSubject(subject *v0.ObjectAndRelation) datastore.ReverseTupleQuery

ReverseQueryTuplesFromSubject constructs a ReverseTupleQuery from this tuple query.

func (TupleQuery) ReverseQueryTuplesFromSubjectNamespace added in v0.0.2

func (ctq TupleQuery) ReverseQueryTuplesFromSubjectNamespace(subjectNamespace string) datastore.ReverseTupleQuery

ReverseQueryTuplesFromSubjectNamespace constructs a ReverseTupleQuery from this tuple query.

func (TupleQuery) ReverseQueryTuplesFromSubjectRelation

func (ctq TupleQuery) ReverseQueryTuplesFromSubjectRelation(subjectNamespace, subjectRelation string) datastore.ReverseTupleQuery

ReverseQueryTuplesFromSubjectRelation constructs a ReverseTupleQuery from this tuple query.

func (TupleQuery) WithSubjectFilter added in v0.0.2

func (ctq TupleQuery) WithSubjectFilter(filter *v1.SubjectFilter) datastore.TupleQuery

WithSubjectFilter implements the datastore.TupleQuery interface

func (TupleQuery) WithUsersets

func (ctq TupleQuery) WithUsersets(usersets []*v0.ObjectAndRelation) datastore.TupleQuery

WithUsersets implements the datastore.TupleQuery interface

Jump to

Keyboard shortcuts

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