Documentation ¶
Index ¶
- Constants
- Variables
- func IsRecordNotFound(err error) bool
- type Config
- type DataBase
- type Page
- type ReConfiguration
- func (reConfiguration *ReConfiguration) Close() error
- func (reConfiguration *ReConfiguration) DataBase() DataBase
- func (reConfiguration *ReConfiguration) DriverName() string
- func (reConfiguration *ReConfiguration) Exec(s string, i ...interface{}) (sql.Result, error)
- func (reConfiguration *ReConfiguration) ExecContext(ctx context.Context, s string, i ...interface{}) (sql.Result, error)
- func (reConfiguration *ReConfiguration) Query(s string, i ...interface{}) (*sql.Rows, error)
- func (reConfiguration *ReConfiguration) QueryContext(ctx context.Context, s string, i ...interface{}) (*sql.Rows, error)
- func (reConfiguration *ReConfiguration) QueryRow(s string, i ...interface{}) *sql.Row
- func (reConfiguration *ReConfiguration) QueryRowContext(ctx context.Context, s string, i ...interface{}) *sql.Row
- func (reConfiguration *ReConfiguration) ReConfiguration(c configurator.Configurator) error
- func (reConfiguration *ReConfiguration) SQL() *sql.DB
- type RecordNotFound
- type SortDirection
Constants ¶
View Source
const ( DriverFieldName = "db.driver" DriverDefault = driver.MySQL )
Variables ¶
View Source
var Component = &app.Component{ Dependencies: app.Components{ logger.Component, configurator.Component, mysql.Component, sqlite.Component, info.Component, }, Constructor: func(container container.Container) error { return container.Provides( NewConfig, NewReConfigurationWithConfigurator, func(reConfiguration *ReConfiguration) DataBase { return reConfiguration }, ) }, BindFlags: func(flagSet *pflag.FlagSet, container container.Container) error { return container.Invoke(func(config *Config) { flagSet.StringVar(&config.Driver, DriverFieldName, DriverDefault, fmt.Sprintf( "database connection driver. Available drivers [%s]", strings.Join([]string{driver.MySQL, driver.SQLite}, ","), )) }) }, Serve: func(c container.Container) error { dataBase, err := container.Get[*ReConfiguration](c) if err != nil { return err } reConfiguration, err := container.Get[configurator.ReConfiguration](c) if err != nil { return err } informer, err := container.Get[logger.Informer](c) if err != nil { return err } reConfiguration.Registration(dataBase) informer.Info("data_base: registration in the reConfigurator") info, err := container.Get[info.Info](c) if err != nil { return err } config, err := container.Get[*Config](c) if err != nil { return err } info.Registration("data_base", config) closer, err := container.Get[closer.Closer](c) if err != nil { return err } ctx, cancelFunc := context.WithCancel(closer.GetContext()) defer cancelFunc() <-ctx.Done() return dataBase.Close() }, }
Functions ¶
func IsRecordNotFound ¶
Types ¶
type Config ¶
type Config struct {
Driver string
}
func Configuration ¶
func Configuration(config *Config, configurator configurator.Configurator) *Config
type DataBase ¶
type DataBase interface { io.Closer Query(string, ...interface{}) (*sql.Rows, error) QueryRow(string, ...interface{}) *sql.Row Exec(string, ...interface{}) (sql.Result, error) QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error) QueryRowContext(context.Context, string, ...interface{}) *sql.Row ExecContext(context.Context, string, ...interface{}) (sql.Result, error) SQL() *sql.DB DriverName() string }
type Page ¶
type Page struct { Number uint32 Limit uint8 ColumnNameToSort string SortDirection SortDirection }
type ReConfiguration ¶
type ReConfiguration struct {
// contains filtered or unexported fields
}
func NewReConfiguration ¶
func NewReConfigurationWithConfigurator ¶
func NewReConfigurationWithConfigurator(informer logger.Informer, container container.Container, config *Config, configurator configurator.Configurator) (*ReConfiguration, error)
func (*ReConfiguration) Close ¶
func (reConfiguration *ReConfiguration) Close() error
func (*ReConfiguration) DataBase ¶
func (reConfiguration *ReConfiguration) DataBase() DataBase
func (*ReConfiguration) DriverName ¶
func (reConfiguration *ReConfiguration) DriverName() string
func (*ReConfiguration) Exec ¶
func (reConfiguration *ReConfiguration) Exec(s string, i ...interface{}) (sql.Result, error)
func (*ReConfiguration) ExecContext ¶
func (*ReConfiguration) Query ¶
func (reConfiguration *ReConfiguration) Query(s string, i ...interface{}) (*sql.Rows, error)
func (*ReConfiguration) QueryContext ¶
func (*ReConfiguration) QueryRow ¶
func (reConfiguration *ReConfiguration) QueryRow(s string, i ...interface{}) *sql.Row
func (*ReConfiguration) QueryRowContext ¶
func (*ReConfiguration) ReConfiguration ¶
func (reConfiguration *ReConfiguration) ReConfiguration(c configurator.Configurator) error
func (*ReConfiguration) SQL ¶
func (reConfiguration *ReConfiguration) SQL() *sql.DB
type RecordNotFound ¶
type RecordNotFound struct {
// contains filtered or unexported fields
}
func NewRecordNotFound ¶
func NewRecordNotFound(error string) *RecordNotFound
func (*RecordNotFound) Error ¶
func (recordNotFound *RecordNotFound) Error() string
type SortDirection ¶
type SortDirection uint
const ( ASC SortDirection = iota DESC )
func (SortDirection) String ¶
func (i SortDirection) String() string
Source Files ¶
Click to show internal directories.
Click to hide internal directories.