slate

package module
v0.30.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 15, 2023 License: MIT Imports: 18 Imported by: 11

README

slate

Opinionated golang application scaffolding

  • slate
    • config
      • decoder
        • json
        • yaml
      • source
        • env
        • file
        • dir
        • aggregate
        • rest
    • env
    • fs
    • log
      • formatter
        • json
      • stream
        • console
        • file
    • migration
    • rdb
      • dialect
        • sqlite
        • mysql
    • trigger
    • watchdog
      • formatter
        • default

Documentation

Overview

Package slate implements a service orientated application scaffolding based on Uber dependency injection project and the extensive use of a service di and service registration providers.

Index

Constants

View Source
const (
	// ContainerID defines the slate package di service id base string.
	ContainerID = "slate"

	// EnvID defines the slate package environment variable base name.
	EnvID = "SLATE"
)
View Source
const (
	// ConfigContainerID defines the id to be used as the provider
	// registration id of a config instance, as a base id of all other config
	// related connections registered in the application di Provider.
	ConfigContainerID = ContainerID + ".config"

	// ConfigParserContainerID defines the base if to all config
	// supplier parser related services
	ConfigParserContainerID = ConfigContainerID + ".parser"

	// ConfigParserCreatorTag defines the tag to be assigned to all
	// Provider parser creators services.
	ConfigParserCreatorTag = ConfigParserContainerID + ".creator"

	// ConfigYAMLDecoderCreatorContainerID defines the id of a YAML
	// content config parser creator service.
	ConfigYAMLDecoderCreatorContainerID = ConfigParserCreatorTag + ".yaml"

	// ConfigJSONDecoderCreatorContainerID defines the id of a JSON
	//	// content config parser creator service.
	ConfigJSONDecoderCreatorContainerID = ConfigParserCreatorTag + ".json"

	// ConfigAllParserCreatorsContainerID defines the id for an aggregation
	// of all registered services that are tagged with the config parser tag.
	ConfigAllParserCreatorsContainerID = ConfigParserCreatorTag + ".all"

	// ConfigParserFactoryContainerID defines the id to be used as the
	// Provider registration id of a config parser factory service.
	ConfigParserFactoryContainerID = ConfigParserContainerID + ".factory"

	// ConfigSupplierContainerID defines the base if to all config supplier
	// related services.
	ConfigSupplierContainerID = ConfigContainerID + ".supplier"

	// ConfigAggregateSupplierTag defines the tag to all config
	// suppliers registered in the container that should be injected in
	// the aggregate instance.
	ConfigAggregateSupplierTag = ConfigSupplierContainerID + ".aggregate"

	// ConfigAllAggregateSuppliersContainerID defines the id of the
	// list of config suppliers to be given to the config aggregation
	// supplier service.
	ConfigAllAggregateSuppliersContainerID = ConfigAggregateSupplierTag + ".all"

	// ConfigSupplierCreatorTag defines the tag to be assigned to all
	// Provider supplier creator services.
	ConfigSupplierCreatorTag = ConfigSupplierContainerID + ".creator"

	// ConfigAggregateSourceCreatorContainerID defines the id of a config
	// supplier service that retrieves the config data from an aggregation
	// of other suppliers.
	ConfigAggregateSourceCreatorContainerID = ConfigSupplierCreatorTag + ".aggregate"

	// ConfigEnvSourceCreatorContainerID defines the id of a config
	// supplier service that retrieves the config data from the environment
	// variables.
	ConfigEnvSourceCreatorContainerID = ConfigSupplierCreatorTag + ".env"

	// ConfigFileSourceCreatorContainerID defines the id of a config
	// supplier service that retrieves the config data from a file.
	ConfigFileSourceCreatorContainerID = ConfigSupplierCreatorTag + ".file"

	// ConfigObsFileSourceCreatorContainerID defines the id of a config
	// supplier service that retrieves the config data from a file that will
	// be periodically observed for changes.
	ConfigObsFileSourceCreatorContainerID = ConfigSupplierCreatorTag + ".obs-file"

	// ConfigDirSourceCreatorContainerID defines the id of a config
	// supplier service that retrieves the config data from a list of files
	// present in a directory (optionally recursive).
	ConfigDirSourceCreatorContainerID = ConfigSupplierCreatorTag + ".dir"

	// ConfigRestSourceCreatorContainerID defines the id of a config
	// supplier service that retrieves the config data from a REST
	// web service.
	ConfigRestSourceCreatorContainerID = ConfigSupplierCreatorTag + ".rest"

	// ConfigObsRestSourceCreatorContainerID defines the id of a config
	// supplier service that retrieves the config data from a REST
	// web service that will be periodically observed for changes.
	ConfigObsRestSourceCreatorContainerID = ConfigSupplierCreatorTag + ".obs-rest"

	// ConfigAllSupplierCreatorsContainerID defines the id for an aggregation
	// of all registered services that are tagged with the config supplier tag.
	ConfigAllSupplierCreatorsContainerID = ConfigSupplierCreatorTag + ".all"

	// ConfigSupplierFactoryContainerID defines the id to be used as the
	// Provider registration id config supplier factory service.
	ConfigSupplierFactoryContainerID = ConfigSupplierContainerID + ".factory"

	// ConfigLoaderContainerID defines the id to be used as the provider
	// registration id of the config loader service.
	ConfigLoaderContainerID = ConfigContainerID + ".loader"

	// ConfigEnvID defines the base environment variable name for all
	// config related environment variables.
	ConfigEnvID = EnvID + "_CONFIG"

	// ConfigFormatJSON defines the value to be used to declare
	// a JSON config supplier encoding format.
	ConfigFormatJSON = "json"

	// ConfigFormatYAML defines the value to be used to declare
	// a YAML config supplier encoding format.
	ConfigFormatYAML = "yaml"

	// ConfigTypeAggregate defines the value to be used to declare a
	// configs supplier type that provides config data from other suppliers.
	ConfigTypeAggregate = "aggregate"

	// ConfigTypeEnv defines the value to be used to
	// declare an environment config supplier type.
	ConfigTypeEnv = "env"

	// ConfigTypeFile defines the value to be used to declare a
	// file config supplier type.
	ConfigTypeFile = "file"

	// ConfigTypeObsFile defines the value to be used to
	// declare an observable file config supplier type.
	ConfigTypeObsFile = "observable-file"

	// ConfigTypeDir defines the value to be used to declare a
	// dir config supplier type.
	ConfigTypeDir = "dir"

	// ConfigTypeRest defines the value to be used to declare a
	// REST config supplier type.
	ConfigTypeRest = "rest"

	// ConfigTypeObsRest defines the value to be used to
	// declare an observable REST config supplier type.
	ConfigTypeObsRest = "observable-rest"
)
View Source
const (
	// LogContainerID defines the id to be used as the Provider
	// registration id of a logger instance, as a base id of all other logger
	// package connections registered in the application Provider.
	LogContainerID = ContainerID + ".log"

	// LogFormatterContainerID defines the base if to all log formatter
	// related services
	LogFormatterContainerID = LogContainerID + ".formatter"

	// LogFormatterCreatorTag defines the tag to be assigned to all
	// Provider formatter creators.
	LogFormatterCreatorTag = LogFormatterContainerID + ".creator"

	// LogJSONEncoderCreatorContainerID defines the Provider id to be used
	// to identifies an output formatter that encodes the logging message into
	// an JSON content.
	LogJSONEncoderCreatorContainerID = LogFormatterCreatorTag + ".json"

	// LogAllFormatterCreatorsContainerID defines the id to be used as the
	// Provider registration id of an aggregate formatter creators
	// retrieval function.
	LogAllFormatterCreatorsContainerID = LogFormatterCreatorTag + ".all"

	// LogFormatterFactoryContainerID defines the id to be used as the
	// Provider registration id of a logger formatter factory instance.
	LogFormatterFactoryContainerID = LogFormatterContainerID + ".factory"

	// LogWriterContainerID defines the base if to all log writers
	// related services
	LogWriterContainerID = LogContainerID + ".writer"

	// LogWriterCreatorTag defines the tag to be assigned to all
	// Provider writer creators.
	LogWriterCreatorTag = LogWriterContainerID + ".creator"

	// LogConsoleStreamCreatorContainerID defines the Provider id to be used
	// to identifies an output writer that sends the logging messages to the
	// standard console.
	LogConsoleStreamCreatorContainerID = LogWriterCreatorTag + ".console"

	// LogFileStreamCreatorContainerID defines the Provider id to be used
	// to identifies an output writer that sends the logging messages to a
	// specific file.
	LogFileStreamCreatorContainerID = LogWriterCreatorTag + ".file"

	// LogRotatingFileStreamCreatorContainerID defines the Provider id to be
	// used to identifies an output writer that sends the logging messages to
	// a specific date related rotating file.
	LogRotatingFileStreamCreatorContainerID = LogWriterCreatorTag + ".rotating-file"

	// LogAllWriterCreatorsContainerID defines the id to be used as the
	// Provider registration id of an aggregate writer creators
	// retrieval function.
	LogAllWriterCreatorsContainerID = LogWriterCreatorTag + ".all"

	// LogWriterFactoryContainerID defines the id to be used as the Provider
	// registration id of a logger writer factory instance.
	LogWriterFactoryContainerID = LogWriterContainerID + ".factory"

	// LogLoaderContainerID defines the id to be used as the Provider
	// registration id of a logger loader instance.
	LogLoaderContainerID = LogContainerID + ".loader"

	// LogEnvID defines the base environment variable name for all
	// log related environment variables.
	LogEnvID = EnvID + "_LOG"

	// LogFormatJSON defines the value to be used to declare a
	// JSON log formatter format.
	LogFormatJSON = "json"

	// LogTypeConsole defines the value to be used to declare a
	// console log writer type.
	LogTypeConsole = "console"

	// LogTypeFile defines the value to be used to declare a
	// file log writer type.
	LogTypeFile = "file"

	// LogTypeRotatingFile defines the value to be used to declare a
	// file log writer type that rotates regarding the current date.
	LogTypeRotatingFile = "rotating-file"
)
View Source
const (
	// MigratorContainerID defines the id to be used as the Provider
	// registration id of a migrator instance, and as a base id of all
	// other migration module services registered in the application
	// Provider.
	MigratorContainerID = ContainerID + ".migrator"

	// MigratorDAOContainerID defines the id to be used as the Provider
	// registration id of the migrator DAO.
	MigratorDAOContainerID = MigratorContainerID + ".dao"

	// MigratorMigrationTag defines the tag to be used
	// to identify a migration entry in the Provider.
	MigratorMigrationTag = MigratorContainerID + ".migration"

	// MigratorAllMigrationsContainerID defines the id to be used to
	// retrieve the list of all migrations from the application Provider.
	MigratorAllMigrationsContainerID = MigratorMigrationTag + ".all"

	// MigratorEnvID defines the migrator module base environment variable name.
	MigratorEnvID = EnvID + "_MIGRATION"
)
View Source
const (
	// RdbContainerID defines the id to be used as the Provider
	// registration id of a relational database connection pool instance,
	// and as a base id of all other relational database package connections
	// registered in the application Provider.
	RdbContainerID = ContainerID + ".rdb"

	// RdbConfigContainerID defines the id to be used as the Provider
	// registration id of the relational database connection configuration
	// instance.
	RdbConfigContainerID = RdbContainerID + ".config"

	// RdbDialectContainerID defines the base if to all rdb dialect
	// related services
	RdbDialectContainerID = RdbContainerID + ".dialect"

	// RdbDialectCreatorTag defines the tag to be assigned to all
	// Provider relational database dialect creators.
	RdbDialectCreatorTag = RdbDialectContainerID + ".creator"

	// RdbAllDialectCreatorsContainerID defines the id to be used as the
	// Provider registration id of an aggregate dialect creators list.
	RdbAllDialectCreatorsContainerID = RdbDialectCreatorTag + ".all"

	// RdbDialectFactoryContainerID defines the id to be used as the
	// Provider registration id of the relational database connection
	// dialect factory service.
	RdbDialectFactoryContainerID = RdbDialectContainerID + ".factory"

	// RdbConnectionContainerID defines the base if to all rdb connection
	// related services
	RdbConnectionContainerID = RdbContainerID + ".connection"

	// RdbConnectionFactoryContainerID defines the id to be used as the
	// Provider registration id of the connection factory service.
	RdbConnectionFactoryContainerID = RdbConnectionContainerID + ".factory"

	// RdbPrimaryConnectionContainerID defines the id to be used as the
	// Provider registration id of the primary relational database service.
	RdbPrimaryConnectionContainerID = RdbConnectionContainerID + ".primary"

	// RdbEnvID defines the base environment variable name for all
	// relational database related environment variables.
	RdbEnvID = EnvID + "_RDB"
)
View Source
const (
	// WatchdogContainerID defines the id to be used as the Provider
	// registration id of a watchdog creator instance, and as a
	// base id of all other watchdog package connections registered
	// in the application Provider.
	WatchdogContainerID = ContainerID + ".watchdog"

	// WatchdogLogFormatterContainerID defines the simple tag to be used
	// to identify a watchdog log formatter entry in the Provider.
	WatchdogLogFormatterContainerID = WatchdogContainerID + ".formatter"

	// WatchdogLogFormatterCreatorTag defines the simple tag to be used
	// to identify a watchdog log formatter entry in the Provider.
	WatchdogLogFormatterCreatorTag = WatchdogLogFormatterContainerID + ".creator"

	// WatchdogDefaultLogFormatterCreatorContainerID defines the simple tag to be used
	// to identify a watchdog log formatter entry in the Provider.
	WatchdogDefaultLogFormatterCreatorContainerID = WatchdogLogFormatterCreatorTag + ".default"

	// WatchdogAllLogFormatterCreatorsContainerID defines the simple tag to be used
	// to identify a watchdog log formatter entry in the Provider.
	WatchdogAllLogFormatterCreatorsContainerID = WatchdogLogFormatterCreatorTag + ".all"

	// WatchdogLogFormatterFactoryContainerID defines the id to be used as the Provider
	// registration id of the log formatter creator.
	WatchdogLogFormatterFactoryContainerID = WatchdogLogFormatterContainerID + ".factory"

	// WatchdogFactoryContainerID defines the id to be used as the Provider
	// registration id of the watchdog creator.
	WatchdogFactoryContainerID = WatchdogContainerID + ".factory"

	// WatchdogProcessTag defines the simple tag to be used
	// to identify a watchdog process entry in the Provider.
	WatchdogProcessTag = WatchdogContainerID + ".process"

	// WatchdogAllProcessesContainerID defines the simple tag to be used
	// to identify a watchdog log formatter entry in the Provider.
	WatchdogAllProcessesContainerID = WatchdogProcessTag + ".all"

	// WatchdogEnvID defines the watchdog package base environment variable name.
	WatchdogEnvID = EnvID + "_WATCHDOG"

	// WatchdogLogFormatterTypeDefault defines the default log formatter type id
	WatchdogLogFormatterTypeDefault = "default"
)
View Source
const (
	// FileSystemContainerID defines the application service Provider
	// registration string of the file system adapter service.
	FileSystemContainerID = ContainerID + ".file_system"
)

