Documentation
¶
Index ¶
- type Registerer
- type RegistererFuncs
- type Registry
- func (receiver *Registry[T]) For(fn func(Registerer[T], string, T))
- func (receiver *Registry[T]) Get(name string) (value T, found bool)
- func (receiver *Registry[T]) Len() int
- func (receiver *Registry[T]) Set(name string, value T) (previous T, found bool)
- func (receiver *Registry[T]) Unset(name string) (previous T, found bool)
- func (receiver *Registry[T]) UnsetWhen(name string, whenFunc func(T) bool) (previous T, found bool, when bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Registerer ¶
type RegistererFuncs ¶
type RegistererFuncs[T any] struct { GetFunc func(name string) (value T, found bool) LenFunc func() int SetFunc func(name string, value T) (previous T, found bool) UnsetFunc func(name string) (previous T, found bool) }
func (RegistererFuncs[T]) Get ¶
func (receiver RegistererFuncs[T]) Get(name string) (value T, found bool)
func (RegistererFuncs[T]) Len ¶
func (receiver RegistererFuncs[T]) Len() int
func (RegistererFuncs[T]) Set ¶
func (receiver RegistererFuncs[T]) Set(name string, value T) (previous T, found bool)
func (RegistererFuncs[T]) Unset ¶
func (receiver RegistererFuncs[T]) Unset(name string) (previous T, found bool)
type Registry ¶
type Registry[T any] struct { // contains filtered or unexported fields }
func (*Registry[T]) For ¶
func (receiver *Registry[T]) For(fn func(Registerer[T], string, T))
For lets you iterate through all the items in the registry — it calls func 'fn' on each item in the registry.
Note that you should NOT call .Get(), .Set(), .Len(), or .Unset() from the `fn`. It will cause For to lock.
func (*Registry[T]) Get ¶
Get return the item inthe registry registered under the name 'name'.
This should NOT be called from within the function passed to Registry.For. Doing so will cause a deadlock
func (*Registry[T]) Len ¶
Len returns the number of items in the registry.
This should NOT be called from within the function passed to Registry.For. Doing so will cause a deadlock
func (*Registry[T]) Set ¶
Set registers an item in the registry under the name 'name', but it also returns the previous item under the name 'name' if it existed.
This should NOT be called from within the function passed to Registry.For. Doing so will cause a deadlock
func (*Registry[T]) Unset ¶
Unset removes an item in the registry under the name 'name', if it is there, and it also returns the previous item under the name 'name' if it existed.
This should NOT be called from within the function passed to Registry.For. Doing so will cause a deadlock
func (*Registry[T]) UnsetWhen ¶
func (receiver *Registry[T]) UnsetWhen(name string, whenFunc func(T) bool) (previous T, found bool, when bool)
UnsetWhen removes an item in the registry under the name 'name', if it is there and the `whenFunc` returns true, and it also returns the previous item under the name 'name' if it existed.
This should NOT be called from within the function passed to Registry.For. Doing so will cause a deadlock