common

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2022 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

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

func ValidateUpdatesToWrite added in v1.3.0

func ValidateUpdatesToWrite(updates []*v1.RelationshipUpdate) error

ValidateUpdatesToWrite performs basic validation on relationship updates going into datastores.

func WithJitter added in v1.5.0

func WithJitter(factor float64, interval time.Duration) time.Duration

WithJitter adjusts an interval by a random amount within some factor of the original interval. Intervals near half of max int64 can return durations outside the jitter factor.

Types

type Changes added in v1.3.0

type Changes map[revisionKey]*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

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 ExecuteQueryFunc added in v1.5.0

type ExecuteQueryFunc func(ctx context.Context, revision datastore.Revision, sql string, args []interface{}) ([]*core.RelationTuple, error)

ExecuteQueryFunc is a function that can be used to execute a single rendered SQL query.

func NewPGXExecutor added in v1.5.0

func NewPGXExecutor(conn *pgxpool.Pool, prepTxn TransactionPreparer) ExecuteQueryFunc

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.

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 TupleQuerySplitter added in v1.3.0

type TupleQuerySplitter struct {
	Executor         ExecuteQueryFunc
	UsersetBatchSize int
}

TupleQuerySplitter is a tuple query runner shared by SQL implementations of the datastore.

func (TupleQuerySplitter) SplitAndExecuteQuery added in v1.5.0

func (tqs TupleQuerySplitter) SplitAndExecuteQuery(
	ctx context.Context,
	query SchemaQueryFilterer,
	revision datastore.Revision,
	opts ...options.QueryOptionsOption,
) (datastore.TupleIterator, error)

SplitAndExecuteQuery is used to split up the usersets in a very large query and execute them as separate queries.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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