Documentation ¶
Index ¶
- Constants
- Variables
- func ValidateUpdatesToWrite(updates []*v1.RelationshipUpdate) error
- type Changes
- type SchemaInformation
- type SchemaQueryFilterer
- func (sqf SchemaQueryFilterer) FilterToRelation(relation string) SchemaQueryFilterer
- func (sqf SchemaQueryFilterer) FilterToResourceID(objectID string) SchemaQueryFilterer
- func (sqf SchemaQueryFilterer) FilterToResourceType(resourceType string) SchemaQueryFilterer
- func (sqf SchemaQueryFilterer) FilterToSubjectFilter(filter *v1.SubjectFilter) SchemaQueryFilterer
- func (sqf SchemaQueryFilterer) FilterToUsersets(usersets []*v0.ObjectAndRelation) SchemaQueryFilterer
- func (sqf SchemaQueryFilterer) Limit(limit uint64) SchemaQueryFilterer
- type TransactionPreparer
- type TupleQuerySplitter
Constants ¶
const DefaultSplitAtEstimatedQuerySize = 8 * units.MiB
DefaultSplitAtEstimatedQuerySize is the default allowed estimated query size before the TupleQuerySplitter 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 ¶
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 ¶
func ValidateUpdatesToWrite ¶ added in v1.3.0
func ValidateUpdatesToWrite(updates []*v1.RelationshipUpdate) error
ValidateUpdatesToWrite performs basic validation on relationship updates going into datastores.
Types ¶
type Changes ¶ added in v1.3.0
type Changes map[uint64]*changeRecord
Changes represents a set of tuple mutations that are kept self-consistent across one or more transaction revisions.
func NewChanges ¶ added in v1.3.0
func NewChanges() Changes
NewChanges creates a new Changes object for change tracking and de-duplication.
func (Changes) AddChange ¶ added in v1.3.0
func (ch Changes) AddChange( ctx context.Context, revTxID uint64, tpl *v0.RelationTuple, op v0.RelationTupleUpdate_Operation, )
AddChange adds a specific change to the complete list of tracked changes
func (Changes) AsRevisionChanges ¶ added in v1.3.0
func (ch Changes) AsRevisionChanges() (changes []*datastore.RevisionChanges)
AsRevisionChanges returns the list of changes processed so far as a datastore watch compatible, ordered, changelist.
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 SchemaQueryFilterer ¶ added in v1.3.0
type SchemaQueryFilterer struct {
// contains filtered or unexported fields
}
SchemaQueryFilterer wraps a SchemaInformation and SelectBuilder to give an opinionated way to build query objects.
func NewSchemaQueryFilterer ¶ added in v1.3.0
func NewSchemaQueryFilterer(schema SchemaInformation, initialQuery sq.SelectBuilder) SchemaQueryFilterer
NewSchemaQueryFilterer creates a new SchemaQueryFilterer object.
func (SchemaQueryFilterer) FilterToRelation ¶ added in v1.3.0
func (sqf SchemaQueryFilterer) FilterToRelation(relation string) SchemaQueryFilterer
FilterToRelation returns a new SchemaQueryFilterer that is limited to resources with the specified relation.
func (SchemaQueryFilterer) FilterToResourceID ¶ added in v1.3.0
func (sqf SchemaQueryFilterer) FilterToResourceID(objectID string) SchemaQueryFilterer
FilterToResourceID returns a new SchemaQueryFilterer that is limited to resources with the specified ID.
func (SchemaQueryFilterer) FilterToResourceType ¶ added in v1.3.0
func (sqf SchemaQueryFilterer) FilterToResourceType(resourceType string) SchemaQueryFilterer
FilterToResourceType returns a new SchemaQueryFilterer that is limited to resources of the specified type.
func (SchemaQueryFilterer) FilterToSubjectFilter ¶ added in v1.3.0
func (sqf SchemaQueryFilterer) FilterToSubjectFilter(filter *v1.SubjectFilter) SchemaQueryFilterer
FilterToSubjectFilter returns a new SchemaQueryFilterer that is limited to resources with subjects that match the specified filter.
func (SchemaQueryFilterer) FilterToUsersets ¶ added in v1.3.0
func (sqf SchemaQueryFilterer) FilterToUsersets(usersets []*v0.ObjectAndRelation) SchemaQueryFilterer
FilterToUsersets returns a new SchemaQueryFilterer that is limited to resources with subjects in the specified list of usersets.
func (SchemaQueryFilterer) Limit ¶ added in v1.3.0
func (sqf SchemaQueryFilterer) Limit(limit uint64) SchemaQueryFilterer
Limit returns a new SchemaQueryFilterer which is limited to the specified number of results.
type TransactionPreparer ¶
TransactionPreparer is a function provided by the datastore to prepare the transaction before the tuple query is run.
type TupleQuerySplitter ¶ added in v1.3.0
type TupleQuerySplitter struct { Conn *pgxpool.Pool PrepareTransaction TransactionPreparer SplitAtEstimatedQuerySize units.Base2Bytes FilteredQueryBuilder SchemaQueryFilterer Revision datastore.Revision Limit *uint64 Usersets []*v0.ObjectAndRelation DebugName string Tracer trace.Tracer }
TupleQuerySplitter is a tuple query runner shared by SQL implementations of the datastore.
func (TupleQuerySplitter) SplitAndExecute ¶ added in v1.3.0
func (ctq TupleQuerySplitter) SplitAndExecute(ctx context.Context) (datastore.TupleIterator, error)
SplitAndExecute executes one or more SQL queries based on the data bound to the TupleQuerySplitter instance.