Variables

View Source
var (
	// ErrServiceContainer defines a di error.
	ErrServiceContainer = NewError("service di error")

	// ErrNonFunctionServiceFactory defines a service di registration error
	// that signals that the registration request was made with a
	// non-function service factory.
	ErrNonFunctionServiceFactory = NewError("non-function service factory")

	// ErrServiceFactoryWithoutResult defines a service di registration error
	// that signals that the registration request was made with a
	// function service factory that don't return a service.
	ErrServiceFactoryWithoutResult = NewError("service factory without result")

	// ErrServiceNotFound defines a service not found on the di.
	ErrServiceNotFound = NewError("service not found")
)
View Source
var (
	// ConfigDefaultFileFormat defines the file config supplier
	// format if the format is not present in the config.
	ConfigDefaultFileFormat = EnvString(ConfigEnvID+"_DEFAULT_FILE_FORMAT", "yaml")

	// ConfigDefaultRestFormat defines the rest config supplier
	// format if the format is not present in the config.
	ConfigDefaultRestFormat = EnvString(ConfigEnvID+"_DEFAULT_REST_FORMAT", "json")

	// ConfigPathSeparator defines the element(s) that will be used to split
	// a config path string into path elements.
	ConfigPathSeparator = EnvString(ConfigEnvID+"_PATH_SEPARATOR", ".")

	// ConfigLoaderActive defines if the config loader should be executed
	// while the provider boot
	ConfigLoaderActive = EnvBool(ConfigEnvID+"_LOADER_ACTIVE", true)

	// ConfigLoaderFileSupplierPath defines the loader config supplier path.
	ConfigLoaderFileSupplierPath = EnvString(ConfigEnvID+"_LOADER_FILE_SUPPLIER_PATH", "config/suppliers.yaml")

	// ConfigLoaderSupplierID defines the id to be used as the
	// entry config supplier id when loading the configurations.
	ConfigLoaderSupplierID = EnvString(ConfigEnvID+"_LOADER_SUPPLIER_ID", "_suppliers")

	// ConfigLoaderSupplierFormat defines the loader config supplier format.
	ConfigLoaderSupplierFormat = EnvString(ConfigEnvID+"_LOADER_SUPPLIER_FORMAT", "yaml")

	// ConfigLoaderSupplierListPath defines the loader config supplier
	// content path to be searched.
	ConfigLoaderSupplierListPath = EnvString(ConfigEnvID+"_LOADER_SUPPLIER_LIST_PATH", "slate.config.suppliers")

	// ConfigObserveFrequency defines the config observable suppliers
	// frequency time in milliseconds. Zero for no check.
	ConfigObserveFrequency = EnvInt(ConfigEnvID+"_OBSERVE_FREQUENCY", 0)
)
View Source
var (
	// ErrInvalidEmptyConfigPath defines an invalid empty path in config
	// partial assigning action.
	ErrInvalidEmptyConfigPath = fmt.Errorf("invalid empty config path")

	// ErrConfigPathNotFound defines an error that signals that a path
	// was not found when requesting a value from a partial or config.
	ErrConfigPathNotFound = fmt.Errorf("config path not found")

	// ErrInvalidConfigFormat defines an error that signals an
	// unexpected/unknown config supplier format.
	ErrInvalidConfigFormat = fmt.Errorf("invalid config format")

	// ErrInvalidConfigSupplier defines an error that signals an
	// unexpected/unknown config supplier type.
	ErrInvalidConfigSupplier = fmt.Errorf("invalid config supplier")

	// ErrConfigSupplierNotFound defines a supplier config supplier
	// not found error.
	ErrConfigSupplierNotFound = fmt.Errorf("config supplier not found")

	// ErrDuplicateConfigSupplier defines a duplicate config supplier
	// registration attempt.
	ErrDuplicateConfigSupplier = fmt.Errorf("config supplier already registered")
)
View Source
var (
	// ErrNilPointer defines a nil pointer argument error.
	ErrNilPointer = NewError("invalid nil pointer")

	// ErrConversion defines a type conversion error.
	ErrConversion = NewError("invalid type conversion")
)
View Source
var (
	// LogFlushFrequency defines the log auto flushing action
	// frequency time in milliseconds.
	LogFlushFrequency = EnvInt(LogEnvID+"_FLUSH_FREQUENCY", 0)

	// LogLoaderActive defines the entry config source active flag
	// used to signal the config loader to load the writers or not
	LogLoaderActive = EnvBool(LogEnvID+"_LOADER_ACTIVE", true)

	// LogLoaderConfigPath defines the entry config source path
	// to be used as the loader entry.
	LogLoaderConfigPath = EnvString(LogEnvID+"_LOADER_CONFIG_PATH", "slate.log.writers")

	// LogLoaderObserveConfig defines the loader config observing flag
	// used to register in the config object an observer of the logger
	// config entries list, so it can reload the Log writers.
	LogLoaderObserveConfig = EnvBool(LogEnvID+"_LOADER_OBSERVE_CONFIG", true)
)
View Source
var (
	// ErrInvalidLogFormat defines an error that signal an invalid
	// logger format.
	ErrInvalidLogFormat = fmt.Errorf("invalid log format")

	// ErrInvalidLogLevel defines an error that signal an invalid
	// logger level.
	ErrInvalidLogLevel = fmt.Errorf("invalid log level")

	// ErrInvalidLogConfig defines an error that signal that the
	// given logger writer config was unable to be parsed correctly
	// enabling the logger writer generation.
	ErrInvalidLogConfig = fmt.Errorf("invalid log writer config")

	// ErrLogWriterNotFound defines an error that signal that the
	// given writer was not found in the logger manager.
	ErrLogWriterNotFound = fmt.Errorf("log writer not found")

	// ErrDuplicateLogWriter defines an error that signal that the
	// requested logger writer to be registered have an id of an already
	// registered logger writer.
	ErrDuplicateLogWriter = fmt.Errorf("log writer already registered")
)
View Source
var (
	// MigratorDatabase defines the migration manager rdb connection name.
	MigratorDatabase = EnvString(MigratorEnvID+"_DATABASE", "primary")

	// MigratorAutoMigrate defines the flag that will be used to enable
	// the auto migration on application boot.
	MigratorAutoMigrate = EnvBool(MigratorEnvID+"_AUTO_MIGRATE", true)
)
View Source
var (
	// RdbPrimary contains the name given to the primary connection.
	RdbPrimary = EnvString(RdbEnvID+"_PRIMARY", "primary")

	// RdbConnectionsConfigPath contains the configuration path that holds the
	// relational database connection configurations.
	RdbConnectionsConfigPath = EnvString(RdbEnvID+"_CONNECTIONS_CONFIG_PATH", "slate.rdb.connections")

	// RdbObserveConfig defines the connection factory config observing flag
	// used to register in the config manager as an observer of the connection
	// config entries list, so it can reset the connections pool as reconfigure
	// the connections.
	RdbObserveConfig = EnvBool(RdbEnvID+"_OBSERVE_CONFIG", true)
)
View Source
var (
	// WatchdogConfigPathPrefix defines the configuration path of the watchdog
	// entries of the application.
	WatchdogConfigPathPrefix = EnvString(WatchdogEnvID+"_CONFIG_PATH", "slate.watchdog.services")

	// WatchdogDefaultFormatter defines the default logging formatter instance id.
	WatchdogDefaultFormatter = EnvString(WatchdogEnvID+"_DEFAULT_FORMATTER", WatchdogLogFormatterTypeDefault)

	// WatchdogLogChannel defines the logging signal channel of the watchdogs.
	WatchdogLogChannel = EnvString(WatchdogEnvID+"_LOG_CHANNEL", "watchdog")

	// WatchdogLogStartLevel defines the watchdog starting logging signal
	// message level.
	WatchdogLogStartLevel = EnvString(WatchdogEnvID+"_LOG_START_LEVEL", "notice")

	// WatchdogLogStartMessage defines the watchdog starting logging signal message.
	WatchdogLogStartMessage = EnvString(WatchdogEnvID+"_LOG_START_MESSAGE", "[watchdog:%s] start execution")

	// WatchdogLogErrorLevel defines the watchdog error logging signal
	// message level.
	WatchdogLogErrorLevel = EnvString(WatchdogEnvID+"_LOG_ERROR_LEVEL", "error")

	// WatchdogLogErrorMessage defines the watchdog error logging signal message.
	WatchdogLogErrorMessage = EnvString(WatchdogEnvID+"_LOG_ERROR_MESSAGE", "[watchdog:%s] execution error (%v)")

	// WatchdogLogDoneLevel defines the watchdog termination logging
	// signal message level.
	WatchdogLogDoneLevel = EnvString(WatchdogEnvID+"_LOG_DONE_LEVEL", "notice")

	// WatchdogLogDoneMessage defines the watchdog termination logging
	// signal message.
	WatchdogLogDoneMessage = EnvString(WatchdogEnvID+"_LOG_DONE_MESSAGE", "[watchdog:%s] execution terminated")
)
View Source
var (
	// ErrInvalidWatchdogLogWriter defines an error that signal that the
	// given watchdog configuration has defined an unrecognizable log
	// writer type.
	ErrInvalidWatchdogLogWriter = fmt.Errorf("invalid watchdog log writer")

	// ErrDuplicateWatchdog defines an error that signal that the
	// given watchdog service is already registered.
	ErrDuplicateWatchdog = fmt.Errorf("duplicate watchdog")
)
View Source
var (
	// ErrUnknownRdbDialect defines an error that signal that the
	// requested database connection configured dialect is unknown.
	ErrUnknownRdbDialect = fmt.Errorf("unknown database dialect")
)
View Source
var LogLevelMap = map[string]LogLevel{
	"fatal":   FATAL,
	"error":   ERROR,
	"warning": WARNING,
	"notice":  NOTICE,
	"info":    INFO,
	"debug":   DEBUG,
}

