Documentation
¶
Index ¶
- Constants
- func BulkExport(ctx context.Context, dl datalayer.DataLayer, batchSize uint64, ...) error
- func ConvertCheckDispatchDebugInformation(ctx context.Context, caveatTypeSet *caveattypes.TypeSet, ...) (*v1.DebugInformation, error)
- func ExportBulk(ctx context.Context, dl datalayer.DataLayer, batchSize uint64, ...) error
- func GetCaveatContext(ctx context.Context, caveatCtx *structpb.Struct, maxCaveatContextSize int) (map[string]any, error)
- func NewExperimentalServer(dispatch dispatch.Dispatcher, permServerConfig PermissionsServerConfig, ...) v1.ExperimentalServiceServer
- func NewPermissionsServer(dispatch dispatch.Dispatcher, config PermissionsServerConfig, ...) v1.PermissionsServiceServer
- func NewPreconditionFailedErr(precondition *v1.Precondition) error
- func NewSchemaServer(config SchemaServerConfig, validator protovalidate.Validator) v1.SchemaServiceServer
- func NewWatchServer(heartbeatDuration time.Duration, validator protovalidate.Validator) v1.WatchServiceServer
- func TranslateExpansionTree(node *core.RelationTupleTreeNode) *v1.PermissionRelationshipTree
- func TranslateRelationshipTree(tree *v1.PermissionRelationshipTree) *core.RelationTupleTreeNode
- type CouldNotTransactionallyDeleteError
- type DuplicateRelationErrorshipError
- type EmptyPreconditionError
- type ErrMaxRelationshipContextError
- type ExceedsMaximumChecksError
- type ExceedsMaximumLimitError
- type ExceedsMaximumPreconditionsError
- type ExceedsMaximumUpdatesError
- type ExperimentalQueryPlanConfig
- type InvalidCursorError
- type InvalidFilterError
- type Metrics
- type NotAPermissionError
- type PermissionsServerConfig
- type PreconditionFailedError
- type SchemaServerConfig
- type TransactionMetadataTooLargeError
Constants ¶
const MaximumTransactionMetadataSize = 65000 // bytes. Limited by the BLOB size used in MySQL driver
Variables ¶
This section is empty.
Functions ¶
func BulkExport ¶ added in v1.33.0
func BulkExport(ctx context.Context, dl datalayer.DataLayer, batchSize uint64, req *v1.BulkExportRelationshipsRequest, fallbackRevision datastore.Revision, fallbackSchemaHash datalayer.SchemaHash, sender func(response *v1.BulkExportRelationshipsResponse) error) error
BulkExport implements the BulkExportRelationships API functionality. Given a datalayer.DataLayer, it will export stream via the sender all relationships matched by the incoming request. If no cursor is provided, it will fallback to the provided revision.
func ConvertCheckDispatchDebugInformation ¶ added in v1.16.2
func ConvertCheckDispatchDebugInformation( ctx context.Context, caveatTypeSet *caveattypes.TypeSet, caveatContext map[string]any, debugInfo *dispatch.DebugInformation, reader datalayer.SchemaReader, ) (*v1.DebugInformation, error)
ConvertCheckDispatchDebugInformation converts dispatch debug information found in the response metadata into DebugInformation returnable to the API.
func ExportBulk ¶ added in v1.37.0
func ExportBulk(ctx context.Context, dl datalayer.DataLayer, batchSize uint64, req *v1.ExportBulkRelationshipsRequest, fallbackRevision datastore.Revision, fallbackSchemaHash datalayer.SchemaHash, sender func(response *v1.ExportBulkRelationshipsResponse) error) error
ExportBulk implements the ExportBulkRelationships API functionality. Given a datalayer.DataLayer, it will export stream via the sender all relationships matched by the incoming request. If no cursor is provided, it will fallback to the provided revision.
func GetCaveatContext ¶ added in v1.18.0
func NewExperimentalServer ¶ added in v1.22.0
func NewExperimentalServer(dispatch dispatch.Dispatcher, permServerConfig PermissionsServerConfig, validator protovalidate.Validator, opts ...options.ExperimentalServerOptionsOption) v1.ExperimentalServiceServer
NewExperimentalServer creates a ExperimentalServiceServer instance.
func NewPermissionsServer ¶
func NewPermissionsServer( dispatch dispatch.Dispatcher, config PermissionsServerConfig, validator protovalidate.Validator, ) v1.PermissionsServiceServer
NewPermissionsServer creates a PermissionsServiceServer instance.
func NewPreconditionFailedErr ¶ added in v1.14.0
func NewPreconditionFailedErr(precondition *v1.Precondition) error
NewPreconditionFailedErr constructs a new precondition failed error.
func NewSchemaServer ¶
func NewSchemaServer(config SchemaServerConfig, validator protovalidate.Validator) v1.SchemaServiceServer
NewSchemaServer creates a SchemaServiceServer instance.
func NewWatchServer ¶ added in v1.2.0
func NewWatchServer(heartbeatDuration time.Duration, validator protovalidate.Validator) v1.WatchServiceServer
NewWatchServer creates an instance of the watch server.
func TranslateExpansionTree ¶ added in v1.5.0
func TranslateExpansionTree(node *core.RelationTupleTreeNode) *v1.PermissionRelationshipTree
func TranslateRelationshipTree ¶ added in v1.2.0
func TranslateRelationshipTree(tree *v1.PermissionRelationshipTree) *core.RelationTupleTreeNode
TranslateRelationshipTree translates a V1 PermissionRelationshipTree into a RelationTupleTreeNode.
Types ¶
type CouldNotTransactionallyDeleteError ¶ added in v1.39.0
type CouldNotTransactionallyDeleteError struct {
// contains filtered or unexported fields
}
CouldNotTransactionallyDeleteError indicates that a deletion could not occur transactionally.
func NewCouldNotTransactionallyDeleteErr ¶ added in v1.22.0
func NewCouldNotTransactionallyDeleteErr(filter *v1.RelationshipFilter, limit uint32) CouldNotTransactionallyDeleteError
NewCouldNotTransactionallyDeleteErr constructs a new could not transactionally deleter error.
func (CouldNotTransactionallyDeleteError) GRPCStatus ¶ added in v1.39.0
func (err CouldNotTransactionallyDeleteError) GRPCStatus() *status.Status
GRPCStatus implements retrieving the gRPC status for the error.
type DuplicateRelationErrorshipError ¶ added in v1.39.0
type DuplicateRelationErrorshipError struct {
// contains filtered or unexported fields
}
DuplicateRelationErrorshipError indicates that an update was attempted on the same relationship.
func NewDuplicateRelationshipErr ¶ added in v1.15.0
func NewDuplicateRelationshipErr(update *v1.RelationshipUpdate) DuplicateRelationErrorshipError
NewDuplicateRelationshipErr constructs a new invalid subject error.
func (DuplicateRelationErrorshipError) GRPCStatus ¶ added in v1.39.0
func (err DuplicateRelationErrorshipError) GRPCStatus() *status.Status
GRPCStatus implements retrieving the gRPC status for the error.
type EmptyPreconditionError ¶ added in v1.39.0
type EmptyPreconditionError struct {
// contains filtered or unexported fields
}
EmptyPreconditionError indicates an empty precondition was found.
func NewEmptyPreconditionErr ¶ added in v1.30.0
func NewEmptyPreconditionErr() EmptyPreconditionError
NewEmptyPreconditionErr constructs a new empty precondition error.
func (EmptyPreconditionError) GRPCStatus ¶ added in v1.39.0
func (err EmptyPreconditionError) GRPCStatus() *status.Status
GRPCStatus implements retrieving the gRPC status for the error.
type ErrMaxRelationshipContextError ¶ added in v1.22.0
type ErrMaxRelationshipContextError struct {
// contains filtered or unexported fields
}
ErrMaxRelationshipContextError indicates an attempt to write a relationship that exceeded the maximum configured context size.
func NewMaxRelationshipContextError ¶ added in v1.22.0
func NewMaxRelationshipContextError(update *v1.RelationshipUpdate, maxAllowedSize int) ErrMaxRelationshipContextError
NewMaxRelationshipContextError constructs a new max relationship context error.
func (ErrMaxRelationshipContextError) GRPCStatus ¶ added in v1.22.0
func (err ErrMaxRelationshipContextError) GRPCStatus() *status.Status
GRPCStatus implements retrieving the gRPC status for the error.
type ExceedsMaximumChecksError ¶ added in v1.39.0
type ExceedsMaximumChecksError struct {
// contains filtered or unexported fields
}
ExceedsMaximumChecksError occurs when too many checks are given to a call.
func NewExceedsMaximumChecksErr ¶ added in v1.30.0
func NewExceedsMaximumChecksErr(checkCount uint64, maxCountAllowed uint64) ExceedsMaximumChecksError
NewExceedsMaximumChecksErr creates a new error representing that too many updates were given to a BulkCheckPermissions call.
func (ExceedsMaximumChecksError) GRPCStatus ¶ added in v1.39.0
func (err ExceedsMaximumChecksError) GRPCStatus() *status.Status
GRPCStatus implements retrieving the gRPC status for the error.
func (ExceedsMaximumChecksError) MarshalZerologObject ¶ added in v1.39.0
func (err ExceedsMaximumChecksError) MarshalZerologObject(e *zerolog.Event)
MarshalZerologObject implements zerolog object marshalling.
type ExceedsMaximumLimitError ¶ added in v1.39.0
type ExceedsMaximumLimitError struct {
// contains filtered or unexported fields
}
ExceedsMaximumLimitError occurs when a limit that is too large is given to a call.
func NewExceedsMaximumLimitErr ¶ added in v1.32.0
func NewExceedsMaximumLimitErr(providedLimit uint64, maxLimitAllowed uint64) ExceedsMaximumLimitError
NewExceedsMaximumLimitErr creates a new error representing that the limit specified was too large.
func (ExceedsMaximumLimitError) GRPCStatus ¶ added in v1.39.0
func (err ExceedsMaximumLimitError) GRPCStatus() *status.Status
GRPCStatus implements retrieving the gRPC status for the error.
func (ExceedsMaximumLimitError) MarshalZerologObject ¶ added in v1.39.0
func (err ExceedsMaximumLimitError) MarshalZerologObject(e *zerolog.Event)
MarshalZerologObject implements zerolog object marshalling.
type ExceedsMaximumPreconditionsError ¶ added in v1.39.0
type ExceedsMaximumPreconditionsError struct {
// contains filtered or unexported fields
}
ExceedsMaximumPreconditionsError occurs when too many preconditions are given to a call.
func NewExceedsMaximumPreconditionsErr ¶ added in v1.14.0
func NewExceedsMaximumPreconditionsErr(preconditionCount uint64, maxCountAllowed uint64) ExceedsMaximumPreconditionsError
NewExceedsMaximumPreconditionsErr creates a new error representing that too many preconditions were given to a call.
func (ExceedsMaximumPreconditionsError) GRPCStatus ¶ added in v1.39.0
func (err ExceedsMaximumPreconditionsError) GRPCStatus() *status.Status
GRPCStatus implements retrieving the gRPC status for the error.
func (ExceedsMaximumPreconditionsError) MarshalZerologObject ¶ added in v1.39.0
func (err ExceedsMaximumPreconditionsError) MarshalZerologObject(e *zerolog.Event)
MarshalZerologObject implements zerolog object marshalling.
type ExceedsMaximumUpdatesError ¶ added in v1.39.0
type ExceedsMaximumUpdatesError struct {
// contains filtered or unexported fields
}
ExceedsMaximumUpdatesError occurs when too many updates are given to a call.
func NewExceedsMaximumUpdatesErr ¶ added in v1.14.0
func NewExceedsMaximumUpdatesErr(updateCount uint64, maxCountAllowed uint64) ExceedsMaximumUpdatesError
NewExceedsMaximumUpdatesErr creates a new error representing that too many updates were given to a WriteRelationships call.
func (ExceedsMaximumUpdatesError) GRPCStatus ¶ added in v1.39.0
func (err ExceedsMaximumUpdatesError) GRPCStatus() *status.Status
GRPCStatus implements retrieving the gRPC status for the error.
func (ExceedsMaximumUpdatesError) MarshalZerologObject ¶ added in v1.39.0
func (err ExceedsMaximumUpdatesError) MarshalZerologObject(e *zerolog.Event)
MarshalZerologObject implements zerolog object marshalling.
type ExperimentalQueryPlanConfig ¶ added in v1.50.0
type ExperimentalQueryPlanConfig struct {
// Check enables the query plan for CheckPermission calls.
Check bool
// LookupResources enables the query plan for LookupResources calls.
LookupResources bool
// LookupSubjects enables the query plan for LookupSubjects calls.
LookupSubjects bool
}
ExperimentalQueryPlanConfig controls which API operations are routed through the experimental query plan engine instead of the standard dispatcher.
type InvalidCursorError ¶ added in v1.39.0
type InvalidCursorError struct {
// contains filtered or unexported fields
}
InvalidCursorError indicates that an invalid cursor was found.
func NewInvalidCursorErr ¶ added in v1.22.0
func NewInvalidCursorErr(reason string) InvalidCursorError
NewInvalidCursorErr constructs a new invalid cursor error.
func (InvalidCursorError) GRPCStatus ¶ added in v1.39.0
func (err InvalidCursorError) GRPCStatus() *status.Status
GRPCStatus implements retrieving the gRPC status for the error.
type InvalidFilterError ¶ added in v1.39.0
type InvalidFilterError struct {
// contains filtered or unexported fields
}
InvalidFilterError indicates the specified relationship filter was invalid.
func NewInvalidFilterErr ¶ added in v1.30.0
func NewInvalidFilterErr(reason string, filter string) InvalidFilterError
NewInvalidFilterErr constructs a new invalid filter error.
func (InvalidFilterError) GRPCStatus ¶ added in v1.39.0
func (err InvalidFilterError) GRPCStatus() *status.Status
GRPCStatus implements retrieving the gRPC status for the error.
type Metrics ¶ added in v1.55.0
type Metrics struct {
// contains filtered or unexported fields
}
Metrics holds the Prometheus metrics exported by the v1 services. It is intended to be constructed once when the server is assembled and shared by every service registered against the same registry. It holds metrics that are emmitted from various APIs.
func NewMetrics ¶ added in v1.55.0
func NewMetrics(registry prometheus.Registerer) *Metrics
NewMetrics creates the v1 services metrics and registers them with the given registry. If the registry is nil, the metrics are usable but not registered anywhere and thus never exported; this is the safe default for tests and tooling that construct servers repeatedly within one process.
func (*Metrics) RecordBulkImportedRelationships ¶ added in v1.55.0
RecordBulkImportedRelationships records the number of relationships written by a bulk import call, as CREATE updates on the write-updates histogram.
func (*Metrics) RecordCheckResult ¶ added in v1.55.0
func (m *Metrics) RecordCheckResult(method string, permissionship v1.CheckPermissionResponse_Permissionship)
RecordCheckResult records the permissionship returned by a successful check.
func (*Metrics) RecordWriteRelationshipsUpdates ¶ added in v1.55.0
func (m *Metrics) RecordWriteRelationshipsUpdates(kind v1.RelationshipUpdate_Operation, count int)
RecordWriteRelationshipsUpdates records the number of updates of the given kind in a WriteRelationships call.
type NotAPermissionError ¶ added in v1.39.0
type NotAPermissionError struct {
// contains filtered or unexported fields
}
NotAPermissionError indicates that the relation is not a permission.
func NewNotAPermissionError ¶ added in v1.33.0
func NewNotAPermissionError(relationName string) NotAPermissionError
NewNotAPermissionError constructs a new not a permission error.
func (NotAPermissionError) GRPCStatus ¶ added in v1.39.0
func (err NotAPermissionError) GRPCStatus() *status.Status
GRPCStatus implements retrieving the gRPC status for the error.
type PermissionsServerConfig ¶ added in v1.12.0
type PermissionsServerConfig struct {
// MaxUpdatesPerWrite holds the maximum number of updates allowed per
// WriteRelationships call.
MaxUpdatesPerWrite uint16
// MaxPreconditionsCount holds the maximum number of preconditions allowed
// on a WriteRelationships or DeleteRelationships call.
MaxPreconditionsCount uint16
// MaximumAPIDepth is the default/starting depth remaining for API calls made
// to the permissions server.
MaximumAPIDepth uint32
// DispatchChunkSize is the maximum number of elements to dispach in a dispatch call
DispatchChunkSize uint16
// StreamingAPITimeout is the timeout for streaming APIs when no response has been
// recently received.
StreamingAPITimeout time.Duration
// MaxCaveatContextSize defines the maximum length of the request caveat context in bytes
MaxCaveatContextSize int
// MaxRelationshipContextSize defines the maximum length of a relationship's context in bytes
MaxRelationshipContextSize int
// MaxDatastoreReadPageSize defines the maximum number of relationships loaded from the
// datastore in one query.
MaxDatastoreReadPageSize uint64
// MaxCheckBulkConcurrency defines the maximum number of concurrent checks that can be
// made in a single CheckBulkPermissions call.
MaxCheckBulkConcurrency uint16
// MaxReadRelationshipsLimit defines the maximum number of relationships that can be read
// in a single ReadRelationships call.
MaxReadRelationshipsLimit uint32
// MaxDeleteRelationshipsLimit defines the maximum number of relationships that can be deleted
// in a single DeleteRelationships call.
MaxDeleteRelationshipsLimit uint32
// MaxLookupResourcesLimit defines the maximum number of resources that can be looked up in a
// single LookupResources call.
MaxLookupResourcesLimit uint32
// MaxBulkExportRelationshipsLimit defines the maximum number of relationships that can be
// exported in a single BulkExportRelationships call.
MaxBulkExportRelationshipsLimit uint32
// ExpiringRelationshipsEnabled defines whether or not expiring relationships are enabled.
ExpiringRelationshipsEnabled bool
// CaveatTypeSet is the set of caveat types to use for caveats. If not specified,
// the default type set is used.
CaveatTypeSet *caveattypes.TypeSet
// PerformanceInsightMetricsEnabled defines whether or not performance insight metrics are enabled.
PerformanceInsightMetricsEnabled bool
// EnableExperimentalLookupResources3 is used to enable LookupResources v3 for testing.
EnableExperimentalLookupResources3 bool // TODO: remove when LookupResources v3 is fully enabled
// ExperimentalQueryPlan configures which API operations use the experimental query plan.
ExperimentalQueryPlan ExperimentalQueryPlanConfig
// Metrics holds the metrics shared by the v1 services. It is meant to be
// built once (via NewMetrics) when the server is assembled and passed to
// every service constructor sharing this config. When nil, a fresh,
// unregistered (and therefore unexported) instance is used.
Metrics *Metrics
// QueryPlanMetadata is the shared per-server stats store that drives the
// count-based plan advisor. When nil, NewPermissionsServer allocates a fresh
// instance. To share stats with a co-located dispatcher (so receiver-side
// dispatch can consult and update the same store), construct one externally
// and pass it both here and via graph.DispatcherParameters.
QueryPlanMetadata *query.QueryPlanMetadata
}
PermissionsServerConfig is configuration for the permissions server.
type PreconditionFailedError ¶ added in v1.39.0
type PreconditionFailedError struct {
// contains filtered or unexported fields
}
PreconditionFailedError occurs when the precondition to a write tuple call does not match.
func (PreconditionFailedError) GRPCStatus ¶ added in v1.39.0
func (err PreconditionFailedError) GRPCStatus() *status.Status
GRPCStatus implements retrieving the gRPC status for the error.
func (PreconditionFailedError) MarshalZerologObject ¶ added in v1.39.0
func (err PreconditionFailedError) MarshalZerologObject(e *zerolog.Event)
MarshalZerologObject implements zerolog object marshalling.
type SchemaServerConfig ¶ added in v1.44.0
type SchemaServerConfig struct {
// CaveatTypeSet is the set of caveat types that are allowed in the schema.
CaveatTypeSet *caveattypes.TypeSet
// AdditiveOnly indicates whether the schema is additive only.
AdditiveOnly bool
// ExpiringRelsEnabled indicates whether expiring relationships are enabled.
ExpiringRelsEnabled bool
// PerformanceInsightMetricsEnabled indicates whether performance insight metrics are enabled.
PerformanceInsightMetricsEnabled bool
}
type TransactionMetadataTooLargeError ¶ added in v1.39.0
type TransactionMetadataTooLargeError struct {
// contains filtered or unexported fields
}
TransactionMetadataTooLargeError indicates that the metadata for a transaction is too large.
func NewTransactionMetadataTooLargeErr ¶ added in v1.38.0
func NewTransactionMetadataTooLargeErr(metadataSize int, maxSize int) TransactionMetadataTooLargeError
NewTransactionMetadataTooLargeErr constructs a new transaction metadata too large error.
func (TransactionMetadataTooLargeError) GRPCStatus ¶ added in v1.39.0
func (err TransactionMetadataTooLargeError) GRPCStatus() *status.Status
func (TransactionMetadataTooLargeError) MarshalZerologObject ¶ added in v1.39.0
func (err TransactionMetadataTooLargeError) MarshalZerologObject(e *zerolog.Event)