Documentation
¶
Overview ¶
Package containing custom dependency container for dependency injection. There is only ever one container and it can be used globally to access all the dependencies.
Package containing custom dependency container for dependency injection. There is only ever one container and it can be used globally to access all the dependencies.
Package containing custom dependency container for dependency injection. There is only ever one container and it can be used globally to access all the dependencies.
Index ¶
- func AddConfigurationBuilder[T any](filePath string, cfgType core.ConfigType) error
- func AddCustomConfiguration[T any](configurationRead func() ([]byte, error), cfgType core.ConfigType) error
- func AddStaticService[T interface{}](spec T, impl any) error
- func AddTransientService[T interface{}](spec T, impl any) error
- func Build() error
- func GetRoids() *roidsContainer
- func Inject[T interface{}]() T
- func UNSAFE_Clear()
- type Service
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddConfigurationBuilder ¶ added in v0.4.0
func AddConfigurationBuilder[T any](filePath string, cfgType core.ConfigType) error
Add a custom configuration file. Default roids.settings.json file.
func AddCustomConfiguration ¶ added in v0.4.0
func AddCustomConfiguration[T any](configurationRead func() ([]byte, error), cfgType core.ConfigType) error
Add Custom Configuration configuraitonRead expects a slice of bytes encoded as json or yaml depending on the config type.
func AddStaticService ¶ added in v0.2.0
Adds a static service to the container. A static service is only created once and lives for the life of the application. Uses the specification (interface or struct) to inject an implementation into the IoC container
func AddTransientService ¶ added in v0.2.0
Adds a transient service to the container. A transient service is newly instantiated for each use.
func GetRoids ¶
func GetRoids() *roidsContainer
Thread-safe function to get the global instance of the dependency container.
func Inject ¶
func Inject[T interface{}]() T
Gets an implementation of a service based on an specification from the container.
func UNSAFE_Clear ¶
func UNSAFE_Clear()
Clears the container of all services SUPER UNSAFE. Only used during testing. Dont use while running an application.
Types ¶
type Service ¶
type Service struct {
// Injector is a function that returns a pointer to a concrete implementation
Injector any
// ID representing and identifying the service
Id string
// The service specification or interface type
SpecType reflect.Type
// contains filtered or unexported fields
}
Struct representing an injectable service. (aka Provider, Assembler, Service, or Injector)