LogLevelMap defines a relation between a human-readable string and a code level identifier of a logging level.

View Source
var LogLevelMapName = map[LogLevel]string{
	FATAL:   "fatal",
	ERROR:   "error",
	WARNING: "warning",
	NOTICE:  "notice",
	INFO:    "info",
	DEBUG:   "debug",
}

LogLevelMapName defines a relation between a code level identifier of a logging level and human-readable string representation of that level.

Functions

func ConfigConvert added in v0.30.0

func ConfigConvert(
	val interface{},
) interface{}

ConfigConvert will convert the given value to a config partial normalized value. This means that the map based values will be cast as a config partial instance and for any other ones (scalar or lists), will be processed accordingly. The conversion is recursive, at all levels.

func EnvBool added in v0.30.0

func EnvBool(
	name string,
	def ...bool,
) bool

EnvBool will try to retrieve a boolean value from the environment variable.

func EnvInt added in v0.30.0

func EnvInt(
	name string,
	def ...int,
) int

EnvInt will try to retrieve an integer value from the environment variable.

func EnvList added in v0.30.0

func EnvList(
	name string,
	def ...[]string,
) []string

EnvList will try to retrieve a list of strings values from the environment variable.

func EnvString added in v0.30.0

func EnvString(
	name string,
	def ...string,
) string

EnvString will try to retrieve a string value from the environment variable.

func NewError added in v0.20.0

func NewError(
	msg string,
	ctx ...map[string]interface{},
) error

NewError will instantiate a new error instance

func NewErrorFrom added in v0.20.0

func NewErrorFrom(
	err error,
	msg string,
	ctx ...map[string]interface{},
) error

NewErrorFrom create a new contextualized error instance from an existing error

func NewLogRotatingFileWriter added in v0.30.0

func NewLogRotatingFileWriter(
	fileSystem afero.Fs,
	file string,
) (io.Writer, error)

NewLogRotatingFileWriter generate a new rotating file writer instance.

Types

type App added in v0.30.0

type App struct {
	ServiceContainer
	// contains filtered or unexported fields
}

App defines the structure that controls the application di and di initialization.

func NewApp added in v0.30.0

func NewApp() *App

NewApp used to instantiate a new application.

func (*App) Boot added in v0.30.0

func (a *App) Boot() error

Boot initializes the application if not initialized yet. The initialization of an application is made by calling of the Provide method on all providers, after the registration of all services in the di, the boot method of all providers will be executed.

func (*App) Provide added in v0.30.0

func (a *App) Provide(
	provider ServiceProvider,
) error

Provide will register a new provider into the application and by doing so, allow to the provider register his services in the application service Provider. At boot will also call the provider boot method so that the provider services and also be initialized.

type Config added in v0.30.0

type Config struct {
	// contains filtered or unexported fields
}

Config defines an object responsible to handle several config suppliers and enable config content observers by path.

func NewConfig added in v0.30.0

func NewConfig() *Config

NewConfig instantiate a new configuration object. This object will handle a series of suppliers, alongside with the ability of registration of config path/values observer callbacks that will be called whenever the value has changed.

func (*Config) AddObserver added in v0.30.0

func (c *Config) AddObserver(
	path string,
	callback ConfigObserver,
) error

AddObserver register a new observer to a configuration path.

func (*Config) AddSupplier added in v0.30.0

func (c *Config) AddSupplier(
	id string,
	priority int,
	supplier ConfigSupplier,
) error

AddSupplier register a new supplier with a specific id with a given priority.

func (*Config) Bool added in v0.30.0

func (c *Config) Bool(
	path string,
	def ...bool,
) (bool, error)

Bool will retrieve a bool configuration value loaded from a supplier.

func (*Config) Close added in v0.30.0

func (c *Config) Close() error

Close terminates the config instance. This will stop the observer trigger and call close on all registered suppliers.

func (*Config) Entries added in v0.30.0

func (c *Config) Entries() []string

Entries will retrieve the list of stored config entries.

func (*Config) Float added in v0.30.0

func (c *Config) Float(
	path string,
	def ...float64,
) (float64, error)

Float will retrieve a floating point configuration value loaded from a supplier.

func (*Config) Get added in v0.30.0

func (c *Config) Get(
	path string,
	def ...interface{},
) (interface{}, error)

Get will retrieve a configuration value loaded from a supplier.

func (*Config) Has added in v0.30.0

func (c *Config) Has(
	path string,
) bool

Has will check if a path has been loaded. This means that if the values has been loaded by any registered supplier.

func (*Config) HasObserver added in v0.30.0

func (c *Config) HasObserver(
	path string,
) bool

HasObserver check if there is an observer to a configuration value path.

func (*Config) HasSupplier added in v0.30.0

func (c *Config) HasSupplier(
	id string,
) bool

HasSupplier check if a supplier with a specific id has been registered.

func (*Config) Int added in v0.30.0

func (c *Config) Int(
	path string,
	def ...int,
) (int, error)

Int will retrieve an integer configuration value loaded from a supplier.

func (*Config) List added in v0.30.0

func (c *Config) List(
	path string,
	def ...[]interface{},
) ([]interface{}, error)

List will retrieve a list configuration value loaded from a supplier.

func (*Config) Partial added in v0.30.0

func (c *Config) Partial(
	path string,
	def ...ConfigPartial,
) (ConfigPartial, error)

Partial will retrieve partial values loaded from a supplier.

func (*Config) Populate added in v0.30.0

func (c *Config) Populate(
	path string,
	data interface{},
	insensitive ...bool,
) (interface{}, error)

Populate will try to populate a given value from a stored configuration path.

func (*Config) RemoveAllSuppliers added in v0.30.0

func (c *Config) RemoveAllSuppliers() error

RemoveAllSuppliers remove all the registered suppliers from the registration list of the configuration. This will also update the configuration content and re-validate the observed paths.

func (*Config) RemoveObserver added in v0.30.0

func (c *Config) RemoveObserver(
	path string,
)

RemoveObserver remove an observer to a configuration path.

func (*Config) RemoveSupplier added in v0.30.0

func (c *Config) RemoveSupplier(
	id string,
) error

RemoveSupplier remove a supplier from the registration list of the configuration. This will also update the configuration content and re-validate the observed paths.

func (*Config) String added in v0.30.0

func (c *Config) String(
	path string,
	def ...string,
) (string, error)

String will retrieve a string configuration value loaded from a supplier.

func (*Config) Supplier added in v0.30.0

func (c *Config) Supplier(
	id string,
) (ConfigSupplier, error)

Supplier retrieve a previously registered supplier with a requested id.

func (*Config) SupplierPriority added in v0.30.0

func (c *Config) SupplierPriority(
	id string,
	priority int,
) error

SupplierPriority set a priority value of a previously registered supplier with the specified id. This may change the defined values if there was an override process of the configuration paths of the changing supplier.

type ConfigAggregateSource added in v0.30.0

type ConfigAggregateSource struct {
	ConfigSource
	// contains filtered or unexported fields
}

ConfigAggregateSource defines a config supplier that aggregates a list of config suppliers into a single aggregate provided supplier.

func NewConfigAggregateSource added in v0.30.0

func NewConfigAggregateSource(
	suppliers []ConfigSupplier,
) (*ConfigAggregateSource, error)

NewConfigAggregateSource will instantiate a new config supplier that aggregate a list of suppliers connections.

type ConfigAggregateSourceCreator added in v0.30.0

type ConfigAggregateSourceCreator struct {
	// contains filtered or unexported fields
}

ConfigAggregateSourceCreator defines a creator used to instantiate a config aggregation config supplier.

func NewConfigAggregateSourceCreator added in v0.30.0

func NewConfigAggregateSourceCreator(
	suppliers []ConfigSupplier,
) (*ConfigAggregateSourceCreator, error)

NewConfigAggregateSourceCreator instantiate the desired aggregation config creator instance.

func (ConfigAggregateSourceCreator) Accept added in v0.30.0

