checkgroup

package
v0.11.1-alpha.0 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ResultIsMember  = Result{Membership: IsMember}
	ResultNotMember = Result{Membership: NotMember}
)
View Source
var DefaultFactory = NewConcurrent

Functions

func IsMemberFunc

func IsMemberFunc(_ context.Context, resultCh chan<- Result)

func NotMemberFunc

func NotMemberFunc(_ context.Context, resultCh chan<- Result)

func UnknownMemberFunc

func UnknownMemberFunc(_ context.Context, resultCh chan<- Result)

Types

type CheckFunc

type CheckFunc = func(ctx context.Context, resultCh chan<- Result)

func ErrorFunc

func ErrorFunc(err error) CheckFunc

func WithEdge

func WithEdge(e Edge, f CheckFunc) CheckFunc

WithEdge adds the edge e to the result of the function.

type Checkgroup

type Checkgroup interface {
	// Done returns true if a result is available.
	Done() bool

	// Add adds the CheckFunc to the checkgroup and starts running it.
	Add(check CheckFunc)

	// SetIsMember makes the checkgroup emit "IsMember" directly.
	SetIsMember()

	// Result returns the result, possibly blocking.
	Result() Result

	// CheckFunc returns a CheckFunc that writes the result to the result
	// channel.
	CheckFunc() CheckFunc
}

func New

func New(ctx context.Context) Checkgroup

func NewConcurrent

func NewConcurrent(ctx context.Context) Checkgroup

type Edge

type Edge struct {
	Tuple relationtuple.RelationTuple
	Type  ketoapi.TreeNodeType
}

type Factory

type Factory = func(ctx context.Context) Checkgroup

type Membership

type Membership int
const (
	MembershipUnknown Membership = iota
	IsMember
	NotMember
)

func (Membership) String

func (i Membership) String() string

type Pool

type Pool interface {
	// Add adds the function to the pool and schedules it. The function will
	// only be run if there is a free worker available in the pool, thus
	// limiting the concurrent workloads in flight.
	Add(check func())

	// TryAdd tries to add the check function if the pool has capacity.
	// Otherwise, it returns false and does not add the check.
	TryAdd(check func()) bool
}

type Result

type Result struct {
	Membership Membership
	Tree       *ketoapi.Tree[*relationtuple.RelationTuple]
	Err        error
}

type Transformation

type Transformation int

Jump to

Keyboard shortcuts

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