reverseexpand

package
v1.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2025 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Overview

Package reverseexpand contains the code that handles the ReverseExpand API

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptyStack           = errors.New("unexpected empty stack")
	ErrLowestWeightFail     = errors.New("failed to get lowest weight edge")
	ErrConstructUsersetFail = errors.New("failed to construct userset")
)

Functions

This section is empty.

Types

type Backend added in v1.10.4

type Backend struct {
	Datastore  storage.RelationshipTupleReader
	StoreID    string
	TypeSystem *typesystem.TypeSystem
	Context    *structpb.Struct
	Graph      *Graph
	Preference openfgav1.ConsistencyPreference
}

Backend is a struct that serves as a container for all backend elements necessary for creating and running a `Pipeline`.

type ConditionalResultStatus

type ConditionalResultStatus int
const (
	RequiresFurtherEvalStatus ConditionalResultStatus = iota
	NoFurtherEvalStatus
)

type Edge added in v1.10.4

type ExecutionError added in v1.9.3

type ExecutionError struct {
	// contains filtered or unexported fields
}

func (*ExecutionError) Error added in v1.9.3

func (e *ExecutionError) Error() string

type Graph added in v1.10.4

type IsUserRef

type IsUserRef interface {
	GetObjectType() string
	String() string
	// contains filtered or unexported methods
}

type Item added in v1.10.4

type Item struct {
	Value string
	Err   error
}

Item is a struct that contains an object `string` as its `Value` or an encountered error as its `Err`. Item is the primary container used to communicate values as they pass through a `Pipeline`.

type Node added in v1.10.4

type Pipeline added in v1.10.4

type Pipeline struct {
	// contains filtered or unexported fields
}

func NewPipeline added in v1.10.4

func NewPipeline(backend *Backend, options ...PipelineOption) *Pipeline

func (*Pipeline) Build added in v1.10.4

func (p *Pipeline) Build(ctx context.Context, source Source, target Target) iter.Seq[Item]

func (*Pipeline) Source added in v1.10.4

func (p *Pipeline) Source(name, relation string) (Source, bool)

func (*Pipeline) Target added in v1.10.4

func (p *Pipeline) Target(name, identifier string) (Target, bool)

type PipelineOption added in v1.10.4

type PipelineOption func(*Pipeline)

func WithChunkSize added in v1.10.4

func WithChunkSize(size int) PipelineOption

func WithNumProcs added in v1.10.4

func WithNumProcs(num int) PipelineOption

type ResolutionMetadata

type ResolutionMetadata struct {
	// The number of times we are expanding from each node to find set of objects
	DispatchCounter *atomic.Uint32

	// WasThrottled indicates whether the request was throttled
	WasThrottled *atomic.Bool

	// WasWeightedGraphUsed indicates whether the weighted graph was used as the algorithm for the ReverseExpand request.
	WasWeightedGraphUsed *atomic.Bool

	// The number of times internal check was called for the optimization path
	CheckCounter *atomic.Uint32
}

func NewResolutionMetadata

func NewResolutionMetadata() *ResolutionMetadata

type ReverseExpandQuery

type ReverseExpandQuery struct {
	// contains filtered or unexported fields
}

func NewReverseExpandQuery

TODO accept ReverseExpandRequest so we can build the datastore object right away.

func (*ReverseExpandQuery) Execute

func (c *ReverseExpandQuery) Execute(
	ctx context.Context,
	req *ReverseExpandRequest,
	resultChan chan<- *ReverseExpandResult,
	resolutionMetadata *ResolutionMetadata,
) error

Execute yields all the objects of the provided objectType that the given user possibly has, a specific relation with and sends those objects to resultChan. It MUST guarantee no duplicate objects sent.

This function respects context timeouts and cancellations. If an error is encountered (e.g. context timeout) before resolving all objects, then the provided channel will NOT be closed, and it will return the error.

If no errors occur, then Execute will yield all of the objects on the provided channel and then close the channel to signal that it is done.