func (s ConfigAggregateSourceCreator) Accept(
	config *ConfigPartial,
) bool

Accept will check if the requested supplier can be instantiated by this creator by parsing the given config partial.

func (ConfigAggregateSourceCreator) Create added in v0.30.0

Create will instantiate the desired aggregation supplier instance with the creator stored list of suppliers.

type ConfigDecoder added in v0.30.0

type ConfigDecoder struct {
	Reader            io.Reader
	UnderlyingDecoder ConfigUnderlyingDecoder
}

ConfigDecoder defines the base structure to a config content decoder instance.

func NewConfigDecoder added in v0.30.0

func NewConfigDecoder(
	reader io.Reader,
	decoder ConfigUnderlyingDecoder,
) *ConfigDecoder

NewConfigDecoder will instantiate a new base config decoder instance.

func (*ConfigDecoder) Close added in v0.30.0

func (d *ConfigDecoder) Close() error

Close terminate the decoder, closing the associated underlying decoder.

func (*ConfigDecoder) Parse added in v0.30.0

func (d *ConfigDecoder) Parse() (*ConfigPartial, error)

Parse the associated configuration supplier encoded content into a configuration partial instance.

type ConfigDirSource added in v0.30.0

type ConfigDirSource struct {
	ConfigSource
	// contains filtered or unexported fields
}

ConfigDirSource defines a config supplier that read all directory files, recursive or not, and parse each one and store all the read content as a config.

func NewConfigDirSource added in v0.30.0

func NewConfigDirSource(
	path,
	format string,
	recursive bool,
	fileSystem afero.Fs,
	parserFactory *ConfigParserFactory,
) (*ConfigDirSource, error)

NewConfigDirSource will instantiate a new configuration supplier that will read a directory files for configuration information.

type ConfigDirSourceCreator added in v0.30.0

type ConfigDirSourceCreator struct {
	// contains filtered or unexported fields
}

ConfigDirSourceCreator defines a supplier creator used to instantiate a dir config supplier.

func NewConfigDirSourceCreator added in v0.30.0

func NewConfigDirSourceCreator(
	fileSystem afero.Fs,
	parserFactory *ConfigParserFactory,
) (*ConfigDirSourceCreator, error)

NewConfigDirSourceCreator instantiates a new dir config supplier creator.

func (ConfigDirSourceCreator) Accept added in v0.30.0

func (s ConfigDirSourceCreator) Accept(
	config *ConfigPartial,
) bool

Accept will check if the requested supplier can be instantiated by this creator by parsing the given config partial.

func (ConfigDirSourceCreator) Create added in v0.30.0

func (s ConfigDirSourceCreator) Create(
	config *ConfigPartial,
) (ConfigSupplier, error)

Create will instantiate the desired dir supplier instance.

type ConfigEnvSource added in v0.30.0

type ConfigEnvSource struct {
	ConfigSource
	// contains filtered or unexported fields
}

ConfigEnvSource defines a config supplier that maps environment variables values to a config.

func NewConfigEnvSource added in v0.30.0

func NewConfigEnvSource(
	mappings map[string]string,
) (*ConfigEnvSource, error)

NewConfigEnvSource will instantiate a new configuration supplier that will map environmental variables to configuration path values.

type ConfigEnvSourceCreator added in v0.30.0

type ConfigEnvSourceCreator struct{}

ConfigEnvSourceCreator defines a supplier creator used to instantiate an environment variable mapped config supplier.

func NewConfigEnvSourceCreator added in v0.30.0

func NewConfigEnvSourceCreator() *ConfigEnvSourceCreator

NewConfigEnvSourceCreator instantiates a new environment config supplier creator.

func (ConfigEnvSourceCreator) Accept added in v0.30.0

func (s ConfigEnvSourceCreator) Accept(
	config *ConfigPartial,
) bool

Accept will check if the requested supplier can be instantiated by this creator by parsing the given config partial.

func (ConfigEnvSourceCreator) Create added in v0.30.0

func (s ConfigEnvSourceCreator) Create(
	config *ConfigPartial,
) (ConfigSupplier, error)

Create will instantiate the desired environment variable mapper supplier instance with the passed mappings.

type ConfigFileSource added in v0.30.0

type ConfigFileSource struct {
	ConfigSource
	// contains filtered or unexported fields
}

ConfigFileSource defines a config supplier that obtains the config content from a system file.

func NewConfigFileSource added in v0.30.0

func NewConfigFileSource(
	path,
	format string,
	fileSystem afero.Fs,
	parserFactory *ConfigParserFactory,
) (*ConfigFileSource, error)

NewConfigFileSource will instantiate a new configuration supplier that will read a file for its configuration info.

type ConfigFileSourceCreator added in v0.30.0

type ConfigFileSourceCreator struct {
	// contains filtered or unexported fields
}

ConfigFileSourceCreator defines a config supplier creator used to instantiate a file config supplier.

func NewConfigFileSourceCreator added in v0.30.0

func NewConfigFileSourceCreator(
	fileSystem afero.Fs,
	parserFactory *ConfigParserFactory,
) (*ConfigFileSourceCreator, error)

NewConfigFileSourceCreator instantiates a new file config supplier creator.

func (ConfigFileSourceCreator) Accept added in v0.30.0

func (s ConfigFileSourceCreator) Accept(
	config *ConfigPartial,
) bool

Accept will check if the requested supplier can be instantiated by this creator by parsing the given config partial.

func (ConfigFileSourceCreator) Create added in v0.30.0

Create will instantiate the desired file supplier instance.

type ConfigJSONDecoder added in v0.30.0

type ConfigJSONDecoder struct {
	ConfigDecoder
}

ConfigJSONDecoder defines a config supplier JSON content decoder instance.

func NewConfigJSONDecoder added in v0.30.0

func NewConfigJSONDecoder(
	reader io.Reader,
) (*ConfigJSONDecoder, error)

NewConfigJSONDecoder will instantiate a new JSON config content decoder.

type ConfigJSONDecoderCreator added in v0.30.0

type ConfigJSONDecoderCreator struct{}

ConfigJSONDecoderCreator defines a config JSON decoder instantiation creator

func NewConfigJSONDecoderCreator added in v0.30.0

func NewConfigJSONDecoderCreator() *ConfigJSONDecoderCreator

NewConfigJSONDecoderCreator will instantiate a new JSON format config decoder creator

func (ConfigJSONDecoderCreator) Accept added in v0.30.0

func (ConfigJSONDecoderCreator) Accept(
	format string,
) bool

Accept will check if the requested format is accepted by the created parser.

func (ConfigJSONDecoderCreator) Create added in v0.30.0

func (ConfigJSONDecoderCreator) Create(
	args ...interface{},
) (ConfigParser, error)

Create will instantiate the desired decoder instance with the given JSON underlying decoder instance that will decode the supplier content.

type ConfigLoader added in v0.30.0

type ConfigLoader struct {
	// contains filtered or unexported fields
}

ConfigLoader defines an object responsible to initialize a configuration manager.

func NewConfigLoader added in v0.30.0

func NewConfigLoader(
	config *Config,
	supplierFactory *ConfigSupplierFactory,
) (*ConfigLoader, error)

NewConfigLoader instantiate a new configuration loader instance.

func (ConfigLoader) Load added in v0.30.0

func (l ConfigLoader) Load() error

Load loads the configuration from a well-defined file.

type ConfigObsFileSource added in v0.30.0

type ConfigObsFileSource struct {
	ConfigFileSource
	// contains filtered or unexported fields
}

ConfigObsFileSource defines a config supplier that read a file content and stores its config contents to be used as a config. The supplier will also be checked for changes recurrently, so it can update the stored configuration information.

func NewConfigObsFileSource added in v0.30.0

func NewConfigObsFileSource(
	path,
	format string,
	fileSystem afero.Fs,
	parserFactory *ConfigParserFactory,
) (*ConfigObsFileSource, error)

NewConfigObsFileSource will instantiate a new configuration supplier that will read a file for configuration info, opening the possibility for on-the-fly update on supplier content change.

func (*ConfigObsFileSource) Reload added in v0.30.0

func (s *ConfigObsFileSource) Reload() (bool, error)

Reload will check if the supplier has been updated, and, if so, reload the supplier config content.

type ConfigObsFileSourceCreator added in v0.30.0

type ConfigObsFileSourceCreator struct {
	ConfigFileSourceCreator
}

ConfigObsFileSourceCreator defines a supplier creator used to instantiate a new observable file supplier.

func NewConfigObsFileSourceCreator added in v0.30.0

func NewConfigObsFileSourceCreator(
	fileSystem afero.Fs,
	parserFactory *ConfigParserFactory,
) (*ConfigObsFileSourceCreator, error)

NewConfigObsFileSourceCreator instantiates a new observable file config supplier creator instance.

func (ConfigObsFileSourceCreator) Accept added in v0.30.0

func (s ConfigObsFileSourceCreator) Accept(
	config *ConfigPartial,
) bool

Accept will check if the requested supplier can be instantiated by this creator by parsing the given config partial.

func (ConfigObsFileSourceCreator) Create added in v0.30.0

Create will instantiate the desired observable file supplier instance.

type ConfigObsRestSource added in v0.30.0

type ConfigObsRestSource struct {
	ConfigRestSource
	// contains filtered or unexported fields
}

ConfigObsRestSource defines a config supplier that read a REST service and store a section of the response as the stored config. Also, the REST service will be periodically checked for updates.

func NewConfigObsRestSource added in v0.30.0

func NewConfigObsRestSource(
	client configRestRequester,
	uri,
	format string,
	parserFactory *ConfigParserFactory,
	timestampPath,
	configPath string,
) (*ConfigObsRestSource, error)

NewConfigObsRestSource will instantiate a new configuration supplier that will read a REST endpoint for configuration info, opening the possibility for on-the-fly update on supplier content change.

func (*ConfigObsRestSource) Reload added in v0.30.0

func (s *ConfigObsRestSource) Reload() (bool, error)

Reload will check if the supplier has been updated, and, if so, reload the supplier configuration content.

type ConfigObsRestSourceCreator added in v0.30.0

type ConfigObsRestSourceCreator struct {
	ConfigRestSourceCreator
}

ConfigObsRestSourceCreator defines a supplier creator used to instantiate an observable REST service config supplier.

func NewConfigObsRestSourceCreator added in v0.30.0

func NewConfigObsRestSourceCreator(
	parserFactory *ConfigParserFactory,
) (*ConfigObsRestSourceCreator, error)

NewConfigObsRestSourceCreator instantiates a new observable REST config supplier creator service.

func (ConfigObsRestSourceCreator) Accept added in v0.30.0

func (s ConfigObsRestSourceCreator) Accept(
	config *ConfigPartial,
) bool

Accept will check if the requested supplier can be instantiated by this creator by parsing the given config partial.

func (ConfigObsRestSourceCreator) Create added in v0.30.0

Create will instantiate the desired observable rest supplier instance.

type ConfigObsSupplier added in v0.30.0

type ConfigObsSupplier interface {
	ConfigSupplier
	Reload() (bool, error)
}

