Documentation ¶
Index ¶
- Variables
- func ContextualizedCaveatFrom(name string, context map[string]any) (*core.ContextualizedCaveat, error)
- func LogOnError(ctx context.Context, f func() error)
- func NewCreateRelationshipExistsError(relationship *core.RelationTuple) error
- func RegisterGCMetrics() error
- func RunGarbageCollection(gc GarbageCollector, window, timeout time.Duration) error
- func StartGarbageCollector(ctx context.Context, gc GarbageCollector, ...) error
- func UpdateTuplesInDatastore(ctx context.Context, ds datastore.Datastore, ...) (datastore.Revision, error)
- func WithJitter(factor float64, interval time.Duration) time.Duration
- func WriteTuples(ctx context.Context, ds datastore.Datastore, ...) (datastore.Revision, error)
- type Changes
- type CreateRelationshipExistsError
- type DeletionCounts
- type ExecuteQueryFunc
- type GarbageCollector
- type SchemaInformation
- type SchemaQueryFilterer
- func (sqf SchemaQueryFilterer) FilterToRelation(relation string) SchemaQueryFilterer
- func (sqf SchemaQueryFilterer) FilterToResourceID(objectID string) SchemaQueryFilterer
- func (sqf SchemaQueryFilterer) FilterToResourceIDs(resourceIds []string) (SchemaQueryFilterer, error)
- func (sqf SchemaQueryFilterer) FilterToResourceType(resourceType string) SchemaQueryFilterer
- func (sqf SchemaQueryFilterer) FilterToSubjectFilter(filter *v1.SubjectFilter) SchemaQueryFilterer
- func (sqf SchemaQueryFilterer) FilterWithCaveatName(caveatName string) SchemaQueryFilterer
- func (sqf SchemaQueryFilterer) FilterWithRelationshipsFilter(filter datastore.RelationshipsFilter) (SchemaQueryFilterer, error)
- func (sqf SchemaQueryFilterer) FilterWithSubjectsSelectors(selectors ...datastore.SubjectsSelector) (SchemaQueryFilterer, error)
- func (sqf SchemaQueryFilterer) MustFilterToResourceIDs(resourceIds []string) SchemaQueryFilterer
- func (sqf SchemaQueryFilterer) MustFilterWithRelationshipsFilter(filter datastore.RelationshipsFilter) SchemaQueryFilterer
- func (sqf SchemaQueryFilterer) MustFilterWithSubjectsSelectors(selectors ...datastore.SubjectsSelector) SchemaQueryFilterer
- type TupleQuerySplitter
- type TxCleanupFunc
Constants ¶
This section is empty.
Variables ¶
var ( // CaveatNameKey is a tracing attribute representing a caveat name CaveatNameKey = attribute.Key("authzed.com/spicedb/sql/caveatName") // 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") )
var MaxGCInterval = 60 * time.Minute
Functions ¶
func ContextualizedCaveatFrom ¶ added in v1.14.0
func ContextualizedCaveatFrom(name string, context map[string]any) (*core.ContextualizedCaveat, error)
ContextualizedCaveatFrom convenience method that handles creation of a contextualized caveat given the possibility of arguments with zero-values.
func LogOnError ¶ added in v1.14.0
LogOnError executes the function and logs the error. Useful to avoid silently ignoring errors in defer statements
func NewCreateRelationshipExistsError ¶ added in v1.12.0
func NewCreateRelationshipExistsError(relationship *core.RelationTuple) error
NewCreateRelationshipExistsError creates a new CreateRelationshipExistsError.
func RegisterGCMetrics ¶ added in v1.10.0
func RegisterGCMetrics() error
RegisterGCMetrics registers garbage collection metrics to the default registry.
func RunGarbageCollection ¶ added in v1.16.0
func RunGarbageCollection(gc GarbageCollector, window, timeout time.Duration) error
RunGarbageCollection runs garbage collection for the datastore.
func StartGarbageCollector ¶ added in v1.10.0
func StartGarbageCollector(ctx context.Context, gc GarbageCollector, interval, window, timeout time.Duration) error
StartGarbageCollector loops forever until the context is canceled and performs garbage collection on the provided interval.
func UpdateTuplesInDatastore ¶ added in v1.12.0
func UpdateTuplesInDatastore(ctx context.Context, ds datastore.Datastore, updates ...*core.RelationTupleUpdate) (datastore.Revision, error)
UpdateTuplesInDatastore is a convenience method to perform multiple relation update operations on a Datastore
func WithJitter ¶ added in v1.5.0
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.
func WriteTuples ¶ added in v1.12.0
func WriteTuples(ctx context.Context, ds datastore.Datastore, op core.RelationTupleUpdate_Operation, tuples ...*core.RelationTuple) (datastore.Revision, error)
WriteTuples is a convenience method to perform the same update operation on a set of tuples
Types ¶
type Changes ¶ added in v1.3.0
type Changes[R datastore.Revision, K comparable] struct { // contains filtered or unexported fields }
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[R datastore.Revision, K comparable](keyFunc func(R) K) Changes[R, K]
NewChanges creates a new Changes object for change tracking and de-duplication.
func (Changes[R, K]) AddChange ¶ added in v1.3.0
func (ch Changes[R, K]) AddChange( ctx context.Context, rev R, tpl *core.RelationTuple, op core.RelationTupleUpdate_Operation, )
AddChange adds a specific change to the complete list of tracked changes
func (Changes[R, K]) AsRevisionChanges ¶ added in v1.3.0
func (ch Changes[R, K]) AsRevisionChanges(lessThanFunc func(lhs, rhs K) bool) []datastore.RevisionChanges
AsRevisionChanges returns the list of changes processed so far as a datastore watch compatible, ordered, changelist.
type CreateRelationshipExistsError ¶ added in v1.12.0
type CreateRelationshipExistsError struct { // Relationship is the relationship that caused the error. May be nil, depending on the datastore. Relationship *core.RelationTuple // contains filtered or unexported fields }
CreateRelationshipExistsError is an error returned when attempting to CREATE an already-existing relationship.
type DeletionCounts ¶ added in v1.10.0
DeletionCounts tracks the amount of deletions that occurred when calling DeleteBeforeTx.
func (DeletionCounts) MarshalZerologObject ¶ added in v1.10.0
func (g DeletionCounts) MarshalZerologObject(e *zerolog.Event)
type ExecuteQueryFunc ¶ added in v1.5.0
type ExecuteQueryFunc func(ctx context.Context, sql string, args []any) ([]*core.RelationTuple, error)
ExecuteQueryFunc is a function that can be used to execute a single rendered SQL query.
type GarbageCollector ¶ added in v1.10.0
type GarbageCollector interface { IsReady(context.Context) (bool, error) Now(context.Context) (time.Time, error) TxIDBefore(context.Context, time.Time) (datastore.Revision, error) DeleteBeforeTx(ctx context.Context, txID datastore.Revision) (DeletionCounts, error) }
GarbageCollector represents any datastore that supports external garbage collection.
type SchemaInformation ¶
type SchemaInformation struct { TableTuple string ColNamespace string ColObjectID string ColRelation string ColUsersetNamespace string ColUsersetObjectID string ColUsersetRelation string ColCaveatName 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) FilterToResourceIDs ¶ added in v1.12.0
func (sqf SchemaQueryFilterer) FilterToResourceIDs(resourceIds []string) (SchemaQueryFilterer, error)
FilterToResourceIDs returns a new SchemaQueryFilterer that is limited to resources with any of the specified IDs.
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) FilterWithCaveatName ¶ added in v1.14.0
func (sqf SchemaQueryFilterer) FilterWithCaveatName(caveatName string) SchemaQueryFilterer
func (SchemaQueryFilterer) FilterWithRelationshipsFilter ¶ added in v1.12.0
func (sqf SchemaQueryFilterer) FilterWithRelationshipsFilter(filter datastore.RelationshipsFilter) (SchemaQueryFilterer, error)
func (SchemaQueryFilterer) FilterWithSubjectsSelectors ¶ added in v1.16.0
func (sqf SchemaQueryFilterer) FilterWithSubjectsSelectors(selectors ...datastore.SubjectsSelector) (SchemaQueryFilterer, error)
FilterWithSubjectsSelectors returns a new SchemaQueryFilterer that is limited to resources with subjects that match the specified selector(s).
func (SchemaQueryFilterer) MustFilterToResourceIDs ¶ added in v1.16.0
func (sqf SchemaQueryFilterer) MustFilterToResourceIDs(resourceIds []string) SchemaQueryFilterer
func (SchemaQueryFilterer) MustFilterWithRelationshipsFilter ¶ added in v1.16.0
func (sqf SchemaQueryFilterer) MustFilterWithRelationshipsFilter(filter datastore.RelationshipsFilter) SchemaQueryFilterer
MustFilterWithRelationshipsFilter returns a new SchemaQueryFilterer that is limited to resources with resources that match the specified filter.
func (SchemaQueryFilterer) MustFilterWithSubjectsSelectors ¶ added in v1.16.0
func (sqf SchemaQueryFilterer) MustFilterWithSubjectsSelectors(selectors ...datastore.SubjectsSelector) SchemaQueryFilterer
MustFilterWithSubjectsSelectors returns a new SchemaQueryFilterer that is limited to resources with subjects that match the specified selector(s).
type TupleQuerySplitter ¶ added in v1.3.0
type TupleQuerySplitter struct { Executor ExecuteQueryFunc UsersetBatchSize uint16 }
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, opts ...options.QueryOptionsOption, ) (datastore.RelationshipIterator, error)
SplitAndExecuteQuery is used to split up the usersets in a very large query and execute them as separate queries.
type TxCleanupFunc ¶ added in v1.8.0
TxCleanupFunc is a function that should be executed when the caller of TransactionFactory is done with the transaction.