Documentation
¶
Overview ¶
Package slate implements a service orientated application scaffolding.
Index ¶
- Constants
- 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 IApplication
- type IContainer
- type IProvider
Constants ¶
const ( // ID defines the slate package container id base string. ID = "slate" // EnvID defines the slate package base environment variable name. EnvID = "SLATE" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
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(_ ...IContainer) (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.
func (*Application) Register ¶ added in v0.17.0
func (a *Application) Register(_ ...IContainer) error
Register is a no-op method, is present just to provide the application instance the interface of a provider, making it easy to define an application as a main provider instance.
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 IApplication ¶ added in v0.9.0
type IApplication interface { IContainer IProvider Provide(provider IProvider) error }
IApplication defines the interface of a slate application instance.
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(...IContainer) error Boot(...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.
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. |
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 err declares all the errors that can be originated by the slate framework.
|
Package err declares all the errors that can be originated by the slate framework. |
Package fs define instances an application provider that publicise an interface to the file system.
|
Package fs define instances an application provider that publicise an interface to the file system. |
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. |
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. |
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. |