ConfigObsSupplier interface extends the ConfigSupplier interface with methods specific to suppliers that will be checked for updates in a regular periodicity defined in the config object where the supplier will be registered.

type ConfigObserver added in v0.30.0

type ConfigObserver func(old, new interface{})

ConfigObserver callback function used to be called when an observed configuration path has changed.

type ConfigParser added in v0.30.0

type ConfigParser interface {
	Parse() (*ConfigPartial, error)
}

ConfigParser interface defines the interaction methods of a content parser used to parse/convert the config supplier content into an application usable config partial instance.

type ConfigParserCreator added in v0.30.0

type ConfigParserCreator interface {
	Accept(format string) bool
	Create(args ...interface{}) (ConfigParser, error)
}

ConfigParserCreator interface defines the methods of the parser factory creator that can validate creation requests and instantiation of a particular requested parser, if enable to do so.

type ConfigParserFactory added in v0.30.0

type ConfigParserFactory []ConfigParserCreator

ConfigParserFactory defines a config parser instantiation factory object.

func NewConfigParserFactory added in v0.30.0

func NewConfigParserFactory(
	creators []ConfigParserCreator,
) *ConfigParserFactory

NewConfigParserFactory will instantiate a new parser factory instance.

func (*ConfigParserFactory) Create added in v0.30.0

func (f *ConfigParserFactory) Create(
	format string,
	args ...interface{},
) (ConfigParser, error)

Create will instantiate the requested new parser capable to parse the formatted content into a usable config partial.

type ConfigPartial added in v0.30.0

type ConfigPartial map[interface{}]interface{}

ConfigPartial defines a section of a configuration information

func (*ConfigPartial) Bool added in v0.30.0

func (p *ConfigPartial) Bool(
	path string,
	def ...bool,
) (bool, error)

Bool will retrieve a value stored in the quested path casting it has a boolean

func (*ConfigPartial) Clone added in v0.30.0

func (p *ConfigPartial) Clone() ConfigPartial

Clone will instantiate an identical instance of the original partial

func (*ConfigPartial) Entries added in v0.30.0

func (p *ConfigPartial) Entries() []string

Entries will retrieve the list of stored entries in the configuration partial.

func (*ConfigPartial) Float added in v0.30.0

func (p *ConfigPartial) Float(
	path string,
	def ...float64,
) (float64, error)

Float will retrieve a value stored in the quested path casting it has a float

func (*ConfigPartial) Get added in v0.30.0

func (p *ConfigPartial) Get(
	path string,
	def ...interface{},
) (interface{}, error)

Get will retrieve the value stored in the requested path. If the path does not exist, then the value nil will be returned. Or, if a simple value was given as the optional extra argument, then it will be returned instead of the standard nil value.

func (*ConfigPartial) Has added in v0.30.0

func (p *ConfigPartial) Has(
	path string,
) bool

Has will check if a requested path can be reached if request to the partial.

func (*ConfigPartial) Int added in v0.30.0

func (p *ConfigPartial) Int(
	path string,
	def ...int,
) (int, error)

Int will retrieve a value stored in the quested path casting it has an integer

func (*ConfigPartial) List added in v0.30.0

func (p *ConfigPartial) List(
	path string,
	def ...[]interface{},
) ([]interface{}, error)

List will retrieve a value stored in the quested path casting it has a list

func (*ConfigPartial) Merge added in v0.30.0

func (p *ConfigPartial) Merge(
	src ConfigPartial,
)

Merge will increment the current partial instance with the information stored in another partial.

func (*ConfigPartial) Partial added in v0.30.0

func (p *ConfigPartial) Partial(
	path string,
	def ...ConfigPartial,
) (ConfigPartial, error)

Partial will retrieve a value stored in the quested path casting it has a config partial

func (*ConfigPartial) Populate added in v0.30.0

func (p *ConfigPartial) Populate(
	path string,
	data interface{},
	insensitive ...bool,
) (interface{}, error)

Populate will try to populate the data argument with the data stored in the path partial location.

func (*ConfigPartial) Set added in v0.30.0

func (p *ConfigPartial) Set(
	path string,
	value interface{},
) (*ConfigPartial, error)

Set will store a value in the requested partial path.

func (*ConfigPartial) String added in v0.30.0

func (p *ConfigPartial) String(
	path string,
	def ...string,
) (string, error)

String will retrieve a value stored in the quested path casting it has a string

type ConfigRestSource added in v0.30.0

type ConfigRestSource struct {
	ConfigSource
	// contains filtered or unexported fields
}

ConfigRestSource defines a config supplier that read a REST service and store a section of the response as the stored config.

func NewConfigRestSource added in v0.30.0

func NewConfigRestSource(
	client configRestRequester,
	uri,
	format string,
	parserFactory *ConfigParserFactory,
	configPath string,
) (*ConfigRestSource, error)

NewConfigRestSource will instantiate a new configuration supplier that will read a REST endpoint for configuration info.

type ConfigRestSourceCreator added in v0.30.0

type ConfigRestSourceCreator struct {
	// contains filtered or unexported fields
}

ConfigRestSourceCreator defines a supplier creator used to instantiate a REST service config supplier.

func NewConfigRestSourceCreator added in v0.30.0

func NewConfigRestSourceCreator(
	parserFactory *ConfigParserFactory,
) (*ConfigRestSourceCreator, error)

NewConfigRestSourceCreator instantiates a new REST service config supplier creator.

func (ConfigRestSourceCreator) Accept added in v0.30.0

func (s ConfigRestSourceCreator) Accept(
	config *ConfigPartial,
) bool

Accept will check if the requested supplier can be instantiated by this creator by parsing the given config partial.

func (ConfigRestSourceCreator) Create added in v0.30.0

Create will instantiate the desired rest supplier instance.

type ConfigServiceRegister added in v0.30.0

type ConfigServiceRegister struct {
	ServiceRegister
}

ConfigServiceRegister defines the service provider to be used by the application to register the config services.

func NewConfigServiceRegister added in v0.30.0

func NewConfigServiceRegister(
	app ...*App,
) *ConfigServiceRegister

NewConfigServiceRegister will generate a new config related services registry instance

func (ConfigServiceRegister) Boot added in v0.30.0

func (sr ConfigServiceRegister) Boot(
	container *ServiceContainer,
) (e error)

Boot will start the config services by calling the config loader initialization method.

func (ConfigServiceRegister) Provide added in v0.30.0

func (sr ConfigServiceRegister) Provide(
	container *ServiceContainer,
) error

Provide will register the configuration module services in the application Provider.

type ConfigSource added in v0.30.0

type ConfigSource struct {
	Mutex   sync.Locker
	Partial ConfigPartial
}

ConfigSource defines a base config source structure used to implement the basics of a config source instance.

func NewConfigSource added in v0.30.0

func NewConfigSource() *ConfigSource

NewConfigSource will instantiate a new config supplier base structure.

func (*ConfigSource) Get added in v0.30.0

func (s *ConfigSource) Get(
	path string,
	def ...interface{},
) (interface{}, error)

Get will retrieve the value stored in the requested path present in the configuration content. If the path does not exist, then the value nil will be returned, or if a default value is given, that will be the resulting value. This method will mostly be used by the config object to obtain the full content of the supplier to aggregate all the data into his internal storing config instance.

func (*ConfigSource) Has added in v0.30.0

func (s *ConfigSource) Has(
	path string,
) bool

Has will check if the requested path is present in the supplier configuration content.

type ConfigSupplier added in v0.30.0

type ConfigSupplier interface {
	Has(path string) bool
	Get(path string, def ...interface{}) (interface{}, error)
}

ConfigSupplier defines the interface of a config partial supplier.

type ConfigSupplierCreator added in v0.30.0

type ConfigSupplierCreator interface {
	Accept(config *ConfigPartial) bool
	Create(config *ConfigPartial) (ConfigSupplier, error)
}

ConfigSupplierCreator interface defines the methods of the supplier factory creator that will be used to instantiate a particular supplier responsible to handle a type of source.

type ConfigSupplierFactory added in v0.30.0

type ConfigSupplierFactory []ConfigSupplierCreator

ConfigSupplierFactory defines an object responsible to instantiate a new config supplier.

func NewConfigSupplierFactory added in v0.30.0

func NewConfigSupplierFactory(
	creators []ConfigSupplierCreator,
) *ConfigSupplierFactory

NewConfigSupplierFactory will instantiate a new config supplier factory instance.

func (*ConfigSupplierFactory) Create added in v0.30.0

func (f *ConfigSupplierFactory) Create(
	config *ConfigPartial,
) (ConfigSupplier, error)

Create will instantiate and return a new config supplier based on the given configuration data.

type ConfigUnderlyingDecoder added in v0.30.0

type ConfigUnderlyingDecoder interface {
	Decode(config interface{}) error
}

ConfigUnderlyingDecoder defines the interface to a content parser underlying decoder instance.

type ConfigYAMLDecoder added in v0.30.0

type ConfigYAMLDecoder struct {
	ConfigDecoder
}

ConfigYAMLDecoder defines a config supplier YAML content decoder instance.

func NewConfigYAMLDecoder added in v0.30.0

func NewConfigYAMLDecoder(
	reader io.Reader,
) (*ConfigYAMLDecoder, error)

NewConfigYAMLDecoder will instantiate a new YAML config content decoder.

func (ConfigYAMLDecoder) Parse added in v0.30.0

func (d ConfigYAMLDecoder) Parse() (*ConfigPartial, error)

Parse the associated config supplier encoded content into a config partial instance.

type ConfigYAMLDecoderCreator added in v0.30.0

type ConfigYAMLDecoderCreator struct{}

ConfigYAMLDecoderCreator defines a YAML config decoder instantiation creator

func NewConfigYAMLDecoderCreator added in v0.30.0

func NewConfigYAMLDecoderCreator() *ConfigYAMLDecoderCreator

NewConfigYAMLDecoderCreator will instantiate a new YAML format config decoder creator

func (ConfigYAMLDecoderCreator) Accept added in v0.30.0

func (ConfigYAMLDecoderCreator) Accept(
	format string,
) bool

Accept will check if the requested format is accepted by the created parser.

func (ConfigYAMLDecoderCreator) Create added in v0.30.0

func (ConfigYAMLDecoderCreator) Create(
	args ...interface{},
) (ConfigParser, error)

Create will instantiate the desired decoder instance with the given YAML underlying decoder instance that will decode the supplier content.

type Error added in v0.20.0

type Error struct {
	// contains filtered or unexported fields
}

Error defines a contextualized error

func (*Error) Context added in v0.20.0

func (e *Error) Context() map[string]interface{}

Context will retrieve the error context information

func (*Error) Error added in v0.20.0

func (e *Error) Error() string

Error retrieve the error information from the error instance

func (*Error) Unwrap added in v0.20.0

func (e *Error) Unwrap() error

Unwrap will try to unwrap the error information

type FileSystemServiceRegister added in v0.30.0

type FileSystemServiceRegister struct {
	ServiceRegister
}

