Documentation
¶
Overview ¶
Code generated by github.com/ecordell/optgen. DO NOT EDIT.
Index ¶
- Constants
- Variables
- func BuildLikePrefixClause(columnName string, prefix string) (sq.Like, error)
- func ColumnsToSelect[CN any, CC any, EC any](b RelationshipsQueryBuilder, resourceObjectType *string, ...) ([]any, error)
- func ContextualizedCaveatFrom(name string, context map[string]any) (*core.ContextualizedCaveat, error)
- func IsCancellationError(err error) bool
- func IsResettableError(err error) bool
- func LogOnError(ctx context.Context, f func() error)
- func MetricsIDFromURL(dsURL string) (string, error)
- func NewReadOnlyTransactionError(err error) error
- func NewRevisionUnavailableError(err error) error
- func NewSerializationError(err error) error
- func NewSliceRelationshipIterator(rels []tuple.Relationship) datastore.RelationshipIterator
- func NewWriteOverLimitError(err error) error
- func QueryRelationships[R Rows, C ~map[string]any](ctx context.Context, builder RelationshipsQueryBuilder, tx Querier[R], ...) (datastore.RelationshipIterator, error)
- func RedactAndLogSensitiveConnString(ctx context.Context, baseErr string, err error, pgURL string) error
- func UpdateRelationshipsInDatastore(ctx context.Context, ds datastore.Datastore, ...) (datastore.Revision, error)
- func WatchBufferSize(sizeString string) (size uint64, err 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]) AddRevisionMetadata(ctx context.Context, rev R, metadata TransactionMetadata) error
- func (ch *Changes[R, K]) AsRevisionChanges(lessThanFunc func(lhs K, 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
- type ChunkedBytesExecutor
- type ChunkedBytesTransaction
- type ColumnOptimizationOption
- type ExecuteReadRelsQueryFunc
- type IndexDefinition
- type IndexingHint
- type MigrationValidator
- type PaginationFilterType
- type Querier
- type QueryRelationshipsExecutor
- type ReadOnlyTransactionError
- type RelationshipsQueryBuilder
- type RevisionUnavailableError
- type Rows
- type SQLByteChunker
- func (c *SQLByteChunker[T]) DeleteChunkedBytes(ctx context.Context, name string, deletedAtValue T) error
- func (c *SQLByteChunker[T]) ReadChunkedBytes(ctx context.Context, name string) ([]byte, error)
- func (c *SQLByteChunker[T]) WriteChunkedBytes(ctx context.Context, name string, data []byte, createdAtValue T) error
- type SQLByteChunkerConfig
- type SchemaInformation
- type SchemaInformationOption
- func SetIndexes(indexes []IndexDefinition) SchemaInformationOption
- func SetSortByResourceColumnOrder(sortByResourceColumnOrder []string) SchemaInformationOption
- func SetSortBySubjectColumnOrder(sortBySubjectColumnOrder []string) SchemaInformationOption
- func WithColCaveatContext(colCaveatContext string) SchemaInformationOption
- func WithColCaveatName(colCaveatName string) SchemaInformationOption
- func WithColExpiration(colExpiration string) SchemaInformationOption
- func WithColIntegrityHash(colIntegrityHash string) SchemaInformationOption
- func WithColIntegrityKeyID(colIntegrityKeyID string) SchemaInformationOption
- func WithColIntegrityTimestamp(colIntegrityTimestamp string) SchemaInformationOption
- func WithColNamespace(colNamespace string) SchemaInformationOption
- func WithColObjectID(colObjectID string) SchemaInformationOption
- func WithColRelation(colRelation string) SchemaInformationOption
- func WithColUsersetNamespace(colUsersetNamespace string) SchemaInformationOption
- func WithColUsersetObjectID(colUsersetObjectID string) SchemaInformationOption
- func WithColUsersetRelation(colUsersetRelation string) SchemaInformationOption
- func WithColumnOptimization(columnOptimization ColumnOptimizationOption) SchemaInformationOption
- func WithExpirationDisabled(expirationDisabled bool) SchemaInformationOption
- func WithIndexes(indexes IndexDefinition) SchemaInformationOption
- func WithIntegrityEnabled(integrityEnabled bool) SchemaInformationOption
- func WithNowFunction(nowFunction string) SchemaInformationOption
- func WithPaginationFilterType(paginationFilterType PaginationFilterType) SchemaInformationOption
- func WithPlaceholderFormat(placeholderFormat squirrel.PlaceholderFormat) SchemaInformationOption
- func WithRelationshipTableName(relationshipTableName string) SchemaInformationOption
- func WithSortByResourceColumnOrder(sortByResourceColumnOrder string) SchemaInformationOption
- func WithSortBySubjectColumnOrder(sortBySubjectColumnOrder string) SchemaInformationOption
- type SchemaQueryFilterer
- func (sqf SchemaQueryFilterer) After(cursor options.Cursor, order options.SortOrder) (SchemaQueryFilterer, error)
- 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) FilterWithNoCaveat() 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) MustAfter(cursor options.Cursor, order options.SortOrder) SchemaQueryFilterer
- 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
- func (sqf SchemaQueryFilterer) WithAdditionalFilter(filter func(original sq.SelectBuilder) sq.SelectBuilder) SchemaQueryFilterer
- func (sqf SchemaQueryFilterer) WithFromSuffix(fromSuffix string) SchemaQueryFilterer
- func (sqf SchemaQueryFilterer) WithFromTable(fromTable string) SchemaQueryFilterer
- func (sqf SchemaQueryFilterer) WithIndexingHint(indexingHint IndexingHint) SchemaQueryFilterer
- type SerializationError
- type TransactionMetadata
- type WriteMode
- type WriteOverLimitError
Constants ¶
const ( PaginationFilterTypeUnknown PaginationFilterType = iota // 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 = 1 // 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 = 2 )
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") )
Functions ¶
func BuildLikePrefixClause ¶ added in v1.44.0
BuildLikePrefixClause builds a LIKE clause for the given column name and prefix.
func ColumnsToSelect ¶ added in v1.40.0
func ColumnsToSelect[CN any, CC any, EC any]( b RelationshipsQueryBuilder, resourceObjectType *string, resourceObjectID *string, resourceRelation *string, subjectObjectType *string, subjectObjectID *string, subjectRelation *string, caveatName *CN, caveatCtx *CC, expiration EC, integrityKeyID *string, integrityHash *[]byte, timestamp *time.Time, ) ([]any, error)
ColumnsToSelect returns the columns to select for a given query. The columns provided are the references to the slots in which the values for each relationship will be placed.
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 IsCancellationError ¶ added in v1.41.0
IsCancellationError determines if an error returned by pgx has been caused by context cancellation.
func IsResettableError ¶ added in v1.41.0
IsResettableError returns whether the given error is a resettable error.
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 MetricsIDFromURL ¶ added in v1.42.0
MetricsIDFromURL extracts the metrics ID from a given datastore URL.
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 NewWriteOverLimitError ¶ added in v1.45.2
NewWriteOverLimitError creates a new WriteOverLimitError.
func QueryRelationships ¶ added in v1.40.0
func QueryRelationships[R Rows, C ~map[string]any](ctx context.Context, builder RelationshipsQueryBuilder, tx Querier[R], explainable datastore.Explainable) (datastore.RelationshipIterator, error)
QueryRelationships queries relationships for the given query and transaction.
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 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 WatchBufferSize ¶ added in v1.49.0
WatchBufferSize takes a string and interprets it as either a percentage of memory (as a percentage of 75% of free memory as measured on startup) or a humanized byte string and returns the number of bytes or an error if the value cannot be interpreted. Returns 0 on an empty string.
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. It is thread-safe.
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]) AddRevisionMetadata ¶ added in v1.45.4
func (ch *Changes[R, K]) AddRevisionMetadata(ctx context.Context, rev R, metadata TransactionMetadata) error
AddRevisionMetadata adds the metadata for the given revision.
func (*Changes[R, K]) AsRevisionChanges ¶ added in v1.3.0
func (ch *Changes[R, K]) AsRevisionChanges(lessThanFunc func(lhs K, 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 ChunkedBytesExecutor ¶ added in v1.47.1
type ChunkedBytesExecutor interface {
// BeginTransaction starts a new transaction for chunked byte operations.
BeginTransaction(ctx context.Context) (ChunkedBytesTransaction, error)
// ExecuteRead executes a SELECT query and returns the results as a map of chunk index to chunk data.
ExecuteRead(ctx context.Context, builder sq.SelectBuilder) (map[int][]byte, error)
}
ChunkedBytesExecutor defines the interface for creating transactions for chunked byte operations.
type ChunkedBytesTransaction ¶ added in v1.47.1
type ChunkedBytesTransaction interface {
// ExecuteWrite executes an INSERT query.
ExecuteWrite(ctx context.Context, builder sq.InsertBuilder) error
// ExecuteDelete executes a DELETE query.
ExecuteDelete(ctx context.Context, builder sq.DeleteBuilder) error
// ExecuteUpdate executes an UPDATE query.
ExecuteUpdate(ctx context.Context, builder sq.UpdateBuilder) error
}
ChunkedBytesTransaction defines the interface for executing SQL queries within a transaction.
type ColumnOptimizationOption ¶ added in v1.40.0
type ColumnOptimizationOption int
ColumnOptimizationOption is an enumerator for column optimization options.
const ( ColumnOptimizationOptionUnknown ColumnOptimizationOption = iota // ColumnOptimizationOptionNone is the default option, which does not optimize the static columns. ColumnOptimizationOptionNone // ColumnOptimizationOptionStaticValues is an option that optimizes columns for static values. ColumnOptimizationOptionStaticValues )
type ExecuteReadRelsQueryFunc ¶ added in v1.40.0
type ExecuteReadRelsQueryFunc func(ctx context.Context, builder RelationshipsQueryBuilder) (datastore.RelationshipIterator, error)
ExecuteReadRelsQueryFunc is a function that can be used to execute a single rendered SQL query.
type IndexDefinition ¶ added in v1.42.0
type IndexDefinition struct {
// Name is the unique name for the index.
Name string
// ColumnsSQL is the SQL fragment of the columns over which this index will apply.
ColumnsSQL string
// Shapes are those query shapes for which this index should be used.
Shapes []queryshape.Shape
// IsDeprecated is true if this index is deprecated and should not be used.
IsDeprecated bool
// PreferredSortOrder is the preferred sort order for this index, if any.
PreferredSortOrder options.SortOrder
}
IndexDefinition is a definition of an index for a datastore.
type IndexingHint ¶ added in v1.43.0
type IndexingHint interface {
// SQLPrefix returns the SQL prefix to be used for the indexing hint, if any.
SQLPrefix() (string, error)
// FromTable returns the table name to be used for the indexing hint, if any.
FromTable(existingTableName string) (string, error)
// FromSQLSuffix returns the suffix to be used for the indexing hint, if any.
FromSQLSuffix() (string, error)
// SortOrder returns the preferred sort order for this index, if any.
SortOrder() options.SortOrder
}
IndexingHint is an interface that can be implemented to provide a hint for the SQL query.
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 for pagination filter types.
type Querier ¶ added in v1.40.0
type Querier[R Rows] interface { QueryFunc(ctx context.Context, f func(context.Context, R) error, sql string, args ...any) error }
Querier is an interface for querying the database.
type QueryRelationshipsExecutor ¶ added in v1.40.0
type QueryRelationshipsExecutor struct {
Executor ExecuteReadRelsQueryFunc
}
QueryRelationshipsExecutor is a relationships query runner shared by SQL implementations of the datastore.
func (QueryRelationshipsExecutor) ExecuteQuery ¶ added in v1.40.0
func (exc QueryRelationshipsExecutor) 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 RelationshipsQueryBuilder ¶ added in v1.40.0
type RelationshipsQueryBuilder struct {
Schema SchemaInformation
SkipCaveats bool
SkipExpiration bool
SQLCheckAssertionForTest options.SQLCheckAssertionForTest
SQLExplainCallbackForTest options.SQLExplainCallbackForTest
// contains filtered or unexported fields
}
RelationshipsQueryBuilder is a builder for producing the SQL and arguments necessary for reading relationships.
func (RelationshipsQueryBuilder) FilteringValuesForTesting ¶ added in v1.40.0
func (b RelationshipsQueryBuilder) FilteringValuesForTesting() map[string]columnTracker
FilteringValuesForTesting returns the filtering values. For test use only.
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 SQLByteChunker ¶ added in v1.47.1
type SQLByteChunker[T any] struct { // contains filtered or unexported fields }
SQLByteChunker provides methods for reading and writing byte data that is chunked across multiple rows in a SQL table.
func MustNewSQLByteChunker ¶ added in v1.47.1
func MustNewSQLByteChunker[T any](config SQLByteChunkerConfig[T]) *SQLByteChunker[T]
MustNewSQLByteChunker creates a new SQLByteChunker with the specified configuration. Panics if the configuration is invalid.
func (*SQLByteChunker[T]) DeleteChunkedBytes ¶ added in v1.47.1
func (c *SQLByteChunker[T]) DeleteChunkedBytes( ctx context.Context, name string, deletedAtValue T, ) error
DeleteChunkedBytes deletes or tombstones all chunks for a given name within a transaction.
Parameters:
- ctx: Context for the operation
- name: The unique identifier for the byte data to delete
- deletedAtValue: The value to write to the deleted_at column (typically a transaction ID or timestamp). Required when using WriteModeInsertWithTombstones. For WriteModeDeleteAndInsert, this parameter is ignored.
func (*SQLByteChunker[T]) ReadChunkedBytes ¶ added in v1.47.1
ReadChunkedBytes reads and reassembles chunked byte data from the database.
Parameters:
- ctx: Context for the operation
- name: The unique identifier for the byte data to read
Returns the reassembled byte data or an error if chunks are missing or invalid.
func (*SQLByteChunker[T]) WriteChunkedBytes ¶ added in v1.47.1
func (c *SQLByteChunker[T]) WriteChunkedBytes( ctx context.Context, name string, data []byte, createdAtValue T, ) error
WriteChunkedBytes writes chunked byte data to the database within a transaction.
Parameters:
- ctx: Context for the operation
- name: The unique identifier for this byte data
- data: The bytes to be chunked and stored
- createdAtValue: The value for the created_at column (typically a transaction ID or timestamp). Required when using WriteModeInsertWithTombstones. For WriteModeDeleteAndInsert, this parameter is ignored.
type SQLByteChunkerConfig ¶ added in v1.47.1
type SQLByteChunkerConfig[T any] struct { // TableName is the name of the table storing the chunked data. TableName string // NameColumn is the column name that stores the identifier for the byte data. NameColumn string // ChunkIndexColumn is the column name that stores the chunk index (0-based). ChunkIndexColumn string // ChunkDataColumn is the column name that stores the chunk bytes. ChunkDataColumn string // MaxChunkSize is the maximum size in bytes for each chunk. MaxChunkSize int // PlaceholderFormat is the placeholder format for SQL queries (e.g., sq.Question, sq.Dollar). PlaceholderFormat sq.PlaceholderFormat // Executor is the executor for running SQL queries. Executor ChunkedBytesExecutor // WriteMode defines how chunked data should be written (insert-with-tombstones or delete-and-insert). WriteMode WriteMode // CreatedAtColumn is the column name that stores when a row was created (alive timestamp/transaction ID). // Required when WriteMode is WriteModeInsertWithTombstones. CreatedAtColumn string // DeletedAtColumn is the column name that stores when a row was deleted (tombstone timestamp/transaction ID). // Required when WriteMode is WriteModeInsertWithTombstones. DeletedAtColumn string // AliveValue is the value used to indicate a row has not been deleted yet (typically max int). // Required when WriteMode is WriteModeInsertWithTombstones. AliveValue T }
SQLByteChunkerConfig contains the configuration for creating a SQLByteChunker.
type SchemaInformation ¶
type SchemaInformation struct {
RelationshipTableName string `debugmap:"visible"`
ColNamespace string `debugmap:"visible"`
ColObjectID string `debugmap:"visible"`
ColRelation string `debugmap:"visible"`
ColUsersetNamespace string `debugmap:"visible"`
ColUsersetObjectID string `debugmap:"visible"`
ColUsersetRelation string `debugmap:"visible"`
ColCaveatName string `debugmap:"visible"`
ColCaveatContext string `debugmap:"visible"`
ColExpiration string `debugmap:"visible"`
ColIntegrityKeyID string `debugmap:"visible"`
ColIntegrityHash string `debugmap:"visible"`
ColIntegrityTimestamp string `debugmap:"visible"`
// Indexes are the indexes to use for this schema.
Indexes []IndexDefinition `debugmap:"visible"`
// PaginationFilterType is the type of pagination filter to use for this schema.
PaginationFilterType PaginationFilterType `debugmap:"visible"`
// PlaceholderFormat is the format of placeholders to use for this schema.
PlaceholderFormat sq.PlaceholderFormat `debugmap:"visible"`
// NowFunction is the function to use to get the current time in the datastore.
NowFunction string `debugmap:"visible"`
// ColumnOptimization is the optimization to use for columns in the schema, if any.
ColumnOptimization ColumnOptimizationOption `debugmap:"visible"`
// IntegrityEnabled is a flag to indicate if the schema has integrity columns.
IntegrityEnabled bool `debugmap:"visible"`
// ExpirationDisabled is a flag to indicate whether expiration support is disabled.
ExpirationDisabled bool `debugmap:"visible"`
// SortByResourceColumnOrder is the order of the resource columns in the schema to use
// when sorting by resource. If unspecified, the default will be used.
SortByResourceColumnOrder []string `debugmap:"visible"`
// SortBySubjectColumnOrder is the order of the subject columns in the schema to use
// when sorting by subject. If unspecified, the default will be used.
SortBySubjectColumnOrder []string `debugmap:"visible"`
}
SchemaInformation holds the schema information from the SQL datastore implementation.
func NewSchemaInformationWithOptions ¶ added in v1.40.0
func NewSchemaInformationWithOptions(opts ...SchemaInformationOption) *SchemaInformation
NewSchemaInformationWithOptions creates a new SchemaInformation with the passed in options set
func NewSchemaInformationWithOptionsAndDefaults ¶ added in v1.40.0
func NewSchemaInformationWithOptionsAndDefaults(opts ...SchemaInformationOption) *SchemaInformation
NewSchemaInformationWithOptionsAndDefaults creates a new SchemaInformation with the passed in options set starting from the defaults
func SchemaInformationWithOptions ¶ added in v1.40.0
func SchemaInformationWithOptions(s *SchemaInformation, opts ...SchemaInformationOption) *SchemaInformation
SchemaInformationWithOptions configures an existing SchemaInformation with the passed in options set
func (*SchemaInformation) DebugMap ¶ added in v1.40.0
func (s *SchemaInformation) DebugMap() map[string]any
DebugMap returns a map form of SchemaInformation for debugging
func (*SchemaInformation) FlatDebugMap ¶ added in v1.49.0
func (s *SchemaInformation) FlatDebugMap() map[string]any
FlatDebugMap returns a flattened map form of SchemaInformation for debugging Nested maps are flattened using dot notation (e.g., "parent.child.field")
func (*SchemaInformation) ToOption ¶ added in v1.40.0
func (s *SchemaInformation) ToOption() SchemaInformationOption
ToOption returns a new SchemaInformationOption that sets the values from the passed in SchemaInformation
func (*SchemaInformation) WithOptions ¶ added in v1.40.0
func (s *SchemaInformation) WithOptions(opts ...SchemaInformationOption) *SchemaInformation
WithOptions configures the receiver SchemaInformation with the passed in options set
type SchemaInformationOption ¶ added in v1.40.0
type SchemaInformationOption func(s *SchemaInformation)
func SetIndexes ¶ added in v1.42.0
func SetIndexes(indexes []IndexDefinition) SchemaInformationOption
SetIndexes returns an option that can set Indexes on a SchemaInformation
func SetSortByResourceColumnOrder ¶ added in v1.43.0
func SetSortByResourceColumnOrder(sortByResourceColumnOrder []string) SchemaInformationOption
SetSortByResourceColumnOrder returns an option that can set SortByResourceColumnOrder on a SchemaInformation
func SetSortBySubjectColumnOrder ¶ added in v1.43.0
func SetSortBySubjectColumnOrder(sortBySubjectColumnOrder []string) SchemaInformationOption
SetSortBySubjectColumnOrder returns an option that can set SortBySubjectColumnOrder on a SchemaInformation
func WithColCaveatContext ¶ added in v1.40.0
func WithColCaveatContext(colCaveatContext string) SchemaInformationOption
WithColCaveatContext returns an option that can set ColCaveatContext on a SchemaInformation
func WithColCaveatName ¶ added in v1.40.0
func WithColCaveatName(colCaveatName string) SchemaInformationOption
WithColCaveatName returns an option that can set ColCaveatName on a SchemaInformation
func WithColExpiration ¶ added in v1.40.0
func WithColExpiration(colExpiration string) SchemaInformationOption
WithColExpiration returns an option that can set ColExpiration on a SchemaInformation
func WithColIntegrityHash ¶ added in v1.40.0
func WithColIntegrityHash(colIntegrityHash string) SchemaInformationOption
WithColIntegrityHash returns an option that can set ColIntegrityHash on a SchemaInformation
func WithColIntegrityKeyID ¶ added in v1.40.0
func WithColIntegrityKeyID(colIntegrityKeyID string) SchemaInformationOption
WithColIntegrityKeyID returns an option that can set ColIntegrityKeyID on a SchemaInformation
func WithColIntegrityTimestamp ¶ added in v1.40.0
func WithColIntegrityTimestamp(colIntegrityTimestamp string) SchemaInformationOption
WithColIntegrityTimestamp returns an option that can set ColIntegrityTimestamp on a SchemaInformation
func WithColNamespace ¶ added in v1.40.0
func WithColNamespace(colNamespace string) SchemaInformationOption
WithColNamespace returns an option that can set ColNamespace on a SchemaInformation
func WithColObjectID ¶ added in v1.40.0
func WithColObjectID(colObjectID string) SchemaInformationOption
WithColObjectID returns an option that can set ColObjectID on a SchemaInformation
func WithColRelation ¶ added in v1.40.0
func WithColRelation(colRelation string) SchemaInformationOption
WithColRelation returns an option that can set ColRelation on a SchemaInformation
func WithColUsersetNamespace ¶ added in v1.40.0
func WithColUsersetNamespace(colUsersetNamespace string) SchemaInformationOption
WithColUsersetNamespace returns an option that can set ColUsersetNamespace on a SchemaInformation
func WithColUsersetObjectID ¶ added in v1.40.0
func WithColUsersetObjectID(colUsersetObjectID string) SchemaInformationOption
WithColUsersetObjectID returns an option that can set ColUsersetObjectID on a SchemaInformation
func WithColUsersetRelation ¶ added in v1.40.0
func WithColUsersetRelation(colUsersetRelation string) SchemaInformationOption
WithColUsersetRelation returns an option that can set ColUsersetRelation on a SchemaInformation
func WithColumnOptimization ¶ added in v1.40.0
func WithColumnOptimization(columnOptimization ColumnOptimizationOption) SchemaInformationOption
WithColumnOptimization returns an option that can set ColumnOptimization on a SchemaInformation
func WithExpirationDisabled ¶ added in v1.40.0
func WithExpirationDisabled(expirationDisabled bool) SchemaInformationOption
WithExpirationDisabled returns an option that can set ExpirationDisabled on a SchemaInformation
func WithIndexes ¶ added in v1.42.0
func WithIndexes(indexes IndexDefinition) SchemaInformationOption
WithIndexes returns an option that can append Indexess to SchemaInformation.Indexes
func WithIntegrityEnabled ¶ added in v1.40.0
func WithIntegrityEnabled(integrityEnabled bool) SchemaInformationOption
WithIntegrityEnabled returns an option that can set IntegrityEnabled on a SchemaInformation
func WithNowFunction ¶ added in v1.40.0
func WithNowFunction(nowFunction string) SchemaInformationOption
WithNowFunction returns an option that can set NowFunction on a SchemaInformation
func WithPaginationFilterType ¶ added in v1.40.0
func WithPaginationFilterType(paginationFilterType PaginationFilterType) SchemaInformationOption
WithPaginationFilterType returns an option that can set PaginationFilterType on a SchemaInformation
func WithPlaceholderFormat ¶ added in v1.40.0
func WithPlaceholderFormat(placeholderFormat squirrel.PlaceholderFormat) SchemaInformationOption
WithPlaceholderFormat returns an option that can set PlaceholderFormat on a SchemaInformation
func WithRelationshipTableName ¶ added in v1.40.0
func WithRelationshipTableName(relationshipTableName string) SchemaInformationOption
WithRelationshipTableName returns an option that can set RelationshipTableName on a SchemaInformation
func WithSortByResourceColumnOrder ¶ added in v1.43.0
func WithSortByResourceColumnOrder(sortByResourceColumnOrder string) SchemaInformationOption
WithSortByResourceColumnOrder returns an option that can append SortByResourceColumnOrders to SchemaInformation.SortByResourceColumnOrder
func WithSortBySubjectColumnOrder ¶ added in v1.43.0
func WithSortBySubjectColumnOrder(sortBySubjectColumnOrder string) SchemaInformationOption
WithSortBySubjectColumnOrder returns an option that can append SortBySubjectColumnOrders to SchemaInformation.SortBySubjectColumnOrder
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 NewSchemaQueryFiltererForRelationshipsSelect ¶ added in v1.40.0
func NewSchemaQueryFiltererForRelationshipsSelect(schema SchemaInformation, filterMaximumIDCount uint16, extraFields ...string) SchemaQueryFilterer
NewSchemaQueryFiltererForRelationshipsSelect creates a new SchemaQueryFilterer object for selecting relationships. This method will automatically filter the columns retrieved from the database, only selecting the columns that are not already specified with a single static value in the query.
func NewSchemaQueryFiltererWithStartingQuery ¶ added in v1.40.0
func NewSchemaQueryFiltererWithStartingQuery(schema SchemaInformation, startingQuery sq.SelectBuilder, filterMaximumIDCount uint16) SchemaQueryFilterer
NewSchemaQueryFiltererWithStartingQuery creates a new SchemaQueryFilterer object for selecting relationships, with a custom starting query. Unlike NewSchemaQueryFiltererForRelationshipsSelect, this method will not auto-filter the columns retrieved from the database.
func (SchemaQueryFilterer) After ¶ added in v1.21.0
func (sqf SchemaQueryFilterer) After(cursor options.Cursor, order options.SortOrder) (SchemaQueryFilterer, error)
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
FilterWithCaveatName returns a new SchemaQueryFilterer that is limited to resources with the specified caveat name.
func (SchemaQueryFilterer) FilterWithNoCaveat ¶ added in v1.43.0
func (sqf SchemaQueryFilterer) FilterWithNoCaveat() SchemaQueryFilterer
FilterWithNoCaveat returns a new SchemaQueryFilterer that is limited to resources with no caveat.
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) MustAfter ¶ added in v1.43.0
func (sqf SchemaQueryFilterer) MustAfter(cursor options.Cursor, order options.SortOrder) SchemaQueryFilterer
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
func (SchemaQueryFilterer) WithAdditionalFilter ¶ added in v1.40.0
func (sqf SchemaQueryFilterer) WithAdditionalFilter(filter func(original sq.SelectBuilder) sq.SelectBuilder) SchemaQueryFilterer
WithAdditionalFilter returns the SchemaQueryFilterer with an additional filter applied to the query.
func (SchemaQueryFilterer) WithFromSuffix ¶ added in v1.40.0
func (sqf SchemaQueryFilterer) WithFromSuffix(fromSuffix string) SchemaQueryFilterer
WithFromSuffix returns the SchemaQueryFilterer with a suffix added to the FROM clause.
func (SchemaQueryFilterer) WithFromTable ¶ added in v1.43.0
func (sqf SchemaQueryFilterer) WithFromTable(fromTable string) SchemaQueryFilterer
WithFromTable returns the SchemaQueryFilterer with a custom FROM table.
func (SchemaQueryFilterer) WithIndexingHint ¶ added in v1.43.0
func (sqf SchemaQueryFilterer) WithIndexingHint(indexingHint IndexingHint) SchemaQueryFilterer
WithIndexingHint returns the SchemaQueryFilterer with an indexing hint applied to the query.
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 TransactionMetadata ¶ added in v1.48.0
func (TransactionMetadata) Equals ¶ added in v1.48.0
func (tm TransactionMetadata) Equals(other TransactionMetadata) bool
func (TransactionMetadata) Len ¶ added in v1.48.0
func (tm TransactionMetadata) Len() int
func (TransactionMetadata) MustStruct ¶ added in v1.48.0
func (tm TransactionMetadata) MustStruct() *structpb.Struct
func (*TransactionMetadata) Scan ¶ added in v1.48.0
func (tm *TransactionMetadata) Scan(val any) error
type WriteMode ¶ added in v1.47.1
type WriteMode int
WriteMode defines how chunked data should be written.
const ( // WriteModeInsertWithTombstones inserts new chunks and marks old chunks with a tombstone. // Requires TombstoneColumn to be set in config. WriteModeInsertWithTombstones WriteMode = iota // WriteModeDeleteAndInsert deletes all existing chunks for the key before inserting new ones. // Useful for replacing data completely. WriteModeDeleteAndInsert )
type WriteOverLimitError ¶ added in v1.45.2
type WriteOverLimitError struct {
// contains filtered or unexported fields
}
func (WriteOverLimitError) GRPCStatus ¶ added in v1.45.2
func (err WriteOverLimitError) GRPCStatus() *status.Status
func (WriteOverLimitError) Unwrap ¶ added in v1.45.2
func (err WriteOverLimitError) Unwrap() error