Documentation ¶
Overview ¶
Package slate implements a service orientated application scaffolding based on Uber dependency injection project and the extensive use of a service container and service registration providers.
Index ¶
- Constants
- Variables
- func NewError(msg string, ctx ...map[string]interface{}) error
- func NewErrorFrom(err error, msg string, ctx ...map[string]interface{}) error
- type Application
- type Container
- func (c *Container) Clear() error
- func (c *Container) Close() error
- func (c *Container) Get(id string) (any, error)
- func (c *Container) Has(id string) bool
- func (c *Container) Remove(id string) error
- func (c *Container) Service(id string, factory interface{}, tags ...string) error
- func (c *Container) Tag(tag string) ([]any, error)
- type Error
- type IApplication
- type IContainer
- type IError
- type IProvider
Constants ¶
const ( // ID defines the slate package container service id base string. ID = "slate" // EnvID defines the slate package environment variable base name. EnvID = "SLATE" )
Variables ¶
var ( // ErrNilPointer defines a nil pointer argument error. ErrNilPointer = NewError("invalid nil pointer") // ErrConversion defines a type conversion error. ErrConversion = NewError("invalid type conversion") // ErrContainer defines a container error. ErrContainer = NewError("service container error") // ErrNonFunctionFactory defines a service container registration error // that signals that the registration request was made with a // non-function service factory. ErrNonFunctionFactory = NewError("non-function service factory") // ErrFactoryWithoutResult defines a service container registration error // that signals that the registration request was made with a // function service factory that don't return a service. ErrFactoryWithoutResult = NewError("service factory without result") // ErrServiceNotFound defines a service not found on the container. ErrServiceNotFound = NewError("service not found") )
Functions ¶
Types ¶
type Application ¶
type Application struct { Container // contains filtered or unexported fields }
Application defines the structure that controls the application container and container initialization.
func NewApplication ¶
func NewApplication() *Application
NewApplication used to instantiate a new application.
func (*Application) Boot ¶
func (a *Application) Boot() (e error)
Boot initializes the application if not initialized yet. The initialization of an application is the calling of the register method on all providers, after the registration of all objects in the container, the boot method of all providers will be executed.
func (*Application) Provide ¶ added in v0.17.0
func (a *Application) Provide( provider IProvider, ) error
Provide will register a new provider into the application used on the application boot.
type Container ¶ added in v0.16.0
type Container struct {
// contains filtered or unexported fields
}
Container defines the structure that hold the application service factories and initialized services.
func NewContainer ¶ added in v0.16.0
func NewContainer() *Container
NewContainer used to instantiate a new application service container.
func (*Container) Clear ¶ added in v0.16.0
Clear will eliminate all the registered object from the container.
func (*Container) Close ¶ added in v0.16.0
Close clean up the container from all the stored objects. If the object has been already instantiated and implements the Closable interface, then the Close method will be called upon the removing instance.
func (*Container) Get ¶ added in v0.16.0
Get will retrieve the requested object from the container. If the object has not yet been instantiated, then the factory method will be executed to instantiate it.
func (*Container) Has ¶ added in v0.16.0
Has will check if an object is registered with the requested id. This does not mean that is instantiated. The instantiation is just executed when the instance is requested for the first time.
func (*Container) Remove ¶ added in v0.16.0
Remove will eliminate the object from the container. If the object has been already instantiated and implements the Closable interface, then the Close method will be called on the removing instance.
func (*Container) Service ¶ added in v0.16.0
Service will register a service factory used to return an instance generated by the given factory. This factory method will only be called once, meaning that everytime the service is requested, is always returned the same instance. If any object was registered previously with the requested id, then the object will be removed by calling the Remove method previously the storing of the new object factory.
type Error ¶ added in v0.20.0
type Error struct {
// contains filtered or unexported fields
}
Error defines a contextualized error
type IApplication ¶ added in v0.9.0
type IApplication interface { IContainer Provide(provider IProvider) error Boot() error }
IApplication defines the interface of a slate application instance that implements a container and handles a series of service providers so the application can properly initialize.
type IContainer ¶ added in v0.16.0
type IContainer interface { io.Closer Has(id string) bool Service(id string, factory interface{}, tags ...string) error Get(id string) (any, error) Tag(tag string) ([]any, error) Remove(id string) error Clear() error }
IContainer defines the interface of a slate application service container instance.
type IProvider ¶ added in v0.16.0
type IProvider interface { Register(container IContainer) error Boot(container IContainer) error }
IProvider is an interface used to define the methods of an object that can be registered into a slate application and register elements in the application container and do some necessary boot actions on initialization.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package config define instances an application provider that publicise services used to manage an application configuration.
|
Package config define instances an application provider that publicise services used to manage an application configuration. |
decoder
Package decoder defines the base types and structures of all configuration decoding functionalities.
|
Package decoder defines the base types and structures of all configuration decoding functionalities. |
decoder/json
Package json defines the JSON format decoder and decoder creation strategy to be integrated into the config package decoder factory instance.
|
Package json defines the JSON format decoder and decoder creation strategy to be integrated into the config package decoder factory instance. |
decoder/yaml
Package yaml defines the YAML format decoder and decoder creation strategy to be integrated into the config package decoder factory instance.
|
Package yaml defines the YAML format decoder and decoder creation strategy to be integrated into the config package decoder factory instance. |
source
Package source defines the base types and structures of all configuration source functionalities.
|
Package source defines the base types and structures of all configuration source functionalities. |
source/aggregate
Package aggregate defines the aggregate source creation strategy to be integrated into the config package source factory instance.
|
Package aggregate defines the aggregate source creation strategy to be integrated into the config package source factory instance. |
source/dir
Package dir defines the directory source creation strategy to be integrated into the config package source factory instance.
|
Package dir defines the directory source creation strategy to be integrated into the config package source factory instance. |
source/env
Package env defines the environment source creation strategy to be integrated into the config package source factory instance.
|
Package env defines the environment source creation strategy to be integrated into the config package source factory instance. |
source/file
Package file defines the file type sources creation strategies to be integrated into the config package source factory instance.
|
Package file defines the file type sources creation strategies to be integrated into the config package source factory instance. |
source/rest
Package rest defines the REST connection source creation strategy to be integrated into the config package source factory instance.
|
Package rest defines the REST connection source creation strategy to be integrated into the config package source factory instance. |
Package dig provides an opinionated way of resolving object dependencies.
|
Package dig provides an opinionated way of resolving object dependencies. |
internal/digtest
Package digtest provides utilities used by dig internally to test its own functionality.
|
Package digtest provides utilities used by dig internally to test its own functionality. |
Package env implements auxiliary functions to access environment variables values.
|
Package env implements auxiliary functions to access environment variables values. |
Package fs define an application provider that publicise an adapter to the file system that can be used by the dependency injection module od the container.
|
Package fs define an application provider that publicise an adapter to the file system that can be used by the dependency injection module od the container. |
Package log define instances an application provider that publicise services used to manage an application logging processes.
|
Package log define instances an application provider that publicise services used to manage an application logging processes. |
formatter
Package formatter defines the base types and structures of all logging formatter functionalities.
|
Package formatter defines the base types and structures of all logging formatter functionalities. |
formatter/json
Package json defines the logging JSON formatter and JSON formatter creation strategy to be integrated into the logging package formatter factory instance.
|
Package json defines the logging JSON formatter and JSON formatter creation strategy to be integrated into the logging package formatter factory instance. |
stream
Package stream defines the base types and structures of all logging stream functionalities.
|
Package stream defines the base types and structures of all logging stream functionalities. |
stream/console
Package console defines the logging console stream and console stream creation strategy to be integrated into the logging package stream factory instance.
|
Package console defines the logging console stream and console stream creation strategy to be integrated into the logging package stream factory instance. |
stream/file
Package file defines the logging file stream and file stream creation strategy to be integrated into the logging package stream factory instance.
|
Package file defines the logging file stream and file stream creation strategy to be integrated into the logging package stream factory instance. |
Package migration define instances an application provider that publicise an interface to a set of services used to manage states and updates to a relational database schema and data.
|
Package migration define instances an application provider that publicise an interface to a set of services used to manage states and updates to a relational database schema and data. |
Package rdb define instances an application provider that publicise an interface to a set of services used to connect and interact with a relational database.
|
Package rdb define instances an application provider that publicise an interface to a set of services used to connect and interact with a relational database. |
dialect
Package dialect defines the base types and structures of all relational database dialect functionalities.
|
Package dialect defines the base types and structures of all relational database dialect functionalities. |
Package trigger define instances that execute code in the future.
|
Package trigger define instances that execute code in the future. |
Package watchdog define a service creation, execution and simple life-cycle handling, has re-running an unexpected stop of a service callback function.
|
Package watchdog define a service creation, execution and simple life-cycle handling, has re-running an unexpected stop of a service callback function. |
formatter
Package formatter defines the base types and structures of all watchdog logging formatter functionalities.
|
Package formatter defines the base types and structures of all watchdog logging formatter functionalities. |
formatter/def
Package def defines the default logging formatter and default formatter creation strategy to be integrated into the watchdog logging package formatter factory instance.
|
Package def defines the default logging formatter and default formatter creation strategy to be integrated into the watchdog logging package formatter factory instance. |