FileSystemServiceRegister defines the module service provider to be used on the application initialization to register the file system adapter service.

func NewFileSystemServiceRegister added in v0.30.0

func NewFileSystemServiceRegister(
	app ...*App,
) *FileSystemServiceRegister

NewFileSystemServiceRegister will generate a new file system register instance

func (FileSystemServiceRegister) Provide added in v0.30.0

func (FileSystemServiceRegister) Provide(
	container *ServiceContainer,
) error

Provide will add to the application Provider the module services.

type Log added in v0.30.0

type Log struct {
	// contains filtered or unexported fields
}

Log defines a new logging manager used to centralize the logging messaging propagation to a list of registered output writers.

func NewLog added in v0.30.0

func NewLog() *Log

NewLog instantiate a new logging manager service.

func (*Log) AddWriter added in v0.30.0

func (l *Log) AddWriter(
	id string,
	writer LogWriter,
) error

AddWriter registers a new writer into the Log instance.

func (*Log) Broadcast added in v0.30.0

func (l *Log) Broadcast(
	level LogLevel,
	msg string,
	ctx ...LogContext,
) error

Broadcast will propagate the logging request to all stored logging writers.

func (*Log) Close added in v0.30.0

func (l *Log) Close() error

Close will terminate all the logging writers associated to the Log.

func (*Log) Flush added in v0.30.0

func (l *Log) Flush() error

Flush will try to flush all the writers from their buffered content

func (*Log) HasWriter added in v0.30.0

func (l *Log) HasWriter(
	id string,
) bool

HasWriter check if a writer is registered with the requested id.

func (*Log) ListWriters added in v0.30.0

func (l *Log) ListWriters() []string

ListWriters retrieve a list of id's of all registered writers on the log manager.

func (*Log) RemoveAllWriters added in v0.30.0

func (l *Log) RemoveAllWriters()

RemoveAllWriters will remove all registered writers from the logging manager.

func (*Log) RemoveWriter added in v0.30.0

func (l *Log) RemoveWriter(
	id string,
)

RemoveWriter will remove a registered writer with the requested id from the logging manager.

func (*Log) Signal added in v0.30.0

func (l *Log) Signal(
	channel string,
	level LogLevel,
	msg string,
	ctx ...LogContext,
) error

Signal will propagate the channel filtered logging request to all stored logging writers.

func (*Log) Writer added in v0.30.0

func (l *Log) Writer(
	id string,
) (LogWriter, error)

Writer retrieve a writer from the logging manager that is registered with the requested id.

type LogConsoleStream added in v0.30.0

type LogConsoleStream struct {
	LogStream
}

LogConsoleStream defines an instance to a console log output stream.

func NewLogConsoleStream added in v0.30.0

func NewLogConsoleStream(
	level LogLevel,
	formatter LogFormatter,
	channels []string,
) (*LogConsoleStream, error)

NewLogConsoleStream generate a new console log stream instance.

type LogConsoleStreamCreator added in v0.30.0

type LogConsoleStreamCreator struct {
	LogStreamCreator
}

LogConsoleStreamCreator defines a console log stream creator service.

func NewLogConsoleStreamCreator added in v0.30.0

func NewLogConsoleStreamCreator(
	formatterFactory *LogFormatterFactory,
) (*LogConsoleStreamCreator, error)

NewLogConsoleStreamCreator generates a new console log stream generation service.

func (LogConsoleStreamCreator) Accept added in v0.30.0

func (s LogConsoleStreamCreator) Accept(
	config *ConfigPartial,
) bool

Accept will check if the writer factory creator can instantiate a writer where the output will be sent to the console.

func (LogConsoleStreamCreator) Create added in v0.30.0

func (s LogConsoleStreamCreator) Create(
	config *ConfigPartial,
) (LogWriter, error)

Create will instantiate the desired stream instance where the writer output is the standard console stream.

type LogContext added in v0.30.0

type LogContext map[string]interface{}

LogContext defines a value map type used by the logging methods to give additional information to the logger entry

type LogFileStream added in v0.30.0

type LogFileStream struct {
	LogStream
}

LogFileStream defines an instance to a file log output stream.

func NewLogFileStream added in v0.30.0

func NewLogFileStream(
	level LogLevel,
	formatter LogFormatter,
	channels []string,
	writer io.Writer,
) (*LogFileStream, error)

NewLogFileStream generate a new file log stream instance.

func (*LogFileStream) Close added in v0.30.0

func (s *LogFileStream) Close() error

Close will terminate the stream stored writer instance.

type LogFileStreamCreator added in v0.30.0

type LogFileStreamCreator struct {
	LogStreamCreator
	// contains filtered or unexported fields
}

LogFileStreamCreator defines a file log stream creator service.

func NewLogFileStreamCreator added in v0.30.0

func NewLogFileStreamCreator(
	fileSystem afero.Fs,
	formatterFactory *LogFormatterFactory,
) (*LogFileStreamCreator, error)

NewLogFileStreamCreator generates a new file log stream generation service.

func (LogFileStreamCreator) Accept added in v0.30.0

func (s LogFileStreamCreator) Accept(
	config *ConfigPartial,
) bool

Accept will check if the stream factory creator can instantiate a stream where the writer will output to a file.

func (LogFileStreamCreator) Create added in v0.30.0

func (s LogFileStreamCreator) Create(
	config *ConfigPartial,
) (LogWriter, error)

Create will instantiate the desired stream instance where the output will be sent to a file.

type LogFormatter added in v0.30.0

type LogFormatter interface {
	Format(level LogLevel, message string, ctx ...LogContext) string
}

LogFormatter interface defines the methods of a logging formatter instance responsible to parse a logging request into the output string.

type LogFormatterCreator added in v0.30.0

type LogFormatterCreator interface {
	Accept(format string) bool
	Create(args ...interface{}) (LogFormatter, error)
}

LogFormatterCreator interface defines the methods of the formatter factory creator that can validate creation requests and instantiation of particular formatter.

type LogFormatterFactory added in v0.30.0

type LogFormatterFactory []LogFormatterCreator

LogFormatterFactory defines the log formatter factory structure used to instantiate log formatters, based on registered instance creators.

func NewLogFormatterFactory added in v0.30.0

func NewLogFormatterFactory(
	creators []LogFormatterCreator,
) *LogFormatterFactory

NewLogFormatterFactory will instantiate a new formatter factory instance

func (*LogFormatterFactory) Create added in v0.30.0

func (f *LogFormatterFactory) Create(
	format string,
	args ...interface{},
) (LogFormatter, error)

Create will instantiate and return a new content formatter.

type LogJSONEncoder added in v0.30.0

type LogJSONEncoder struct{}

LogJSONEncoder defines an instance used to format a log message into a JSON string.

func NewLogJSONEncoder added in v0.30.0

func NewLogJSONEncoder() *LogJSONEncoder

NewLogJSONEncoder will create a new JSON log message encoder.

func (LogJSONEncoder) Format added in v0.30.0

func (f LogJSONEncoder) Format(
	level LogLevel,
	message string,
	ctx ...LogContext,
) string

Format will create the output JSON string message formatted with the content of the passed level, message and context

type LogJSONEncoderCreator added in v0.30.0

type LogJSONEncoderCreator struct{}

LogJSONEncoderCreator defines a log message JSON formatter creator.

func NewLogJSONEncoderCreator added in v0.30.0

func NewLogJSONEncoderCreator() *LogJSONEncoderCreator

NewLogJSONEncoderCreator generates a new JSON formatter creator service.

func (LogJSONEncoderCreator) Accept added in v0.30.0

func (LogJSONEncoderCreator) Accept(
	format string,
) bool

Accept will check if the formatter factory creator can instantiate a formatter of the requested format.

func (LogJSONEncoderCreator) Create added in v0.30.0

func (LogJSONEncoderCreator) Create(
	_ ...interface{},
) (LogFormatter, error)

Create will instantiate the desired formatter instance.

type LogLevel added in v0.30.0

type LogLevel int

LogLevel identifies a value type that describes a logging level.

const (
	// FATAL defines a fatal logging level.
	FATAL LogLevel = 1 + iota
	// ERROR defines a error logging level.
	ERROR
	// WARNING defines a warning logging level.
	WARNING
	// NOTICE defines a notice logging level.
	NOTICE
	// INFO defines a info logging level.
	INFO
	// DEBUG defines a debug logging level.
	DEBUG
)

type LogLoader added in v0.30.0

type LogLoader struct {
	// contains filtered or unexported fields
}

LogLoader defines the logger instantiation and initialization of a new logging manager.

func NewLogLoader added in v0.30.0

func NewLogLoader(
	config *Config,
	log *Log,
	writerFactory *LogWriterFactory,
) (*LogLoader, error)

NewLogLoader generates a new logger initialization instance.

func (LogLoader) Load added in v0.30.0

func (l LogLoader) Load() error

Load will parse the configuration and instantiates logging writers depending the data on the configuration.

type LogRotatingFileStreamCreator added in v0.30.0

type LogRotatingFileStreamCreator struct {
	LogFileStreamCreator
}

LogRotatingFileStreamCreator define a new rotating file log stream creator.

func NewLogRotatingFileStreamCreator added in v0.30.0

func NewLogRotatingFileStreamCreator(
	fileSystem afero.Fs,
	formatterFactory *LogFormatterFactory,
) (*LogRotatingFileStreamCreator, error)

NewLogRotatingFileStreamCreator generate a new rotating file log stream creator.

func (LogRotatingFileStreamCreator) Accept added in v0.30.0

func (s LogRotatingFileStreamCreator) Accept(
	config *ConfigPartial,
) bool

Accept will check if the stream factory creator can instantiate a stream where the output will be to a rotating file.

func (LogRotatingFileStreamCreator) Create added in v0.30.0

Create will instantiate the desired stream instance where the output is a rotating file.

type LogRotatingFileWriter added in v0.30.0

type LogRotatingFileWriter struct {
	// contains filtered or unexported fields
}

LogRotatingFileWriter defines an output writer used by a file stream that will use a dated file for target output.

func (*LogRotatingFileWriter) Close added in v0.30.0

func (w *LogRotatingFileWriter) Close() error

Close satisfies the Closable interface.

func (*LogRotatingFileWriter) Write added in v0.30.0

func (w *LogRotatingFileWriter) Write(
	output []byte,
) (int, error)

Write satisfies the io.Writer interface.

type LogServiceRegister added in v0.30.0

type LogServiceRegister struct {
	ServiceRegister
}

LogServiceRegister defines a service provider to be used on the application initialization to register the logging service.

func NewLogServiceRegister added in v0.30.0

func NewLogServiceRegister(
	app ...*App,
) *LogServiceRegister

NewLogServiceRegister will generate a new logging services registry instance

func (LogServiceRegister) Boot added in v0.30.0

func (sr LogServiceRegister) Boot(
	container *ServiceContainer,
) (e error)

Boot will start the logging services by calling the log loader initialization method.

func (LogServiceRegister) Provide added in v0.30.0