type ReverseExpandQueryOption

type ReverseExpandQueryOption func(d *ReverseExpandQuery)

func WithCheckResolver added in v1.9.0

func WithCheckResolver(resolver graph.CheckResolver) ReverseExpandQueryOption

func WithDispatchThrottlerConfig added in v1.5.4

func WithDispatchThrottlerConfig(config threshold.Config) ReverseExpandQueryOption

func WithListObjectOptimizationsEnabled added in v1.9.0

func WithListObjectOptimizationsEnabled(enabled bool) ReverseExpandQueryOption

func WithLogger added in v1.4.3

func WithLogger(logger logger.Logger) ReverseExpandQueryOption

func WithResolveNodeBreadthLimit

func WithResolveNodeBreadthLimit(limit uint32) ReverseExpandQueryOption

func WithResolveNodeLimit

func WithResolveNodeLimit(limit uint32) ReverseExpandQueryOption

type ReverseExpandRequest

type ReverseExpandRequest struct {
	StoreID          string
	ObjectType       string
	Relation         string
	User             IsUserRef
	ContextualTuples []*openfgav1.TupleKey // TODO remove
	Context          *structpb.Struct
	Consistency      openfgav1.ConsistencyPreference
	// contains filtered or unexported fields
}

type ReverseExpandResult

type ReverseExpandResult struct {
	Object       string
	ResultStatus ConditionalResultStatus
}

type Source added in v1.10.4

type Source *Node

type StatusPool added in v1.10.4

type StatusPool struct {
	// contains filtered or unexported fields
}

StatusPool is a struct that aggregates status values, as booleans, from multiple sources into a single boolean status value. Each source must register itself using the `Register` method and supply the returned value in each call to `Set` when updating the source's status value. The default state of a StatusPool is `false` for all sources. All StatusPool methods are thread safe.

func (*StatusPool) Register added in v1.10.4

func (sp *StatusPool) Register() int

Register is a function that creates a new entry in the StatusPool for a source and returns an identifier that is unique within the context of the StatusPool instance. The returned integer identifier values are predictable incrementing values beginning at 0. The `Register` method is thread safe.

func (*StatusPool) Set added in v1.10.4

func (sp *StatusPool) Set(id int, status bool)

Set is a function that accepts a registered identifier and a boolean status. The caller must provide an integer identifier returned from an initial call to the `Register` function associated with the desired source. The `Set` function is thread safe.

func (*StatusPool) Status added in v1.10.4

func (sp *StatusPool) Status() bool

Status is a function that returns the cummulative status of all sources registered within the pool. If any registered source's status is set to `true`, the return value of the `Status` function will be `true`. The default value is `false`. The `Status` function is thread safe.

type Target added in v1.10.4

type Target struct {
	// contains filtered or unexported fields
}

type UserRef

type UserRef struct {

	// Types that are assignable to Ref
	//  *UserRef_Object
	//  *UserRef_TypedWildcard
	//  *UserRef_ObjectRelation
	Ref IsUserRef
}

type UserRefObject

type UserRefObject struct {
	Object *openfgav1.Object
}

func (*UserRefObject) GetObjectType

func (u *UserRefObject) GetObjectType() string

func (*UserRefObject) String

func (u *UserRefObject) String() string

type UserRefObjectRelation

type UserRefObjectRelation struct {
	ObjectRelation *openfgav1.ObjectRelation
	Condition      *openfgav1.RelationshipCondition
}

func (*UserRefObjectRelation) GetObjectType

func (u *UserRefObjectRelation) GetObjectType() string

func (*UserRefObjectRelation) String

func (u *UserRefObjectRelation) String() string

type UserRefTypedWildcard

type UserRefTypedWildcard struct {
	Type string
}

func (*UserRefTypedWildcard) GetObjectType

func (u *UserRefTypedWildcard) GetObjectType() string

func (*UserRefTypedWildcard) String

func (u *UserRefTypedWildcard) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL