Documentation ¶
Overview ¶
Package rkmysql is an implementation of rkentry.Entry which could be used gorm.DB instance.
Index ¶
- Constants
- func RegisterMySqlEntryYAML(raw []byte) map[string]rkentry.Entry
- type BootMySQL
- type BootMySQLE
- type Logger
- func (l *Logger) Error(ctx context.Context, msg string, data ...interface{})
- func (l *Logger) Info(ctx context.Context, msg string, data ...interface{})
- func (l *Logger) LogMode(level gormLogger.LogLevel) gormLogger.Interface
- func (l *Logger) Trace(ctx context.Context, begin time.Time, ...)
- func (l *Logger) Warn(ctx context.Context, msg string, data ...interface{})
- type MySqlEntry
- func (entry *MySqlEntry) Bootstrap(ctx context.Context)
- func (entry *MySqlEntry) GetDB(name string) *gorm.DB
- func (entry *MySqlEntry) GetDescription() string
- func (entry *MySqlEntry) GetName() string
- func (entry *MySqlEntry) GetType() string
- func (entry *MySqlEntry) Interrupt(ctx context.Context)
- func (entry *MySqlEntry) IsHealthy() bool
- func (entry *MySqlEntry) RegisterPromMetrics(registry *prometheus.Registry) error
- func (entry *MySqlEntry) String() string
- type Option
- func WithAddr(addr string) Option
- func WithDatabase(name string, dryRun, autoCreate bool, params ...string) Option
- func WithDescription(description string) Option
- func WithLogger(logger *Logger) Option
- func WithName(name string) Option
- func WithPass(pass string) Option
- func WithPlugin(name string, plugin gorm.Plugin) Option
- func WithProtocol(protocol string) Option
- func WithUser(user string) Option
Constants ¶
View Source
const MySqlEntryType = "MySqlEntry"
Variables ¶
This section is empty.
Functions ¶
func RegisterMySqlEntryYAML ¶ added in v1.0.0
RegisterMySqlEntryYAML register MySqlEntry based on config file into rkentry.GlobalAppCtx
Types ¶
type BootMySQL ¶ added in v1.0.0
type BootMySQL struct {
MySql []*BootMySQLE `yaml:"mysql" json:"mysql"`
}
BootMySQL MySql entry boot config which reflects to YAML config
type BootMySQLE ¶ added in v1.1.0
type BootMySQLE struct { Enabled bool `yaml:"enabled" json:"enabled"` Name string `yaml:"name" json:"name"` Description string `yaml:"description" json:"description"` Domain string `yaml:"domain" json:"domain"` User string `yaml:"user" json:"user"` Pass string `yaml:"pass" json:"pass"` Protocol string `yaml:"protocol" json:"protocol"` Addr string `yaml:"addr" json:"addr"` Database []struct { Name string `yaml:"name" json:"name"` Params []string `yaml:"params" json:"params"` DryRun bool `yaml:"dryRun" json:"dryRun"` AutoCreate bool `yaml:"autoCreate" json:"autoCreate"` Plugins struct { Prom plugins.PromConfig `yaml:"prom"` } `yaml:"plugins" json:"plugins"` } `yaml:"database" json:"database"` Logger struct { Entry string `json:"entry" yaml:"entry"` Level string `json:"level" yaml:"level"` Encoding string `json:"encoding" yaml:"encoding"` OutputPaths []string `json:"outputPaths" yaml:"outputPaths"` SlowThresholdMs int `json:"slowThresholdMs" yaml:"slowThresholdMs"` IgnoreRecordNotFoundError bool `json:"ignoreRecordNotFoundError" yaml:"ignoreRecordNotFoundError"` } `json:"logger" yaml:"logger"` }
type Logger ¶ added in v0.0.2
type Logger struct { SlowThreshold time.Duration IgnoreRecordNotFoundError bool LogLevel gormLogger.LogLevel // contains filtered or unexported fields }
func (*Logger) LogMode ¶ added in v1.2.5
func (l *Logger) LogMode(level gormLogger.LogLevel) gormLogger.Interface
type MySqlEntry ¶
type MySqlEntry struct { User string `yaml:"user" json:"user"` Protocol string `yaml:"protocol" json:"protocol"` Addr string `yaml:"addr" json:"addr"` GormDbMap map[string]*gorm.DB `yaml:"-" json:"-"` GormConfigMap map[string]*gorm.Config `yaml:"-" json:"-"` // contains filtered or unexported fields }
MySqlEntry will init gorm.DB or SqlMock with provided arguments
func GetMySqlEntry ¶
func GetMySqlEntry(name string) *MySqlEntry
GetMySqlEntry returns MySqlEntry instance
func RegisterMySqlEntry ¶
func RegisterMySqlEntry(opts ...Option) *MySqlEntry
RegisterMySqlEntry will register Entry into GlobalAppCtx
func (*MySqlEntry) Bootstrap ¶
func (entry *MySqlEntry) Bootstrap(ctx context.Context)
Bootstrap MySqlEntry
func (*MySqlEntry) GetDescription ¶
func (entry *MySqlEntry) GetDescription() string
GetDescription returns entry description
func (*MySqlEntry) Interrupt ¶
func (entry *MySqlEntry) Interrupt(ctx context.Context)
Interrupt MySqlEntry
func (*MySqlEntry) IsHealthy ¶
func (entry *MySqlEntry) IsHealthy() bool
IsHealthy checks healthy status remote provider
func (*MySqlEntry) RegisterPromMetrics ¶ added in v1.2.7
func (entry *MySqlEntry) RegisterPromMetrics(registry *prometheus.Registry) error
func (*MySqlEntry) String ¶
func (entry *MySqlEntry) String() string
String returns json marshalled string
type Option ¶
type Option func(*MySqlEntry)
Option for MySqlEntry
func WithDatabase ¶
WithDatabase provide database
func WithDescription ¶
WithDescription provide name.
Click to show internal directories.
Click to hide internal directories.