func (sr LogServiceRegister) Provide(
	container *ServiceContainer,
) error

Provide will register the logging module services in the application Provider.

type LogStream added in v0.30.0

type LogStream struct {
	Channels  []string
	Level     LogLevel
	Formatter LogFormatter
	Mutex     sync.Locker
	Buffer    []string
	Writer    io.Writer
}

LogStream defines the base log stream instance used as starting point to all log stream/writers services.

func NewLogStream added in v0.30.0

func NewLogStream(
	level LogLevel,
	formatter LogFormatter,
	channels []string,
	writer io.Writer,
) *LogStream

NewLogStream will instantiate a new log stream instance

func (*LogStream) AddChannel added in v0.30.0

func (s *LogStream) AddChannel(
	channel string,
)

AddChannel register a channel to the list of channels that the stream is listening.

func (*LogStream) Broadcast added in v0.30.0

func (s *LogStream) Broadcast(
	level LogLevel,
	msg string,
	ctx ...LogContext,
) error

Broadcast will process the logging signal request and store the logging request into the underlying writer if passing the level filtering.

func (*LogStream) Close added in v0.30.0

func (s *LogStream) Close() error

Close will close the stream flushing all the stored messages.

func (*LogStream) Flush added in v0.30.0

func (s *LogStream) Flush() error

Flush will flush all buffered log entries to the stream writer

func (*LogStream) Format added in v0.30.0

func (s *LogStream) Format(
	level LogLevel,
	message string,
	ctx ...LogContext,
) string

Format will try to format a logging message.

func (*LogStream) HasChannel added in v0.30.0

func (s *LogStream) HasChannel(
	channel string,
) bool

HasChannel will validate if the stream is listening to a specific logging channel.

func (*LogStream) ListChannels added in v0.30.0

func (s *LogStream) ListChannels() []string

ListChannels retrieves the list of channels that the stream is listening.

func (*LogStream) RemoveChannel added in v0.30.0

func (s *LogStream) RemoveChannel(
	channel string,
)

RemoveChannel removes a channel from the list of channels that the stream is listening.

func (*LogStream) Signal added in v0.30.0

func (s *LogStream) Signal(
	channel string,
	level LogLevel,
	msg string,
	ctx ...LogContext,
) error

Signal will process the logging signal request and store the logging request into the underlying writer if passing the channel and level filtering.

type LogStreamCreator added in v0.30.0

type LogStreamCreator struct {
	// contains filtered or unexported fields
}

LogStreamCreator defines a base log stream creator service.

type LogWriter added in v0.30.0

type LogWriter interface {
	Signal(channel string, level LogLevel, message string, ctx ...LogContext) error
	Broadcast(level LogLevel, message string, ctx ...LogContext) error
	Flush() error

	HasChannel(channel string) bool
	ListChannels() []string
	AddChannel(channel string)
	RemoveChannel(channel string)
}

LogWriter interface defines the interaction methods with a logging writer responsible to output logging message to a defined output.

type LogWriterCreator added in v0.30.0

type LogWriterCreator interface {
	Accept(config *ConfigPartial) bool
	Create(config *ConfigPartial) (LogWriter, error)
}

LogWriterCreator interface defines the methods of the writer factory creator that can validate creation requests and instantiation of particular type of writer.

type LogWriterFactory added in v0.30.0

type LogWriterFactory []LogWriterCreator

LogWriterFactory is a logging writer generator based on a registered list of writer generation creators.

func NewLogWriterFactory added in v0.30.0

func NewLogWriterFactory(
	creators []LogWriterCreator,
) *LogWriterFactory

NewLogWriterFactory will instantiate a new writer factory instance

func (*LogWriterFactory) Create added in v0.30.0

func (f *LogWriterFactory) Create(
	config *ConfigPartial,
) (LogWriter, error)

Create will instantiate and return a new log writer instance based on the passed config.

type Migration added in v0.30.0

type Migration interface {
	Version() uint64
	Up() error
	Down() error
}

Migration defines an interface that all migrations must obey.

type Migrator added in v0.30.0

type Migrator struct {
	// contains filtered or unexported fields
}

Migrator defines a new migration manager instance.

func NewMigrator added in v0.30.0

func NewMigrator(
	dao *MigratorDao,
	migrations []Migration,
) (*Migrator, error)

NewMigrator will instantiate a new Migrator instance.

func (*Migrator) AddMigration added in v0.30.0

func (m *Migrator) AddMigration(
	migration Migration,
) error

AddMigration registers a migration into the migration manager.

func (*Migrator) Current added in v0.30.0

func (m *Migrator) Current() (uint64, error)

Current returns the version of the last executed migration.

func (*Migrator) Down added in v0.30.0

func (m *Migrator) Down() error

Down will try to revert the last migration executed.

func (*Migrator) Migrate added in v0.30.0

func (m *Migrator) Migrate() error

Migrate execute all migrations that are yet to be executed.

func (*Migrator) Up added in v0.30.0

func (m *Migrator) Up() error

Up will try to execute the next migration in queue to be executed.

type MigratorDao added in v0.30.0

type MigratorDao struct {
	// contains filtered or unexported fields
}

MigratorDao defines an migration record DAO instance responsible to manager the installed migrations.

func NewMigratorDao added in v0.30.0

func NewMigratorDao(
	conn *gorm.DB,
) (*MigratorDao, error)

NewMigratorDao will instantiate a new migration DAO instance.

func (MigratorDao) Down added in v0.30.0

func (d MigratorDao) Down(
	last MigratorRecord,
) error

Down will remove the last migration register

func (MigratorDao) Last added in v0.30.0

func (d MigratorDao) Last() (MigratorRecord, error)

Last will retrieve the last registered migration

func (MigratorDao) Up added in v0.30.0

func (d MigratorDao) Up(
	version uint64,
) (MigratorRecord, error)

Up will register a new executed migration

type MigratorRecord added in v0.30.0

type MigratorRecord struct {
	ID uint `json:"id" xml:"id" gorm:"primaryKey"`

	Version uint64 `json:"model" xml:"model"`

	CreatedAt time.Time  `json:"createdAt" xml:"createdAt"`
	UpdatedAt time.Time  `json:"updatedAt" xml:"updatedAt"`
	DeletedAt *time.Time `json:"deletedAt" xml:"deletedAt" sql:"index"`
}

MigratorRecord defines the rdb record that stores a migration.

func (MigratorRecord) TableName added in v0.30.0

func (MigratorRecord) TableName() string

TableName defines the table name to be used to manage the migrations.

type MigratorServiceRegister added in v0.30.0

type MigratorServiceRegister struct {
	ServiceRegister
}

MigratorServiceRegister defines the slate.migration module service provider to be used on the application initialization to register the migrations service.

func NewMigratorServiceRegister added in v0.30.0

func NewMigratorServiceRegister(
	app ...*App,
) *MigratorServiceRegister

NewMigratorServiceRegister will generate a new registry instance

func (MigratorServiceRegister) Boot added in v0.30.0

func (sr MigratorServiceRegister) Boot(
	container *ServiceContainer,
) (e error)

Boot will start the migration package If the auto migration is defined as true, ether by global variable or by environment variable, the migrator will automatically try to migrate to the last registered migration

func (MigratorServiceRegister) Provide added in v0.30.0

func (sr MigratorServiceRegister) Provide(
	container *ServiceContainer,
) error

Provide will register the migration package connections in the application Provider

type RdbConnectionFactory added in v0.30.0

type RdbConnectionFactory struct {
	// contains filtered or unexported fields
}

RdbConnectionFactory is a database connection generator.

func NewRdbConnectionFactory added in v0.30.0

func NewRdbConnectionFactory(
	dialectFactory *RdbDialectFactory,
) (*RdbConnectionFactory, error)

NewRdbConnectionFactory will instantiate a new relational database connection factory instance.

func (*RdbConnectionFactory) Create added in v0.30.0

func (f *RdbConnectionFactory) Create(
	config *ConfigPartial,
	gormConfig *gorm.Config,
) (*gorm.DB, error)

Create execute the process of the connection creation based on parameters given by the passed config partial.

type RdbConnectionPool added in v0.30.0

type RdbConnectionPool struct {
	// contains filtered or unexported fields
}

RdbConnectionPool is a database connection pool and generator.

func NewRdbConnectionPool added in v0.30.0

func NewRdbConnectionPool(
	config *Config,
	connectionFactory *RdbConnectionFactory,
) (*RdbConnectionPool, error)

NewRdbConnectionPool will instantiate a new relational database connection pool instance.

func (*RdbConnectionPool) Get added in v0.30.0

func (f *RdbConnectionPool) Get(
	name string,
	gormConfig *gorm.Config,
) (*gorm.DB, error)

Get execute the process of the connection creation based on the base configuration defined by the given name of the connection, and apply the extra connection config also given as arguments.

type RdbDialectCreator added in v0.30.0

type RdbDialectCreator interface {
	Accept(config *ConfigPartial) bool
	Create(config *ConfigPartial) (gorm.Dialector, error)
}

RdbDialectCreator defines the interface to a gorm rdb dialect instantiation strategy, based on a configuration.

type RdbDialectFactory added in v0.30.0

type RdbDialectFactory []RdbDialectCreator

RdbDialectFactory defines an object that will generate a database dialect interface based on a registered list of dialect creators.

func NewRdbDialectFactory added in v0.30.0

func NewRdbDialectFactory(
	creators []RdbDialectCreator,
) *RdbDialectFactory

NewRdbDialectFactory will instantiate a new relational database dialect factory service.

func (*RdbDialectFactory) Create added in v0.30.0

func (f *RdbDialectFactory) Create(
	config *ConfigPartial,
) (gorm.Dialector, error)

Create generates a new connection dialect interface defined by the configuration parameters stored in the configuration partial marked by the given name.

type RdbServiceRegister added in v0.30.0

type RdbServiceRegister struct {
	ServiceRegister
}

RdbServiceRegister defines the service provider to be used on the application initialization to register the relational database services.

func NewRdbServiceRegister added in v0.30.0

func NewRdbServiceRegister(
	app ...*App,
) *RdbServiceRegister

NewRdbServiceRegister will generate a new service registry instance

func (RdbServiceRegister) Provide added in v0.30.0

func (sr RdbServiceRegister) Provide(
	container *ServiceContainer,
) error

Provide will register the relational database module services in the application Provider.

type ServiceContainer

type ServiceContainer struct {
	// contains filtered or unexported fields
}

ServiceContainer defines the structure that hold the application service factories and initialized services.

func NewServiceContainer added in v0.30.0

func NewServiceContainer() *ServiceContainer

NewServiceContainer used to instantiate a new application service di.

func (*ServiceContainer) Add added in v0.30.0

func (c *ServiceContainer) Add(
	id string,
	factory interface{},
	tags ...string,
) error

Add will register a service factory used to create a service 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 service was registered previously with the requested id, then the service will be removed by calling the Remove method before the storing of the new service factory.

func (*ServiceContainer) Clear

func (c *ServiceContainer) Clear() error

