Documentation ¶
Overview ¶
Package rksqlserver is an implementation of rkentry.Entry which could be used gorm.DB instance.
Index ¶
- Constants
- func RegisterSqlServerEntryYAML(raw []byte) map[string]rkentry.Entry
- type BootSqlServer
- type BootSqlServerE
- 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 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 WithUser(user string) Option
- type SqlServerEntry
- func (entry *SqlServerEntry) Bootstrap(ctx context.Context)
- func (entry *SqlServerEntry) GetDB(name string) *gorm.DB
- func (entry *SqlServerEntry) GetDescription() string
- func (entry *SqlServerEntry) GetName() string
- func (entry *SqlServerEntry) GetType() string
- func (entry *SqlServerEntry) Interrupt(ctx context.Context)
- func (entry *SqlServerEntry) IsHealthy() bool
- func (entry *SqlServerEntry) RegisterPromMetrics(registry *prometheus.Registry) error
- func (entry *SqlServerEntry) String() string
Constants ¶
const (
SqlServerEntryType = "SqlServerEntry"
)
Variables ¶
This section is empty.
Functions ¶
func RegisterSqlServerEntryYAML ¶ added in v1.0.0
RegisterSqlServerEntryYAML register SqlServerEntry based on config file into rkentry.GlobalAppCtx
Types ¶
type BootSqlServer ¶ added in v1.0.0
type BootSqlServer struct {
SqlServer []*BootSqlServerE `yaml:"sqlserver" json:"sqlserver"`
}
BootSqlServer entry boot config which reflects to YAML config
type BootSqlServerE ¶ added in v1.1.0
type BootSqlServerE 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"` 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 ¶
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 Option ¶
type Option func(*SqlServerEntry)
func WithDatabase ¶
WithDatabase provide database
func WithDescription ¶
WithDescription provide name.
type SqlServerEntry ¶
type SqlServerEntry struct { User string `yaml:"user" json:"user"` 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 }
SqlServerEntry will init gorm.DB or SqlMock with provided arguments
func GetSqlServerEntry ¶
func GetSqlServerEntry(name string) *SqlServerEntry
GetSqlServerEntry returns SqlServerEntry instance
func RegisterSqlServerEntry ¶
func RegisterSqlServerEntry(opts ...Option) *SqlServerEntry
RegisterSqlServerEntry will register Entry into GlobalAppCtx
func (*SqlServerEntry) Bootstrap ¶
func (entry *SqlServerEntry) Bootstrap(ctx context.Context)
Bootstrap SqlServerEntry
func (*SqlServerEntry) GetDescription ¶
func (entry *SqlServerEntry) GetDescription() string
GetDescription returns entry description
func (*SqlServerEntry) GetName ¶
func (entry *SqlServerEntry) GetName() string
GetName returns entry name
func (*SqlServerEntry) GetType ¶
func (entry *SqlServerEntry) GetType() string
GetType returns entry type
func (*SqlServerEntry) Interrupt ¶
func (entry *SqlServerEntry) Interrupt(ctx context.Context)
Interrupt SqlServerEntry
func (*SqlServerEntry) IsHealthy ¶
func (entry *SqlServerEntry) IsHealthy() bool
IsHealthy checks healthy status remote provider
func (*SqlServerEntry) RegisterPromMetrics ¶ added in v1.2.7
func (entry *SqlServerEntry) RegisterPromMetrics(registry *prometheus.Registry) error
func (*SqlServerEntry) String ¶
func (entry *SqlServerEntry) String() string
String returns json marshalled string