Documentation
ΒΆ
Index ΒΆ
Constants ΒΆ
View Source
const ( DsnFieldName = "db.mysql.dsn" ConnectionErrorLimitFieldName = "db.mysql.connection.error.limit" ConnectionErrorTimeoutFieldName = "db.mysql.connection.error.timeout" ConnectionErrorLimitDefault = uint32(10) ConnectionErrorTimeoutDefault = 10 * time.Second )
View Source
const MySQL driver.Driver = "mysql"
MySQL is the driver identifier for MySQL database. It is used across all Compogo database components (client, migrator, generator).
Variables ΒΆ
View Source
var Component = &component.Component{ Init: component.StepFunc(func(container container.Container) error { return container.Provides( NewConfig, NewMySQL, ) }), BindFlags: component.BindFlags(func(flagSet flag.FlagSet, container container.Container) error { return container.Invoke(func(config *Config) { flagSet.StringVar(&config.DSN, DsnFieldName, "", "mysql dsn string connection") flagSet.Uint32Var(&config.ErrorLimit, ConnectionErrorLimitFieldName, ConnectionErrorLimitDefault, "") flagSet.DurationVar(&config.ErrorTimeout, ConnectionErrorTimeoutFieldName, ConnectionErrorTimeoutDefault, "") }) }), Configuration: component.StepFunc(func(container container.Container) error { return container.Invoke(Configuration) }), }
Component is a ready-to-use Compogo component that provides a MySQL client. It automatically:
- Registers Config and NewMySQL in the DI container
- Adds command-line flags for MySQL configuration
- Applies configuration during Configuration phase
Usage:
compogo.WithComponents(
db_client.Component,
mysql.Component,
// ... other components
)
The MySQL client can be injected into any component:
type UserService struct {
db mysql.Client
}
Functions ΒΆ
This section is empty.
Types ΒΆ
type Client ΒΆ
Client is an alias for client.Client to provide a cleaner API. Users can work with mysql.Client without importing the internal client package.
type Config ΒΆ
func Configuration ΒΆ
func Configuration(config *Config, configurator configurator.Configurator) *Config
Click to show internal directories.
Click to hide internal directories.