Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Factory ¶
type Factory[T any] struct { // contains filtered or unexported fields }
func NewFactory ¶
func (*Factory[T]) Register ¶
Register registers a new build functionx. The name is the key used to retrieve the build functionx. If the name is already registered, returns an error. The name is not case sensitive.
func (*Factory[T]) Unregister ¶
type SafeFactory ¶
type SafeFactory[T any] struct { // contains filtered or unexported fields }
SafeFactory is a factory that can create objects of type T. It is safe for concurrent use.
func NewSafeFactory ¶
func NewSafeFactory[T any]() *SafeFactory[T]
func (*SafeFactory[T]) Register ¶
func (f *SafeFactory[T]) Register(name string, fn func() (T, error)) error
Register registers a new factory functionx for the given type. The name is used to identify the type in the factory. If the name is already registered, returns an error. it is not case sensitive.
func (*SafeFactory[T]) Unregister ¶
func (f *SafeFactory[T]) Unregister(name string) error
Click to show internal directories.
Click to hide internal directories.