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 *tuple.Relationship) error
- func NewReadOnlyTransactionError(err error) error
- func NewRevisionUnavailableError(err error) error
- func NewSerializationError(err error) error
- func NewSliceRelationshipIterator(rels []tuple.Relationship) datastore.RelationshipIterator
- func RedactAndLogSensitiveConnString(ctx context.Context, baseErr string, err error, pgURL string) error
- func RegisterGCMetrics() error
- func RunGarbageCollection(gc GarbageCollector, window, timeout time.Duration) error
- func StartGarbageCollector(ctx context.Context, gc GarbageCollector, ...) error
- func UpdateRelationshipsInDatastore(ctx context.Context, ds datastore.Datastore, ...) (datastore.Revision, error)
- func WriteRelationships(ctx context.Context, ds datastore.Datastore, op tuple.UpdateOperation, ...) (datastore.Revision, error)
- type Changes
- func (ch *Changes[R, K]) AddChangedDefinition(ctx context.Context, rev R, def datastore.SchemaDefinition) error
- func (ch *Changes[R, K]) AddDeletedCaveat(_ context.Context, rev R, caveatName string) error
- func (ch *Changes[R, K]) AddDeletedNamespace(_ context.Context, rev R, namespaceName string) error
- func (ch *Changes[R, K]) AddRelationshipChange(ctx context.Context, rev R, rel tuple.Relationship, op tuple.UpdateOperation) error
- func (ch *Changes[R, K]) AsRevisionChanges(lessThanFunc func(lhs, rhs K) bool) ([]datastore.RevisionChanges, error)
- func (ch *Changes[R, K]) FilterAndRemoveRevisionChanges(lessThanFunc func(lhs, rhs K) bool, boundRev R) ([]datastore.RevisionChanges, error)
- func (ch *Changes[R, K]) IsEmpty() bool
- func (ch *Changes[R, K]) SetRevisionMetadata(ctx context.Context, rev R, metadata map[string]any) error
- type CreateRelationshipExistsError
- type DeletionCounts
- type ExecuteQueryFunc
- type GarbageCollector
- type MigrationValidator
- type PaginationFilterType
- type QueryExecutor
- type ReadOnlyTransactionError
- type RevisionUnavailableError
- type SchemaInformation
- type SchemaQueryFilterer
- func (sqf SchemaQueryFilterer) After(cursor options.Cursor, order options.SortOrder) 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) FilterWithResourceIDPrefix(prefix string) (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) MustFilterWithResourceIDPrefix(prefix string) SchemaQueryFilterer
- func (sqf SchemaQueryFilterer) MustFilterWithSubjectsSelectors(selectors ...datastore.SubjectsSelector) SchemaQueryFilterer
- func (sqf SchemaQueryFilterer) TupleOrder(order options.SortOrder) SchemaQueryFilterer
- func (sqf SchemaQueryFilterer) UnderlyingQueryBuilder() sq.SelectBuilder
- type SerializationError
- 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 *tuple.Relationship) error
NewCreateRelationshipExistsError creates a new CreateRelationshipExistsError.
func NewReadOnlyTransactionError ¶ added in v1.35.3
NewReadOnlyTransactionError creates a new ReadOnlyTransactionError.
func NewRevisionUnavailableError ¶ added in v1.35.0
NewRevisionUnavailableError creates a new RevisionUnavailableError.
func NewSerializationError ¶ added in v1.26.0
NewSerializationError creates a new SerializationError
func NewSliceRelationshipIterator ¶ added in v1.21.0
func NewSliceRelationshipIterator(rels []tuple.Relationship) datastore.RelationshipIterator
NewSliceRelationshipIterator creates a datastore.RelationshipIterator instance from a materialized slice of tuples.
func RedactAndLogSensitiveConnString ¶ added in v1.27.0
func RedactAndLogSensitiveConnString(ctx context.Context, baseErr string, err error, pgURL string) error
RedactAndLogSensitiveConnString elides the given error, logging it only at trace level (after being redacted).
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 UpdateRelationshipsInDatastore ¶ added in v1.39.0
func UpdateRelationshipsInDatastore(ctx context.Context, ds datastore.Datastore, updates ...tuple.RelationshipUpdate) (datastore.Revision, error)
UpdateRelationshipsInDatastore is a convenience method to perform multiple relation update operations on a Datastore
func WriteRelationships ¶ added in v1.39.0
func WriteRelationships(ctx context.Context, ds datastore.Datastore, op tuple.UpdateOperation, rels ...tuple.Relationship) (datastore.Revision, error)
WriteRelationships is a convenience method to perform the same update operation on a set of relationships
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 datastore 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, content datastore.WatchContent, maxByteSize uint64) *Changes[R, K]
NewChanges creates a new Changes object for change tracking and de-duplication.
func (*Changes[R, K]) AddChangedDefinition ¶ added in v1.29.0
func (ch *Changes[R, K]) AddChangedDefinition( ctx context.Context, rev R, def datastore.SchemaDefinition, ) error
AddChangedDefinition adds a change indicating that the schema definition (namespace or caveat) was changed to the definition given.
func (*Changes[R, K]) AddDeletedCaveat ¶ added in v1.29.0
AddDeletedCaveat adds a change indicating that the caveat with the name was deleted.
func (*Changes[R, K]) AddDeletedNamespace ¶ added in v1.29.0
func (ch *Changes[R, K]) AddDeletedNamespace( _ context.Context, rev R, namespaceName string, ) error
AddDeletedNamespace adds a change indicating that the namespace with the name was deleted.
func (*Changes[R, K]) AddRelationshipChange ¶ added in v1.29.0
func (ch *Changes[R, K]) AddRelationshipChange( ctx context.Context, rev R, rel tuple.Relationship, op tuple.UpdateOperation, ) error
AddRelationshipChange 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, error)
AsRevisionChanges returns the list of changes processed so far as a datastore watch compatible, ordered, changelist.
func (*Changes[R, K]) FilterAndRemoveRevisionChanges ¶ added in v1.29.0
func (ch *Changes[R, K]) FilterAndRemoveRevisionChanges(lessThanFunc func(lhs, rhs K) bool, boundRev R) ([]datastore.RevisionChanges, error)
FilterAndRemoveRevisionChanges filters a list of changes processed up to the bound revision from the changes list, removing them and returning the filtered changes.
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 *tuple.Relationship // contains filtered or unexported fields }
CreateRelationshipExistsError is an error returned when attempting to CREATE an already-existing relationship.
func (CreateRelationshipExistsError) GRPCStatus ¶ added in v1.22.0
func (err CreateRelationshipExistsError) GRPCStatus() *status.Status
GRPCStatus implements retrieving the gRPC status for the error.
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) (datastore.RelationshipIterator, 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 { HasGCRun() bool MarkGCCompleted() ResetGCCompleted() ReadyState(context.Context) (datastore.ReadyState, 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 MigrationValidator ¶ added in v1.39.0
type MigrationValidator struct {
// contains filtered or unexported fields
}
func NewMigrationValidator ¶ added in v1.39.0
func NewMigrationValidator(headMigration string, additionalAllowedMigrations []string) *MigrationValidator
func (*MigrationValidator) MigrationReadyState ¶ added in v1.39.0
func (mv *MigrationValidator) MigrationReadyState(version string) datastore.ReadyState
MigrationReadyState returns the readiness of the datastore for the given version.
type PaginationFilterType ¶ added in v1.21.0
type PaginationFilterType uint8
PaginationFilterType is an enumerator
const ( // TupleComparison uses a comparison with a compound key, // e.g. (namespace, object_id, relation) > ('ns', '123', 'viewer') // which is not compatible with all datastores. TupleComparison PaginationFilterType = iota // ExpandedLogicComparison comparison uses a nested tree of ANDs and ORs to properly // filter out already received relationships. Useful for databases that do not support // tuple comparison, or do not execute it efficiently ExpandedLogicComparison )
type QueryExecutor ¶ added in v1.24.0
type QueryExecutor struct {
Executor ExecuteQueryFunc
}
QueryExecutor is a tuple query runner shared by SQL implementations of the datastore.
func (QueryExecutor) ExecuteQuery ¶ added in v1.24.0
func (tqs QueryExecutor) ExecuteQuery( ctx context.Context, query SchemaQueryFilterer, opts ...options.QueryOptionsOption, ) (datastore.RelationshipIterator, error)
ExecuteQuery executes the query.
type ReadOnlyTransactionError ¶ added in v1.35.3
type ReadOnlyTransactionError struct {
// contains filtered or unexported fields
}
ReadOnlyTransactionError is returned when an otherwise read-write transaction fails on writes with an error indicating that the datastore is currently in a read-only mode.
func (ReadOnlyTransactionError) GRPCStatus ¶ added in v1.35.3
func (err ReadOnlyTransactionError) GRPCStatus() *status.Status
type RevisionUnavailableError ¶ added in v1.35.0
type RevisionUnavailableError struct {
// contains filtered or unexported fields
}
RevisionUnavailableError is returned when a revision is not available on a replica.
type SchemaInformation ¶
type SchemaInformation struct {
// contains filtered or unexported fields
}
SchemaInformation holds the schema information from the SQL datastore implementation.
func NewSchemaInformation ¶ added in v1.21.0
func NewSchemaInformation( colNamespace, colObjectID, colRelation, colUsersetNamespace, colUsersetObjectID, colUsersetRelation, colCaveatName string, paginationFilterType PaginationFilterType, ) SchemaInformation
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, filterMaximumIDCount uint16) SchemaQueryFilterer
NewSchemaQueryFilterer creates a new SchemaQueryFilterer object.
func (SchemaQueryFilterer) After ¶ added in v1.21.0
func (sqf SchemaQueryFilterer) After(cursor options.Cursor, order options.SortOrder) SchemaQueryFilterer
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) FilterWithResourceIDPrefix ¶ added in v1.30.0
func (sqf SchemaQueryFilterer) FilterWithResourceIDPrefix(prefix string) (SchemaQueryFilterer, error)
FilterWithResourceIDPrefix returns new SchemaQueryFilterer that is limited to resources whose ID starts with the specified prefix.
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) MustFilterWithResourceIDPrefix ¶ added in v1.30.0
func (sqf SchemaQueryFilterer) MustFilterWithResourceIDPrefix(prefix string) SchemaQueryFilterer
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).
func (SchemaQueryFilterer) TupleOrder ¶ added in v1.21.0
func (sqf SchemaQueryFilterer) TupleOrder(order options.SortOrder) SchemaQueryFilterer
func (SchemaQueryFilterer) UnderlyingQueryBuilder ¶ added in v1.34.0
func (sqf SchemaQueryFilterer) UnderlyingQueryBuilder() sq.SelectBuilder
type SerializationError ¶ added in v1.26.0
type SerializationError struct {
// contains filtered or unexported fields
}
SerializationError is returned when there's been a serialization error while performing a datastore operation
func (SerializationError) GRPCStatus ¶ added in v1.26.0
func (err SerializationError) GRPCStatus() *status.Status
func (SerializationError) Unwrap ¶ added in v1.26.0
func (err SerializationError) Unwrap() error
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.