Documentation ¶
Index ¶
- func ForEachChunk[T any](data []T, chunkSize uint64, handler func(items []T))
- type BaseSubjectSet
- func (bss BaseSubjectSet[T]) Add(foundSubject T) bool
- func (bss BaseSubjectSet[T]) AsSlice() []T
- func (bss BaseSubjectSet[T]) Clone() BaseSubjectSet[T]
- func (bss BaseSubjectSet[T]) Get(id string) (T, bool)
- func (bss BaseSubjectSet[T]) IntersectionDifference(other BaseSubjectSet[T])
- func (bss BaseSubjectSet[T]) IsEmpty() bool
- func (bss BaseSubjectSet[T]) Subtract(foundSubject T)
- func (bss BaseSubjectSet[T]) SubtractAll(other BaseSubjectSet[T])
- func (bss BaseSubjectSet[T]) UnionWith(foundSubjects []T)
- func (bss BaseSubjectSet[T]) UnionWithSet(other BaseSubjectSet[T])
- func (bss BaseSubjectSet[T]) UnsafeRemoveExact(foundSubject T)
- type MultiMap
- type Set
- func (s *Set[T]) Add(value T) bool
- func (s *Set[T]) AsSlice() []T
- func (s *Set[T]) Copy() *Set[T]
- func (s *Set[T]) Extend(values []T)
- func (s *Set[T]) ForEach(callback func(value T) error) error
- func (s *Set[T]) Has(value T) bool
- func (s *Set[T]) Intersect(other *Set[T]) *Set[T]
- func (s *Set[T]) IntersectionDifference(other *Set[T]) *Set[T]
- func (s *Set[T]) IsEmpty() bool
- func (s *Set[T]) Len() int
- func (s *Set[T]) Remove(value T) bool
- func (s *Set[T]) RemoveAll(other *Set[T])
- func (s *Set[T]) Subtract(other *Set[T]) *Set[T]
- type StringSetWrapper
- type Subject
- type SubjectSet
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ForEachChunk ¶
ForEachChunk executes the given handler for each chunk of items in the slice.
Types ¶
type BaseSubjectSet ¶
type BaseSubjectSet[T Subject] struct { // contains filtered or unexported fields }
BaseSubjectSet defines a set that tracks accessible subjects. It is generic to allow other implementations to define the kind of tracking information associated with each subject.
NOTE: Unlike a traditional set, unions between wildcards and a concrete subject will result in *both* being present in the set, to maintain the proper set semantics around wildcards.
func NewBaseSubjectSet ¶
func NewBaseSubjectSet[T Subject]( constructor func(subjectID string, excludedSubjectIDs []string, sources ...T) T, combiner func(existing T, added T) T, ) BaseSubjectSet[T]
NewBaseSubjectSet creates a new base subject set for use underneath well-typed implementation.
The constructor function is a function that returns a new instancre of type T for a particular subject ID. The combiner function is optional, and if given, is used to combine existing elements in the set into a new element. This is typically used in debug packages for tracking of additional metadata.
func (BaseSubjectSet[T]) Add ¶
func (bss BaseSubjectSet[T]) Add(foundSubject T) bool
Add adds the found subject to the set. This is equivalent to a Union operation between the existing set of subjects and a set containing the single subject.
func (BaseSubjectSet[T]) AsSlice ¶
func (bss BaseSubjectSet[T]) AsSlice() []T
AsSlice returns the contents of the subject set as a slice of found subjects.
func (BaseSubjectSet[T]) Clone ¶
func (bss BaseSubjectSet[T]) Clone() BaseSubjectSet[T]
Clone returns a clone of this subject set. Note that this is a shallow clone. NOTE: Should only be used when performance is not a concern.
func (BaseSubjectSet[T]) Get ¶
func (bss BaseSubjectSet[T]) Get(id string) (T, bool)
Get returns the found subject with the given ID in the set, if any.
func (BaseSubjectSet[T]) IntersectionDifference ¶
func (bss BaseSubjectSet[T]) IntersectionDifference(other BaseSubjectSet[T])
IntersectionDifference performs an intersection between this set and the other set, modifying this set in place.
func (BaseSubjectSet[T]) IsEmpty ¶
func (bss BaseSubjectSet[T]) IsEmpty() bool
IsEmpty returns whether the subject set is empty.
func (BaseSubjectSet[T]) Subtract ¶
func (bss BaseSubjectSet[T]) Subtract(foundSubject T)
Subtract subtracts the given subject found the set.
func (BaseSubjectSet[T]) SubtractAll ¶
func (bss BaseSubjectSet[T]) SubtractAll(other BaseSubjectSet[T])
SubtractAll subtracts the other set of subjects from this set of subtracts, modifying this set in place.
func (BaseSubjectSet[T]) UnionWith ¶
func (bss BaseSubjectSet[T]) UnionWith(foundSubjects []T)
UnionWith adds the given subjects to this set, via a union call.
func (BaseSubjectSet[T]) UnionWithSet ¶
func (bss BaseSubjectSet[T]) UnionWithSet(other BaseSubjectSet[T])
UnionWithSet performs a union operation between this set and the other set, modifying this set in place.
func (BaseSubjectSet[T]) UnsafeRemoveExact ¶
func (bss BaseSubjectSet[T]) UnsafeRemoveExact(foundSubject T)
UnsafeRemoveExact removes the *exact* matching subject, with no wildcard handling. This should ONLY be used for testing.
type MultiMap ¶ added in v1.13.0
type MultiMap[T comparable, Q any] struct { // contains filtered or unexported fields }
func NewMultiMap ¶ added in v1.13.0
func NewMultiMap[T comparable, Q any]() *MultiMap[T, Q]
type Set ¶
type Set[T comparable] struct { // contains filtered or unexported fields }
Set implements a very basic generic set.
func (*Set[T]) Add ¶
Add adds the given value to the set and returns true. If the value is already present, returns false.
func (*Set[T]) AsSlice ¶
func (s *Set[T]) AsSlice() []T
AsSlice returns the set as a slice of values.
func (*Set[T]) ForEach ¶ added in v1.14.0
ForEach executes the callback for each item in the set until an error is encountered.
func (*Set[T]) Intersect ¶ added in v1.14.0
Intersect removes any values from this set that are not shared with the other set, returning a new set.
func (*Set[T]) IntersectionDifference ¶
IntersectionDifference removes any values from this set that are not shared with the other set. Returns the same set.
func (*Set[T]) Remove ¶
Remove removes the value from the set, returning whether the element was present when the call was made.
type StringSetWrapper ¶ added in v1.14.0
StringSetWrapper wraps a set of strings and provides marshalling for zerolog.
func StringSet ¶ added in v1.14.0
func StringSet(set *Set[string]) StringSetWrapper
StringSet wraps a Set of strings and provides automatic log marshalling.
func (StringSetWrapper) MarshalZerologObject ¶ added in v1.14.0
func (s StringSetWrapper) MarshalZerologObject(e *zerolog.Event)
MarshalZerologObject implements zerolog object marshalling.
type Subject ¶
type Subject interface { // GetSubjectId returns the ID of the subject. For wildcards, this should be `*`. GetSubjectId() string // GetExcludedSubjectIds returns the list of subject IDs excluded. Should only have values // for wildcards. GetExcludedSubjectIds() []string }
Subject is a subject that can be placed into a BaseSubjectSet.
type SubjectSet ¶
type SubjectSet struct { BaseSubjectSet[*v1.FoundSubject] }
SubjectSet defines a set that tracks accessible subjects.
NOTE: Unlike a traditional set, unions between wildcards and a concrete subject will result in *both* being present in the set, to maintain the proper set semantics around wildcards.
func NewSubjectSet ¶
func NewSubjectSet() SubjectSet
NewSubjectSet creates and returns a new subject set.
func (SubjectSet) IntersectionDifference ¶
func (ss SubjectSet) IntersectionDifference(other SubjectSet)
func (SubjectSet) SubtractAll ¶
func (ss SubjectSet) SubtractAll(other SubjectSet)
func (SubjectSet) UnionWithSet ¶
func (ss SubjectSet) UnionWithSet(other SubjectSet)