Documentation
¶
Index ¶
- Constants
- Variables
- func ExceededMaxTypeDefinitionsLimitError(limit int) error
- func InvalidWriteInputError(tk *openfgapb.TupleKey, operation openfgapb.TupleOperation) error
- type AssertionsBackend
- type AuthorizationModelBackend
- type AuthorizationModelReadBackend
- type ChangelogBackend
- type Deletes
- type OpenFGADatastore
- type PaginationOptions
- type StoresBackend
- type TupleBackend
- type TupleIterator
- type TypeDefinitionReadBackend
- type TypeDefinitionWriteBackend
- type Writes
Constants ¶
View Source
const DefaultPageSize = 50
Variables ¶
View Source
var ( ErrCollision = errors.New("item already exists") ErrInvalidContinuationToken = errors.New("invalid continuation token") ErrInvalidWriteInput = errors.New("invalid write input") ErrNotFound = errors.New("not found") ErrTransactionalWriteFailed = errors.New("transactional write failed due to bad input") ErrMismatchObjectType = errors.New("mismatched types in request and continuation token") ErrExceededWriteBatchLimit = errors.New("number of operations exceeded write batch limit") ErrCancelled = errors.New("request has been cancelled") )
since these errors are allocated at init time, it is better to leave them as normal errors instead of errors that have stack encoded.
View Source
var TupleIteratorDone = errors.New("no more tuples in iterator")
Functions ¶
func InvalidWriteInputError ¶
func InvalidWriteInputError(tk *openfgapb.TupleKey, operation openfgapb.TupleOperation) error
Types ¶
type AssertionsBackend ¶
type AuthorizationModelBackend ¶
type AuthorizationModelBackend interface {
AuthorizationModelReadBackend
TypeDefinitionReadBackend
TypeDefinitionWriteBackend
}
AuthorizationModelBackend provides an R/W interface for managing type definition.
type AuthorizationModelReadBackend ¶
type AuthorizationModelReadBackend interface {
// ReadAuthorizationModel Read the store type definition corresponding to `id`.
ReadAuthorizationModel(ctx context.Context, store string, id string) (*openfgapb.AuthorizationModel, error)
// ReadAuthorizationModels Read all type definitions ids for the supplied store.
ReadAuthorizationModels(ctx context.Context, store string, options PaginationOptions) ([]*openfgapb.AuthorizationModel, []byte, error)
FindLatestAuthorizationModelID(ctx context.Context, store string) (string, error)
}
AuthorizationModelReadBackend Provides a Read interface for managing type definitions.
type ChangelogBackend ¶
type ChangelogBackend interface {
// ReadChanges returns the writes and deletes that have occurred for tuples of a given object type within a store.
// The horizonOffset should be specified using a unit no more granular than a millisecond and should be interpreted
// as a millisecond duration.
ReadChanges(ctx context.Context, store, objectType string, paginationOptions PaginationOptions, horizonOffset time.Duration) ([]*openfgapb.TupleChange, []byte, error)
}
type OpenFGADatastore ¶
type OpenFGADatastore interface {
TupleBackend
AuthorizationModelBackend
StoresBackend
AssertionsBackend
ChangelogBackend
Close(ctx context.Context) error
}
type PaginationOptions ¶
func NewPaginationOptions ¶
func NewPaginationOptions(ps int32, contToken string) PaginationOptions
type StoresBackend ¶
type StoresBackend interface {
CreateStore(ctx context.Context, store *openfgapb.Store) (*openfgapb.Store, error)
DeleteStore(ctx context.Context, id string) error
GetStore(ctx context.Context, id string) (*openfgapb.Store, error)
ListStores(ctx context.Context, paginationOptions PaginationOptions) ([]*openfgapb.Store, []byte, error)
}
type TupleBackend ¶
type TupleBackend interface {
// Read the set of tuples associated with `store` and `key`, which may be partially filled. A key must specify at
// least one of `Object` or `User` (or both), and may also optionally constrain by relation. The caller must be
// careful to close the TupleIterator, either by consuming the entire iterator or by closing it.
Read(context.Context, string, *openfgapb.TupleKey) (TupleIterator, error)
// ReadPage is similar to Read, but with PaginationOptions. Instead of returning a TupleIterator, ReadPage
// returns a page of tuples and a possibly non-empty continuation token.
ReadPage(context.Context, string, *openfgapb.TupleKey, PaginationOptions) ([]*openfgapb.Tuple, []byte, error)
// Write updates data in the tuple backend, performing all delete operations in
// `deletes` before adding new values in `writes`, returning the time of the transaction, or an error.
// It is expected that
// - there is at most 10 deletes/writes
// - no duplicate item in delete/write list
Write(context.Context, string, Deletes, Writes) error
ReadUserTuple(context.Context, string, *openfgapb.TupleKey) (*openfgapb.Tuple, error)
ReadUsersetTuples(context.Context, string, *openfgapb.TupleKey) (TupleIterator, error)
// ReadByStore reads the tuples associated with `store`.
ReadByStore(context.Context, string, PaginationOptions) ([]*openfgapb.Tuple, []byte, error)
// MaxTuplesInWriteOperation returns the maximum number of items allowed in a single write transaction
MaxTuplesInWriteOperation() int
}
A TupleBackend provides an R/W interface for managing tuples.
type TupleIterator ¶
type TupleIterator interface {
Next() (*openfgapb.Tuple, error)
// Stop will release any resources held by the iterator. It must be safe to be called multiple times.
Stop()
}
TupleIterator is an iterator for Tuples. It is closed by explicitly calling Stop() or by calling Next() until it returns an TupleIteratorDone error.
type TypeDefinitionReadBackend ¶
type TypeDefinitionReadBackend interface {
// ReadTypeDefinition Read the store authorization model corresponding to `id` + `objectType`.
ReadTypeDefinition(ctx context.Context, store, id string, objectType string) (*openfgapb.TypeDefinition, error)
}
TypeDefinitionReadBackend Provides a Read interface for managing type definitions.
type TypeDefinitionWriteBackend ¶
type TypeDefinitionWriteBackend interface {
// MaxTypesInTypeDefinition returns the maximum number of items allowed for type definitions
MaxTypesInTypeDefinition() int
// WriteAuthorizationModel writes an authorization model for the given store.
// It is expected that the number of type definitions is less than or equal to 24
WriteAuthorizationModel(ctx context.Context, store, id string, tds *openfgapb.TypeDefinitions) error
}
TypeDefinitionWriteBackend Provides a write interface for managing typed definition.
Click to show internal directories.
Click to hide internal directories.