Clear will eliminate all the registered services from the di.

func (*ServiceContainer) Close

func (c *ServiceContainer) Close() error

Close clean up the di 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 (*ServiceContainer) Get

func (c *ServiceContainer) Get(
	id string,
) (any, error)

Get will retrieve the requested service from the di. If the object has not yet been instantiated, then the factory method will be executed to instantiate it.

func (*ServiceContainer) Has

func (c *ServiceContainer) Has(
	id string,
) bool

Has will check if a service 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 (*ServiceContainer) Remove

func (c *ServiceContainer) Remove(
	id string,
) error

Remove will eliminate the service from the di. If the service has been already instantiated and implements the Closable interface, then the Close method will be called on the removing instance.

func (*ServiceContainer) Tag added in v0.30.0

func (c *ServiceContainer) Tag(
	tag string,
) ([]any, error)

Tag will retrieve the list of entries connections that where registered with the request teg.

type ServiceProvider

type ServiceProvider interface {
	Provide(container *ServiceContainer) error
	Boot(container *ServiceContainer) error
}

ServiceProvider defines the base application provider registry interface of an object used to register services in the application di.

type ServiceRegister added in v0.30.0

type ServiceRegister struct {
	App *App
}

ServiceRegister defines the base application provider registry object used to register services in the application di Provider

func NewServiceRegister added in v0.30.0

func NewServiceRegister(
	app ...*App,
) *ServiceRegister

NewServiceRegister will instantiate a new provider instance

func (ServiceRegister) Boot added in v0.30.0

func (ServiceRegister) Boot(
	container *ServiceContainer,
) error

Boot will execute the registry instance boot process

func (ServiceRegister) Provide added in v0.30.0

func (ServiceRegister) Provide(
	container *ServiceContainer,
) error

Provide method will register the services in the application di

type Trigger added in v0.30.0

type Trigger interface {
	io.Closer
	Delay() time.Duration
}

Trigger defines an interface of all the time related future execution services.

type TriggerCallback added in v0.30.0

type TriggerCallback func() error

TriggerCallback used as a trigger execution process.

type TriggerPulse added in v0.30.0

type TriggerPulse struct {
	// contains filtered or unexported fields
}

TriggerPulse defines an instance used to execute a callback function after a defined time.

func NewTriggerPulse added in v0.30.0

func NewTriggerPulse(
	delay time.Duration,
	callback TriggerCallback,
) (*TriggerPulse, error)

NewTriggerPulse instantiate a new pulse trigger that will execute a callback method after a determined amount of time.

func (*TriggerPulse) Close added in v0.30.0

func (t *TriggerPulse) Close() error

Close will stop the trigger and release all the associated resources.

func (TriggerPulse) Delay added in v0.30.0

func (t TriggerPulse) Delay() time.Duration

Delay will retrieve the time period associated to the trigger.

type TriggerRecurring added in v0.30.0

type TriggerRecurring struct {
	// contains filtered or unexported fields
}

TriggerRecurring defines an instance used to execute a callback function recurrently in a defined interval time.

func NewTriggerRecurring added in v0.30.0

func NewTriggerRecurring(
	delay time.Duration,
	callback TriggerCallback,
) (*TriggerRecurring, error)

NewTriggerRecurring instantiate a new trigger that will execute a callback method recurrently with a defined periodicity.

func (*TriggerRecurring) Close added in v0.30.0

func (t *TriggerRecurring) Close() error

Close will stop the trigger and release all the associated resources.

func (TriggerRecurring) Delay added in v0.30.0

func (t TriggerRecurring) Delay() time.Duration

Delay will retrieve the time period associated to the trigger.

type Watchdog added in v0.30.0

type Watchdog struct {
	// contains filtered or unexported fields
}

Watchdog defines the instance used to overlook a process execution.

func NewWatchdog added in v0.30.0

func NewWatchdog(
	logAdapter *WatchdogLogAdapter,
) (*Watchdog, error)

NewWatchdog generates a new watchdog instance.

func (*Watchdog) Run added in v0.30.0

func (w *Watchdog) Run(
	process WatchdogProcessor,
) (e error)

Run will run a process overlooked by the current watchdog instance.

type WatchdogDefaultLogFormatter added in v0.30.0

type WatchdogDefaultLogFormatter struct{}

WatchdogDefaultLogFormatter defines an instance to a watchdog logging message formatter.

func NewWatchdogDefaultLogFormatter added in v0.30.0

func NewWatchdogDefaultLogFormatter() *WatchdogDefaultLogFormatter

NewWatchdogDefaultLogFormatter will instantiate a new default watchdog logging message formatter

func (WatchdogDefaultLogFormatter) Done added in v0.30.0

func (WatchdogDefaultLogFormatter) Done(
	service string,
) string

Done format a watchdog termination signal message.

func (WatchdogDefaultLogFormatter) Error added in v0.30.0

func (WatchdogDefaultLogFormatter) Error(
	service string,
	e error,
) string

Error format a watchdog error signal message.

func (WatchdogDefaultLogFormatter) Start added in v0.30.0

func (WatchdogDefaultLogFormatter) Start(
	service string,
) string

Start format a watchdog starting signal message.

type WatchdogDefaultLogFormatterCreator added in v0.30.0

type WatchdogDefaultLogFormatterCreator struct{}

WatchdogDefaultLogFormatterCreator defines the default log formatter creator service.

func NewWatchdogDefaultLogFormatterCreator added in v0.30.0

func NewWatchdogDefaultLogFormatterCreator() *WatchdogDefaultLogFormatterCreator

NewWatchdogDefaultLogFormatterCreator will instantiate a new default logging formatter creator service.

func (WatchdogDefaultLogFormatterCreator) Accept added in v0.30.0

Accept will check if the creator is able to create the requested log formatter based on the given configuration.

func (WatchdogDefaultLogFormatterCreator) Create added in v0.30.0

Create will try to generate a log formatter based on the passed configuration.

type WatchdogFactory added in v0.30.0

type WatchdogFactory struct {
	// contains filtered or unexported fields
}

WatchdogFactory defines an instance of a watchdog creator, used to create watchdogs related to a configuration entry.

func NewWatchdogFactory added in v0.30.0

func NewWatchdogFactory(
	config *Config,
	logger *Log,
	logFormatterFactory *WatchdogLogFormatterFactory,
) (*WatchdogFactory, error)

NewWatchdogFactory will generate a new watchdog creator instance.

func (*WatchdogFactory) Create added in v0.30.0

func (f *WatchdogFactory) Create(
	service string,
) (*Watchdog, error)

Create will create a new watchdog instance for the required service with the name passed as argument.

type WatchdogKennel added in v0.30.0

type WatchdogKennel struct {
	// contains filtered or unexported fields
}

WatchdogKennel define an instance that will manage a group of watchdog connections, and is used to run them in parallel.

func NewWatchdogKennel added in v0.30.0

func NewWatchdogKennel(
	watchdogFactory *WatchdogFactory,
	processes []WatchdogProcessor,
) (*WatchdogKennel, error)

NewWatchdogKennel will generate a new kennel instance.

func (*WatchdogKennel) Run added in v0.30.0

func (k *WatchdogKennel) Run() error

Run will execute all the registered processes in their respective watchdogs.

type WatchdogLogAdapter added in v0.30.0

type WatchdogLogAdapter struct {
	// contains filtered or unexported fields
}

WatchdogLogAdapter define an instance a watchdog logging adapter.

func NewWatchdogLogAdapter added in v0.30.0

func NewWatchdogLogAdapter(
	name,
	channel string,
	startLevel,
	errorLevel,
	doneLevel LogLevel,
	logger *Log,
	formatter WatchdogLogFormatter,
) (*WatchdogLogAdapter, error)

NewWatchdogLogAdapter will create a new watchdog logging adapter.

func (*WatchdogLogAdapter) Done added in v0.30.0

func (a *WatchdogLogAdapter) Done() error

Done will format and redirect the termination logging message to the application logger.

func (*WatchdogLogAdapter) Error added in v0.30.0

func (a *WatchdogLogAdapter) Error(
	e error,
) error

Error will format and redirect the error logging message to the application logger.

func (*WatchdogLogAdapter) Start added in v0.30.0

func (a *WatchdogLogAdapter) Start() error

Start will format and redirect the start logging message to the application logger.

type WatchdogLogFormatter added in v0.30.0

type WatchdogLogFormatter interface {
	Start(service string) string
	Error(service string, e error) string
	Done(service string) string
}

WatchdogLogFormatter defines an interface to a watchdog logging message formatter.

type WatchdogLogFormatterCreator added in v0.30.0

type WatchdogLogFormatterCreator interface {
	Accept(config *ConfigPartial) bool
	Create(config *ConfigPartial) (WatchdogLogFormatter, error)
}

WatchdogLogFormatterCreator defines a watchdog logging message formatter creator service.

type WatchdogLogFormatterFactory added in v0.30.0

type WatchdogLogFormatterFactory []WatchdogLogFormatterCreator

WatchdogLogFormatterFactory defines an object responsible to instantiate a new watchdog log formatter.

func NewWatchdogLogFormatterFactory added in v0.30.0

func NewWatchdogLogFormatterFactory(
	creators []WatchdogLogFormatterCreator,
) *WatchdogLogFormatterFactory

NewWatchdogLogFormatterFactory will instantiate a new logging formatter creator instance.

func (*WatchdogLogFormatterFactory) Create added in v0.30.0

Create will instantiate and return a new watchdog log formatter defined by the requested configuration data.

type WatchdogProcess added in v0.30.0

type WatchdogProcess struct {
	// contains filtered or unexported fields
}

WatchdogProcess defines an instance to a watchdog process that will be overlooked by the watchdog.

func NewWatchdogProcess added in v0.30.0

func NewWatchdogProcess(
	service string,
	runner func() error,
) (*WatchdogProcess, error)

NewWatchdogProcess generate a new process instance with the given service name and runner method.

func (*WatchdogProcess) Runner added in v0.30.0

func (p *WatchdogProcess) Runner() func() error

Runner retrieve the process runner method.

func (*WatchdogProcess) Service added in v0.30.0

func (p *WatchdogProcess) Service() string

Service will retrieve the service name.

type WatchdogProcessor added in v0.30.0

type WatchdogProcessor interface {
	Service() string
	Runner() func() error
}

WatchdogProcessor defines an interface to a watchdog process.

type WatchdogServiceRegister added in v0.30.0

type WatchdogServiceRegister struct {
	ServiceRegister
}

WatchdogServiceRegister defines the service provider to be used on the application initialization to register the relational database services.

func NewWatchdogServiceRegister added in v0.30.0

func NewWatchdogServiceRegister(
	app ...*App,
) *WatchdogServiceRegister

NewWatchdogServiceRegister will generate a new service registry instance

func (WatchdogServiceRegister) Provide added in v0.30.0

func (sr WatchdogServiceRegister) Provide(
	container *ServiceContainer,
) error

Provide will register the relational database module services in the application Provider.

Directories

Path Synopsis
dig
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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL