Documentation ¶
Index ¶
- Constants
- Variables
- func CoreFilterFromRelationshipFilter(filter *v1.RelationshipFilter) *core.RelationshipFilter
- func CredentialsProviderOptions() string
- func DefinitionsOf[T SchemaDefinition](revisionedDefinitions []RevisionedDefinition[T]) []T
- func DeleteAllData(ctx context.Context, ds Datastore) error
- func EngineOptions() string
- func NewCaveatNameNotFoundErr(name string) error
- func NewCounterAlreadyRegisteredErr(counterName string, filter *core.RelationshipFilter) error
- func NewCounterNotRegisteredErr(counterName string) error
- func NewInvalidRevisionErr(revision Revision, reason InvalidRevisionReason) error
- func NewMaximumChangesSizeExceededError(maxSize uint64) error
- func NewNamespaceNotFoundErr(nsName string) error
- func NewReadonlyErr() error
- func NewWatchCanceledErr() error
- func NewWatchDisabledErr(reason string) error
- func NewWatchDisconnectedErr() error
- func NewWatchTemporaryErr(wrapped error) error
- func SortedEngineIDs() []string
- func UnwrapAs[T any](datastore Datastore) T
- type BulkWriteRelationshipSource
- type CaveatReader
- type CaveatStorer
- type CounterReader
- type CounterRegisterer
- type CredentialsProvider
- type Datastore
- type ErrCaveatNameNotFound
- type ErrCounterAlreadyRegistered
- type ErrCounterNotRegistered
- type ErrInvalidRevision
- type ErrNamespaceNotFound
- type ErrNotFound
- type ErrReadOnly
- type ErrWatchCanceled
- type ErrWatchDisabled
- type ErrWatchDisconnected
- type ErrWatchRetryable
- type Feature
- type FeatureStatus
- type Features
- type InvalidRevisionReason
- type MaximumChangesSizeExceededError
- type ObjectTypeStat
- type ReadOnlyDatastore
- type ReadWriteTransaction
- type Reader
- type ReadyState
- type RelationshipCounter
- type RelationshipIterator
- type RelationshipQueryOperation
- type RelationshipsFilter
- type RelationshipsQueryTree
- type RepairOperation
- type RepairableDatastore
- type Revision
- type RevisionChanges
- type RevisionedCaveat
- type RevisionedDefinition
- type RevisionedNamespace
- type SchemaDefinition
- type StartableDatastore
- type Stats
- type StrictReadDatastore
- type SubjectRelationFilter
- func (sf SubjectRelationFilter) IsEmpty() bool
- func (sf SubjectRelationFilter) WithEllipsisRelation() SubjectRelationFilter
- func (sf SubjectRelationFilter) WithNonEllipsisRelation(relation string) SubjectRelationFilter
- func (sf SubjectRelationFilter) WithOnlyNonEllipsisRelations() SubjectRelationFilter
- func (sf SubjectRelationFilter) WithRelation(relation string) SubjectRelationFilter
- type SubjectsFilter
- type SubjectsSelector
- type TxUserFunc
- type UnwrappableDatastore
- type WatchContent
- type WatchOptions
Constants ¶
const (
// AWSIAMCredentialProvider generates AWS IAM tokens for authenticating with the datastore (i.e. RDS)
AWSIAMCredentialProvider = "aws-iam"
)
const Ellipsis = "..."
Ellipsis is a special relation that is assumed to be valid on the right hand side of a tuple.
Variables ¶
var ( ErrClosedIterator = errors.New("unable to iterate: iterator closed") ErrCursorsWithoutSorting = errors.New("cursors are disabled on unsorted results") ErrCursorEmpty = errors.New("cursors are only available after the first result") )
var BuilderForCredentialProvider = map[string]credentialsProviderBuilderFunc{ AWSIAMCredentialProvider: newAWSIAMCredentialsProvider, }
var Engines []string
Functions ¶
func CoreFilterFromRelationshipFilter ¶
func CoreFilterFromRelationshipFilter(filter *v1.RelationshipFilter) *core.RelationshipFilter
CoreFilterFromRelationshipFilter constructs a core RelationshipFilter from a V1 RelationshipsFilter.
func CredentialsProviderOptions ¶
func CredentialsProviderOptions() string
CredentialsProviderOptions returns the full set of credential provider names, sorted and quoted into a string.
func DefinitionsOf ¶
func DefinitionsOf[T SchemaDefinition](revisionedDefinitions []RevisionedDefinition[T]) []T
DefinitionsOf returns just the schema definitions found in the list of revisioned definitions.
func DeleteAllData ¶ added in v0.0.3
DeleteAllData deletes all data from the datastore. Should only be used when explicitly requested. The data is transactionally deleted, which means it may time out.
func EngineOptions ¶
func EngineOptions() string
EngineOptions returns the full set of engine IDs, sorted and quoted into a string.
func NewCaveatNameNotFoundErr ¶
NewCaveatNameNotFoundErr constructs a new caveat name not found error.
func NewCounterAlreadyRegisteredErr ¶
func NewCounterAlreadyRegisteredErr(counterName string, filter *core.RelationshipFilter) error
NewCounterAlreadyRegisteredErr constructs a new filter not registered error.
func NewCounterNotRegisteredErr ¶
NewCounterNotRegisteredErr constructs a new counter not registered error.
func NewInvalidRevisionErr ¶
func NewInvalidRevisionErr(revision Revision, reason InvalidRevisionReason) error
NewInvalidRevisionErr constructs a new invalid revision error.
func NewMaximumChangesSizeExceededError ¶ added in v0.0.3
NewMaximumChangesSizeExceededError creates a new MaximumChangesSizeExceededError.
func NewNamespaceNotFoundErr ¶
NewNamespaceNotFoundErr constructs a new namespace not found error.
func NewReadonlyErr ¶
func NewReadonlyErr() error
NewReadonlyErr constructs an error for when a request has failed because the datastore has been configured to be read-only.
func NewWatchCanceledErr ¶
func NewWatchCanceledErr() error
NewWatchCanceledErr constructs a new watch was canceled error.
func NewWatchDisabledErr ¶
NewWatchDisabledErr constructs a new watch is disabled error.
func NewWatchDisconnectedErr ¶
func NewWatchDisconnectedErr() error
NewWatchDisconnectedErr constructs a new watch was disconnected error.
func NewWatchTemporaryErr ¶
NewWatchTemporaryErr wraps another error in watch, indicating that the error is likely a temporary condition and clients may consider retrying by calling watch again (vs a fatal error).
func SortedEngineIDs ¶
func SortedEngineIDs() []string
SortedEngineIDs returns the full set of engine IDs, sorted.
Types ¶
type BulkWriteRelationshipSource ¶
type BulkWriteRelationshipSource interface { // Next Returns a pointer to a relation tuple if one is available, or nil if // there are no more or there was an error. // // Note: sources may re-use the same memory address for every tuple, data // may change on every call to next even if the pointer has not changed. Next(ctx context.Context) (*core.RelationTuple, error) }
BulkWriteRelationshipSource is an interface for transferring relationships to a backing datastore with a zero-copy methodology.
type CaveatReader ¶
type CaveatReader interface { // ReadCaveatByName returns a caveat with the provided name. // It returns an instance of ErrCaveatNotFound if not found. ReadCaveatByName(ctx context.Context, name string) (caveat *core.CaveatDefinition, lastWritten Revision, err error) // ListAllCaveats returns all caveats stored in the system. ListAllCaveats(ctx context.Context) ([]RevisionedCaveat, error) // LookupCaveatsWithNames finds all caveats with the matching names. LookupCaveatsWithNames(ctx context.Context, names []string) ([]RevisionedCaveat, error) }
CaveatReader offers read operations for caveats
type CaveatStorer ¶
type CaveatStorer interface { CaveatReader // WriteCaveats stores the provided caveats, and returns the assigned IDs // Each element of the returning slice corresponds by possition to the input slice WriteCaveats(context.Context, []*core.CaveatDefinition) error // DeleteCaveats deletes the provided caveats by name DeleteCaveats(ctx context.Context, names []string) error }
CaveatStorer offers both read and write operations for Caveats
type CounterReader ¶
type CounterReader interface { // CountRelationships returns the count of relationships that match the provided counter. If the counter is not // registered, returns an error. CountRelationships(ctx context.Context, name string) (int, error) // LookupCounters returns all registered counters. LookupCounters(ctx context.Context) ([]RelationshipCounter, error) }
CounterReader is an interface for reading counts.
type CounterRegisterer ¶
type CounterRegisterer interface { // RegisterCounter registers a count with the provided filter. If the counter already exists, // returns an error. RegisterCounter(ctx context.Context, name string, filter *core.RelationshipFilter) error // UnregisterCounter unregisters a counter. If the counter did not exist, returns an error. UnregisterCounter(ctx context.Context, name string) error // StoreCounterValue stores a count for the counter with the given name, at the given revision. // If the counter does not exist, returns an error. StoreCounterValue(ctx context.Context, name string, value int, computedAtRevision Revision) error }
CounterRegisterer is an interface for registering and unregistering counts.
type CredentialsProvider ¶
type CredentialsProvider interface { // Name returns the name of the provider Name() string // IsCleartextToken returns true if the token returned represents a token (rather than a password) that must be sent in cleartext to the datastore, or false otherwise. // This may be used to configure the datastore options to avoid sending a hash of the token instead of its value. // Note that it is always recommended that communication channel be encrypted. IsCleartextToken() bool // Get returns the username and password to use when connecting to the underlying datastore Get(ctx context.Context, dbEndpoint string, dbUser string) (string, string, error) }
CredentialsProvider allows datastore credentials to be retrieved dynamically
var NoCredentialsProvider CredentialsProvider = nil
func NewCredentialsProvider ¶
func NewCredentialsProvider(ctx context.Context, name string) (CredentialsProvider, error)
NewCredentialsProvider create a new CredentialsProvider for the given name returns an error if no match is found, of if there is a problem creating the given CredentialsProvider
type Datastore ¶
type Datastore interface { ReadOnlyDatastore // ReadWriteTx starts a read/write transaction, which will be committed if no error is // returned and rolled back if an error is returned. ReadWriteTx(context.Context, TxUserFunc, ...options.RWTOptionsOption) (Revision, error) }
Datastore represents tuple access for a single namespace.
type ErrCaveatNameNotFound ¶
type ErrCaveatNameNotFound struct {
// contains filtered or unexported fields
}
ErrCaveatNameNotFound is the error returned when a caveat is not found by its name
func (ErrCaveatNameNotFound) CaveatName ¶
func (err ErrCaveatNameNotFound) CaveatName() string
CaveatName returns the name of the caveat that couldn't be found
func (ErrCaveatNameNotFound) DetailsMetadata ¶
func (err ErrCaveatNameNotFound) DetailsMetadata() map[string]string
DetailsMetadata returns the metadata for details for this error.
func (ErrCaveatNameNotFound) IsNotFoundError ¶
func (err ErrCaveatNameNotFound) IsNotFoundError() bool
type ErrCounterAlreadyRegistered ¶
type ErrCounterAlreadyRegistered struct {
// contains filtered or unexported fields
}
ErrCounterAlreadyRegistered indicates that a counter was already registered.
func (ErrCounterAlreadyRegistered) DetailsMetadata ¶
func (err ErrCounterAlreadyRegistered) DetailsMetadata() map[string]string
DetailsMetadata returns the metadata for details for this error.
type ErrCounterNotRegistered ¶
type ErrCounterNotRegistered struct {
// contains filtered or unexported fields
}
ErrCounterNotRegistered indicates that a counter was not registered.
func (ErrCounterNotRegistered) DetailsMetadata ¶
func (err ErrCounterNotRegistered) DetailsMetadata() map[string]string
DetailsMetadata returns the metadata for details for this error.
type ErrInvalidRevision ¶
type ErrInvalidRevision struct {
// contains filtered or unexported fields
}
ErrInvalidRevision occurs when a revision specified to a call was invalid.
func (ErrInvalidRevision) InvalidRevision ¶
func (err ErrInvalidRevision) InvalidRevision() Revision
InvalidRevision is the revision that failed.
func (ErrInvalidRevision) MarshalZerologObject ¶
func (err ErrInvalidRevision) MarshalZerologObject(e *zerolog.Event)
MarshalZerologObject implements zerolog object marshalling.
func (ErrInvalidRevision) Reason ¶
func (err ErrInvalidRevision) Reason() InvalidRevisionReason
Reason is the reason the revision failed.
type ErrNamespaceNotFound ¶
type ErrNamespaceNotFound struct {
// contains filtered or unexported fields
}
ErrNamespaceNotFound occurs when a namespace was not found.
func (ErrNamespaceNotFound) DetailsMetadata ¶
func (err ErrNamespaceNotFound) DetailsMetadata() map[string]string
DetailsMetadata returns the metadata for details for this error.
func (ErrNamespaceNotFound) IsNotFoundError ¶
func (err ErrNamespaceNotFound) IsNotFoundError() bool
func (ErrNamespaceNotFound) MarshalZerologObject ¶
func (err ErrNamespaceNotFound) MarshalZerologObject(e *zerolog.Event)
MarshalZerologObject implements zerolog object marshalling.
func (ErrNamespaceNotFound) NotFoundNamespaceName ¶
func (err ErrNamespaceNotFound) NotFoundNamespaceName() string
NotFoundNamespaceName is the name of the namespace not found.
type ErrNotFound ¶
type ErrNotFound interface {
IsNotFoundError() bool
}
ErrNotFound is a shared interface for not found errors.
type ErrReadOnly ¶
type ErrReadOnly struct {
// contains filtered or unexported fields
}
ErrReadOnly is returned when the operation cannot be completed because the datastore is in read-only mode.
type ErrWatchCanceled ¶
type ErrWatchCanceled struct {
// contains filtered or unexported fields
}
ErrWatchCanceled occurs when a watch was canceled by the caller.
type ErrWatchDisabled ¶
type ErrWatchDisabled struct {
// contains filtered or unexported fields
}
ErrWatchDisabled occurs when watch is disabled by being unsupported by the datastore.
type ErrWatchDisconnected ¶
type ErrWatchDisconnected struct {
// contains filtered or unexported fields
}
ErrWatchDisconnected occurs when a watch has fallen too far behind and was forcibly disconnected as a result.
type ErrWatchRetryable ¶
type ErrWatchRetryable struct {
// contains filtered or unexported fields
}
ErrWatchRetryable is returned when a transient/temporary error occurred in watch and indicates that the caller *may* retry the watch after some backoff time.
type Feature ¶
type Feature struct { Status FeatureStatus Reason string }
Feature represents a capability that a datastore can support, plus an optional message explaining the feature is available (or not).
type FeatureStatus ¶ added in v0.0.3
type FeatureStatus int
FeatureStatus are the possible statuses for a feature in the datastore.
const ( // FeatureStatusUnknown indicates that the status of the feature is unknown. // This can be returned, for example, when a call is made to OfflineFeatures // but the feature requires a call to the database to determine its status. FeatureStatusUnknown FeatureStatus = iota // FeatureSupported indicates that the feature is supported by the datastore. FeatureSupported // FeatureUnsupported indicates that the feature is not supported by the datastore. FeatureUnsupported )
type Features ¶
type Features struct { // Watch is enabled if the underlying datastore can support the Watch api. Watch Feature // ContinuousCheckpointing is enabled if the underlying datastore supports continuous checkpointing // via the Watch API. If not supported, clients of the Watch API may expect checkpoints only when // new transactions are committed. ContinuousCheckpointing Feature // IntegrityData is enabled if the underlying datastore supports retrieving and storing // integrity information. IntegrityData Feature }
Features holds values that represent what features a database can support.
type InvalidRevisionReason ¶
type InvalidRevisionReason int
InvalidRevisionReason is the reason the revision could not be used.
const ( // RevisionStale is the reason returned when a revision is outside the window of // validity by being too old. RevisionStale InvalidRevisionReason = iota // CouldNotDetermineRevision is the reason returned when a revision for a // request could not be determined. CouldNotDetermineRevision )
type MaximumChangesSizeExceededError ¶ added in v0.0.3
type MaximumChangesSizeExceededError struct {
// contains filtered or unexported fields
}
MaximumChangesSizeExceededError is returned when the maximum size of changes is exceeded.
type ObjectTypeStat ¶
type ObjectTypeStat struct { // NumRelations is the number of relations defined in a single object type. NumRelations uint32 // NumPermissions is the number of permissions defined in a single object type. NumPermissions uint32 }
ObjectTypeStat represents statistics for a single object type (namespace).
func ComputeObjectTypeStats ¶
func ComputeObjectTypeStats(objTypes []RevisionedNamespace) []ObjectTypeStat
ComputeObjectTypeStats creates a list of object type stats from an input list of parsed object types.
type ReadOnlyDatastore ¶ added in v0.0.3
type ReadOnlyDatastore interface { // SnapshotReader creates a read-only handle that reads the datastore at the specified revision. // Any errors establishing the reader will be returned by subsequent calls. SnapshotReader(Revision) Reader // OptimizedRevision gets a revision that will likely already be replicated // and will likely be shared amongst many queries. OptimizedRevision(ctx context.Context) (Revision, error) // HeadRevision gets a revision that is guaranteed to be at least as fresh as // right now. HeadRevision(ctx context.Context) (Revision, error) // CheckRevision checks the specified revision to make sure it's valid and // hasn't been garbage collected. CheckRevision(ctx context.Context, revision Revision) error // RevisionFromString will parse the revision text and return the specific type of Revision // used by the specific datastore implementation. RevisionFromString(serialized string) (Revision, error) // Watch notifies the caller about changes to the datastore, based on the specified options. // // All events following afterRevision will be sent to the caller. Watch(ctx context.Context, afterRevision Revision, options WatchOptions) (<-chan *RevisionChanges, <-chan error) // ReadyState returns a state indicating whether the datastore is ready to accept data. // Datastores that require database schema creation will return not-ready until the migrations // have been run to create the necessary tables. ReadyState(ctx context.Context) (ReadyState, error) // Features returns an object representing what features this // datastore can support. Can make calls to the database, so should // only be used when a connection is allowed. Features(ctx context.Context) (*Features, error) // OfflineFeatures returns an object representing what features this // datastore supports code-wise, without making any calls to the database. OfflineFeatures() (*Features, error) // Statistics returns relevant values about the data contained in this cluster. Statistics(ctx context.Context) (Stats, error) // Close closes the data store. Close() error }
ReadOnlyDatastore is an interface for reading relationships from the datastore.
type ReadWriteTransaction ¶
type ReadWriteTransaction interface { Reader CaveatStorer CounterRegisterer // WriteRelationships takes a list of tuple mutations and applies them to the datastore. WriteRelationships(ctx context.Context, mutations []*core.RelationTupleUpdate) error // DeleteRelationships deletes relationships that match the provided filter, with // the optional limit. If a limit is provided and reached, the method will return // true as the first return value. Otherwise, the boolean can be ignored. DeleteRelationships(ctx context.Context, filter *v1.RelationshipFilter, options ...options.DeleteOptionsOption, ) (bool, error) // WriteNamespaces takes proto namespace definitions and persists them. WriteNamespaces(ctx context.Context, newConfigs ...*core.NamespaceDefinition) error // DeleteNamespaces deletes namespaces including associated relationships. DeleteNamespaces(ctx context.Context, nsNames ...string) error // BulkLoad takes a relationship source iterator, and writes all of the // relationships to the backing datastore in an optimized fashion. This // method can and will omit checks and otherwise cut corners in the // interest of performance, and should not be relied upon for OLTP-style // workloads. BulkLoad(ctx context.Context, iter BulkWriteRelationshipSource) (uint64, error) }
type Reader ¶
type Reader interface { CaveatReader CounterReader // QueryRelationships reads relationships, starting from the resource side. QueryRelationships( ctx context.Context, filter RelationshipsFilter, options ...options.QueryOptionsOption, ) (RelationshipIterator, error) // ReverseQueryRelationships reads relationships, starting from the subject. ReverseQueryRelationships( ctx context.Context, subjectsFilter SubjectsFilter, options ...options.ReverseQueryOptionsOption, ) (RelationshipIterator, error) // ReadNamespaceByName reads a namespace definition and the revision at which it was created or // last written. It returns an instance of ErrNamespaceNotFound if not found. ReadNamespaceByName(ctx context.Context, nsName string) (ns *core.NamespaceDefinition, lastWritten Revision, err error) // ListAllNamespaces lists all namespaces defined. ListAllNamespaces(ctx context.Context) ([]RevisionedNamespace, error) // LookupNamespacesWithNames finds all namespaces with the matching names. LookupNamespacesWithNames(ctx context.Context, nsNames []string) ([]RevisionedNamespace, error) }
Reader is an interface for reading relationships from the datastore.
type ReadyState ¶
type ReadyState struct { // Message is a human-readable status message for the current state. Message string // IsReady indicates whether the datastore is ready. IsReady bool }
ReadyState represents the ready state of the datastore.
type RelationshipCounter ¶
type RelationshipCounter struct { // Name is the name of the counter. Name string // Filter is the filter that the count represents. Filter *core.RelationshipFilter // Count is the count of relationships that match the filter. Count int // ComputedAtRevision is the revision at which the count was last computed. If NoRevision, // the count has never been computed. ComputedAtRevision Revision }
RelationshipCounter is a struct that represents a count of relationships that match a filter.
type RelationshipIterator ¶
type RelationshipIterator interface { // Next returns the next tuple in the result set. Next() *core.RelationTuple // Cursor returns a cursor that can be used to resume reading of relationships // from the last relationship returned. Only applies if a sort ordering was // requested. Cursor() (options.Cursor, error) // Err after receiving a nil response, the caller must check for an error. Err() error // Close cancels the query and closes any open connections. Close() }
RelationshipIterator is an iterator over matched tuples.
type RelationshipQueryOperation ¶
type RelationshipQueryOperation int
const ( RelationshipQueryNone RelationshipQueryOperation = 0 RelationshipQueryOr RelationshipQueryOperation = 1 RelationshipQueryAnd RelationshipQueryOperation = 2 )
type RelationshipsFilter ¶
type RelationshipsFilter struct { // OptionalResourceType is the namespace/type for the resources to be found. OptionalResourceType string // OptionalResourceIds are the IDs of the resources to find. If nil empty, any resource ID will be allowed. // Cannot be used with OptionalResourceIDPrefix. OptionalResourceIds []string // OptionalResourceIDPrefix is the prefix to use for resource IDs. If empty, any prefix is allowed. // Cannot be used with OptionalResourceIds. OptionalResourceIDPrefix string // OptionalResourceRelation is the relation of the resource to find. If empty, any relation is allowed. OptionalResourceRelation string // OptionalSubjectsSelectors is the selectors to use for subjects of the relationship. If nil, all subjects are allowed. // If specified, relationships matching *any* selector will be returned. OptionalSubjectsSelectors []SubjectsSelector // OptionalCaveatName is the filter to use for caveated relationships, filtering by a specific caveat name. // If nil, all caveated and non-caveated relationships are allowed OptionalCaveatName string }
RelationshipsFilter is a filter for relationships.
func RelationshipsFilterFromCoreFilter ¶
func RelationshipsFilterFromCoreFilter(filter *core.RelationshipFilter) (RelationshipsFilter, error)
RelationshipsFilterFromCoreFilter constructs a datastore RelationshipsFilter from a core RelationshipFilter.
func RelationshipsFilterFromPublicFilter ¶
func RelationshipsFilterFromPublicFilter(filter *v1.RelationshipFilter) (RelationshipsFilter, error)
RelationshipsFilterFromPublicFilter constructs a datastore RelationshipsFilter from an API-defined RelationshipFilter.
func (RelationshipsFilter) Test ¶
func (rf RelationshipsFilter) Test(relationship *core.RelationTuple) bool
Test returns true iff the given relationship is matched by this filter.
type RelationshipsQueryTree ¶
type RelationshipsQueryTree struct {
// contains filtered or unexported fields
}
func NewRelationshipQueryTree ¶
func NewRelationshipQueryTree(filter RelationshipsFilter) RelationshipsQueryTree
type RepairOperation ¶
type RepairOperation struct { // Name is the command-line name for the repair operation. Name string // Description is the human-readable description for the repair operation. Description string }
RepairOperation represents a single kind of repair operation that can be run in a repairable datastore.
type RepairableDatastore ¶
type RepairableDatastore interface { Datastore // Repair runs the repair operation on the datastore. Repair(ctx context.Context, operationName string, outputProgress bool) error // RepairOperations returns the available repair operations for the datastore. RepairOperations() []RepairOperation }
RepairableDatastore is an optional extension to the datastore interface that, when implemented, provides the ability for callers to repair the datastore's data in some fashion.
type Revision ¶
type Revision interface { fmt.Stringer // Equal returns whether the revisions should be considered equal. Equal(Revision) bool // GreaterThan returns whether the receiver is probably greater than the right hand side. GreaterThan(Revision) bool // LessThan returns whether the receiver is probably less than the right hand side. LessThan(Revision) bool }
Revision is an interface for a comparable revision type that can be different for each datastore implementation.
var NoRevision Revision = nilRevision{}
NoRevision is a zero type for the revision that will make changing the revision type in the future a bit easier if necessary. Implementations should use any time they want to signal an empty/error revision.
type RevisionChanges ¶
type RevisionChanges struct { Revision Revision // RelationshipChanges are any relationships that were changed at this revision. RelationshipChanges []*core.RelationTupleUpdate // ChangedDefinitions are any definitions that were added or changed at this revision. ChangedDefinitions []SchemaDefinition // DeletedNamespaces are any namespaces that were deleted. DeletedNamespaces []string // DeletedCaveats are any caveats that were deleted. DeletedCaveats []string // IsCheckpoint, if true, indicates that the datastore has reported all changes // up until and including the Revision and that no additional schema updates can // have occurred before this point. IsCheckpoint bool // Metadata is the metadata associated with the revision, if any. Metadata *structpb.Struct }
RevisionChanges represents the changes in a single transaction.
func (*RevisionChanges) MarshalZerologObject ¶
func (rc *RevisionChanges) MarshalZerologObject(e *zerolog.Event)
type RevisionedCaveat ¶
type RevisionedCaveat = RevisionedDefinition[*core.CaveatDefinition]
RevisionedCaveat is a revisioned version of a caveat definition.
type RevisionedDefinition ¶
type RevisionedDefinition[T SchemaDefinition] struct { // Definition is the namespace or caveat definition. Definition T // LastWrittenRevision is the revision at which the namespace or caveat was last updated. LastWrittenRevision Revision }
RevisionedDefinition holds a schema definition and its last updated revision.
func (RevisionedDefinition[T]) GetLastWrittenRevision ¶
func (rd RevisionedDefinition[T]) GetLastWrittenRevision() Revision
type RevisionedNamespace ¶
type RevisionedNamespace = RevisionedDefinition[*core.NamespaceDefinition]
RevisionedNamespace is a revisioned version of a namespace definition.
type SchemaDefinition ¶
SchemaDefinition represents a namespace or caveat definition under a schema.
type StartableDatastore ¶
type StartableDatastore interface { Datastore // Start starts any background operations on the datastore. The context provided, if canceled, will // also cancel the background operation(s) on the datastore. Start(ctx context.Context) error }
StartableDatastore is an optional extension to the datastore interface that, when implemented, provides the ability for callers to start background operations on the datastore.
type Stats ¶
type Stats struct { // UniqueID is a unique string for a single datastore. UniqueID string // EstimatedRelationshipCount is a best-guess estimate of the number of relationships // in the datastore. Computing it should use a lightweight method such as reading // table statistics. EstimatedRelationshipCount uint64 // ObjectTypeStatistics returns a slice element for each object type (namespace) // stored in the datastore. ObjectTypeStatistics []ObjectTypeStat }
Stats represents statistics for the entire datastore.
type StrictReadDatastore ¶ added in v0.0.3
type StrictReadDatastore interface { Datastore // IsStrictReadModeEnabled returns whether the datastore is in strict read mode. IsStrictReadModeEnabled() bool }
StrictReadDatastore is an interface for datastores that support strict read mode.
type SubjectRelationFilter ¶
type SubjectRelationFilter struct { // NonEllipsisRelation is the relation of the subject type to find. If empty, // IncludeEllipsisRelation must be true. NonEllipsisRelation string // IncludeEllipsisRelation, if true, indicates that the ellipsis relation // should be included as an option. IncludeEllipsisRelation bool // OnlyNonEllipsisRelations, if true, indicates that only non-ellipsis relations // should be included. OnlyNonEllipsisRelations bool }
SubjectRelationFilter is the filter to use for relation(s) of subjects being queried.
func (SubjectRelationFilter) IsEmpty ¶
func (sf SubjectRelationFilter) IsEmpty() bool
IsEmpty returns true if the subject relation filter is empty.
func (SubjectRelationFilter) WithEllipsisRelation ¶
func (sf SubjectRelationFilter) WithEllipsisRelation() SubjectRelationFilter
WithEllipsisRelation indicates that the subject filter should include the ellipsis relation as an option for the subjects' relation.
func (SubjectRelationFilter) WithNonEllipsisRelation ¶
func (sf SubjectRelationFilter) WithNonEllipsisRelation(relation string) SubjectRelationFilter
WithNonEllipsisRelation indicates that the specified non-ellipsis relation should be included as an option for the subjects' relation.
func (SubjectRelationFilter) WithOnlyNonEllipsisRelations ¶
func (sf SubjectRelationFilter) WithOnlyNonEllipsisRelations() SubjectRelationFilter
WithOnlyNonEllipsisRelations indicates that only non-ellipsis relations should be included.
func (SubjectRelationFilter) WithRelation ¶
func (sf SubjectRelationFilter) WithRelation(relation string) SubjectRelationFilter
WithRelation indicates that the specified relation should be included as an option for the subjects' relation.
type SubjectsFilter ¶
type SubjectsFilter struct { // SubjectType is the namespace/type for the subjects to be found. SubjectType string // OptionalSubjectIds are the IDs of the subjects to find. If nil or empty, any subject ID will be allowed. OptionalSubjectIds []string // RelationFilter is the filter to use for the relation(s) of the subjects. If neither field // is set, any relation is allowed. RelationFilter SubjectRelationFilter }
SubjectsFilter is a filter for subjects.
func (SubjectsFilter) AsSelector ¶
func (sf SubjectsFilter) AsSelector() SubjectsSelector
type SubjectsSelector ¶
type SubjectsSelector struct { // OptionalSubjectType is the namespace/type for the subjects to be found, if any. OptionalSubjectType string // OptionalSubjectIds are the IDs of the subjects to find. If nil or empty, any subject ID will be allowed. OptionalSubjectIds []string // RelationFilter is the filter to use for the relation(s) of the subjects. If neither field // is set, any relation is allowed. RelationFilter SubjectRelationFilter }
SubjectsSelector is a selector for subjects.
func (SubjectsSelector) Test ¶
func (ss SubjectsSelector) Test(subject *core.ObjectAndRelation) bool
Test returns true iff the given subject is matched by this filter.
type TxUserFunc ¶
type TxUserFunc func(context.Context, ReadWriteTransaction) error
TxUserFunc is a type for the function that users supply when they invoke a read-write transaction.
type UnwrappableDatastore ¶
type UnwrappableDatastore interface { // Unwrap returns the wrapped datastore. Unwrap() Datastore }
UnwrappableDatastore represents a datastore that can be unwrapped into the underlying datastore.
type WatchContent ¶
type WatchContent int
const ( WatchRelationships WatchContent = 1 << 0 WatchSchema WatchContent = 1 << 1 WatchCheckpoints WatchContent = 1 << 2 )
type WatchOptions ¶
type WatchOptions struct { // Content is the content to watch. Content WatchContent // CheckpointInterval is the interval to use for checkpointing in the watch. // If given the zero value, the datastore's default will be used. If smaller // than the datastore's minimum, the minimum will be used. CheckpointInterval time.Duration // WatchBufferLength is the length of the buffer for the watch channel. If // given the zero value, the datastore's default will be used. WatchBufferLength uint16 // WatchBufferWriteTimeout is the timeout for writing to the watch channel. // If given the zero value, the datastore's default will be used. WatchBufferWriteTimeout time.Duration // WatchConnectTimeout is the timeout for connecting to the watch channel. // If given the zero value, the datastore's default will be used. // May not be supported by the datastore. WatchConnectTimeout time.Duration // MaximumBufferedChangesByteSize is the maximum byte size of the buffered changes struct. // If unspecified, no maximum will be enforced. If the maximum is reached before // the changes can be sent, the watch will be closed with an error. MaximumBufferedChangesByteSize uint64 }
WatchOptions are options for a Watch call.
func WatchJustRelationships ¶
func WatchJustRelationships() WatchOptions
WatchJustRelationships returns watch options for just relationships.
func WatchJustSchema ¶
func WatchJustSchema() WatchOptions
WatchJustSchema returns watch options for just schema.
func (WatchOptions) WithCheckpointInterval ¶
func (wo WatchOptions) WithCheckpointInterval(interval time.Duration) WatchOptions
WithCheckpointInterval sets the checkpoint interval on a watch options, returning an updated options struct.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Code generated by github.com/ecordell/optgen.
|
Code generated by github.com/ecordell/optgen. |