Documentation
¶
Index ¶
- Constants
- Variables
- func ErrDryRunModeUnsupported(err error) error
- func ErrEmptySlice(err error) error
- func ErrInvalidDB(err error) error
- func ErrInvalidData(err error) error
- func ErrInvalidField(err error) error
- func ErrInvalidTransaction(err error) error
- func ErrInvalidValue(err error) error
- func ErrInvalidValueOfLength(err error) error
- func ErrMissingWhereClause(err error) error
- func ErrModelValueRequired(err error) error
- func ErrNotImplemented(err error) error
- func ErrPrimaryKeyRequired(err error) error
- func ErrRegistered(err error) error
- func ErrUnsupportedDriver(err error) error
- func ErrUnsupportedRelation(err error) error
- func GormErrRecordNotFound(err error) error
- func IsErrInvalidTransaction(err error) bool
- func IsGormErrRecordNotFound(err error) bool
- func NewGormError() gorm.Plugin
- func NewGormTracer() gorm.Plugin
- func NewLogger(config *LoggerConf, core zapcore.Core) logger.Interface
- func WrapGormError(err error) error
- type Conf
- func (*Conf) Descriptor() ([]byte, []int)deprecated
- func (x *Conf) GetConnMaxLifetime() *durationpb.Duration
- func (x *Conf) GetDriver() DBType
- func (x *Conf) GetLogger() *LoggerConf
- func (x *Conf) GetMaxIdleConns() int32
- func (x *Conf) GetMaxOpenConns() int32
- func (x *Conf) GetSource() string
- func (*Conf) ProtoMessage()
- func (x *Conf) ProtoReflect() protoreflect.Message
- func (x *Conf) Reset()
- func (x *Conf) String() string
- func (m *Conf) Validate() error
- func (m *Conf) ValidateAll() error
- type ConfMultiError
- type ConfValidationError
- type DB
- type DBType
- type GormError
- type GormTracer
- 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 logger.LogLevel) logger.Interface
- func (l *Logger) Trace(ctx context.Context, begin time.Time, fc func() (string, int64), err error)
- func (l *Logger) Warn(ctx context.Context, msg string, data ...interface{})
- type LoggerConf
- func (*LoggerConf) Descriptor() ([]byte, []int)deprecated
- func (x *LoggerConf) GetColorful() bool
- func (x *LoggerConf) GetIgnoreRecordNotFoundError() bool
- func (x *LoggerConf) GetLogLevel() int32
- func (x *LoggerConf) GetParameterizedQueries() bool
- func (x *LoggerConf) GetSlowThreshold() *durationpb.Duration
- func (*LoggerConf) ProtoMessage()
- func (x *LoggerConf) ProtoReflect() protoreflect.Message
- func (x *LoggerConf) Reset()
- func (x *LoggerConf) String() string
- func (m *LoggerConf) Validate() error
- func (m *LoggerConf) ValidateAll() error
- type LoggerConfMultiError
- type LoggerConfValidationError
Constants ¶
const ( Reset = "\033[0m" Red = "\033[31m" Green = "\033[32m" Yellow = "\033[33m" Blue = "\033[34m" Magenta = "\033[35m" Cyan = "\033[36m" White = "\033[37m" BlueBold = "\033[34;1m" MagentaBold = "\033[35;1m" RedBold = "\033[31;1m" YellowBold = "\033[33;1m" )
Colors
Variables ¶
var ( DBType_name = map[int32]string{ 0: "UNKNOWN", 1: "mysql", 2: "postgres", 3: "sqlite", 4: "sqlserver", } DBType_value = map[string]int32{ "UNKNOWN": 0, "mysql": 1, "postgres": 2, "sqlite": 3, "sqlserver": 4, } )
Enum value maps for DBType.
var File_store_gormx_conf_proto protoreflect.FileDescriptor
Functions ¶
func ErrDryRunModeUnsupported ¶
ErrDryRunModeUnsupported dry run mode unsupported
func ErrInvalidTransaction ¶
func ErrInvalidValueOfLength ¶
ErrInvalidValueOfLength invalid values do not match length
func ErrMissingWhereClause ¶
ErrMissingWhereClause missing where clause
func ErrModelValueRequired ¶
ErrModelValueRequired model value required
func ErrPrimaryKeyRequired ¶
ErrPrimaryKeyRequired primary keys required
func ErrUnsupportedDriver ¶
ErrUnsupportedDriver unsupported driver
func ErrUnsupportedRelation ¶
ErrUnsupportedRelation unsupported relations
func GormErrRecordNotFound ¶
GormErrRecordNotFound 找不到记录
func IsErrInvalidTransaction ¶
func IsGormErrRecordNotFound ¶
func NewGormError ¶ added in v0.0.29
func NewGormTracer ¶ added in v0.0.27
Types ¶
type Conf ¶
type Conf struct { Driver DBType `protobuf:"varint,1,opt,name=driver,proto3,enum=store.gormx.DBType" json:"driver,omitempty"` Source string `protobuf:"bytes,2,opt,name=source,proto3" json:"source,omitempty"` MaxOpenConns int32 `protobuf:"varint,4,opt,name=maxOpenConns,proto3" json:"maxOpenConns,omitempty"` MaxIdleConns int32 `protobuf:"varint,5,opt,name=maxIdleConns,proto3" json:"maxIdleConns,omitempty"` ConnMaxLifetime *durationpb.Duration `protobuf:"bytes,6,opt,name=connMaxLifetime,proto3" json:"connMaxLifetime,omitempty"` Logger *LoggerConf `protobuf:"bytes,7,opt,name=logger,proto3" json:"logger,omitempty"` // contains filtered or unexported fields }
func (*Conf) Descriptor
deprecated
func (*Conf) GetConnMaxLifetime ¶ added in v0.0.25
func (x *Conf) GetConnMaxLifetime() *durationpb.Duration
func (*Conf) GetLogger ¶ added in v0.0.34
func (x *Conf) GetLogger() *LoggerConf
func (*Conf) GetMaxIdleConns ¶ added in v0.0.25
func (*Conf) GetMaxOpenConns ¶ added in v0.0.25
func (*Conf) ProtoMessage ¶
func (*Conf) ProtoMessage()
func (*Conf) ProtoReflect ¶
func (x *Conf) ProtoReflect() protoreflect.Message
func (*Conf) Validate ¶
Validate checks the field values on Conf with the rules defined in the proto definition for this message. If any rules are violated, the first error encountered is returned, or nil if there are no violations.
func (*Conf) ValidateAll ¶ added in v0.0.8
ValidateAll checks the field values on Conf with the rules defined in the proto definition for this message. If any rules are violated, the result is a list of violation errors wrapped in ConfMultiError, or nil if none found.
type ConfMultiError ¶ added in v0.0.8
type ConfMultiError []error
ConfMultiError is an error wrapping multiple validation errors returned by Conf.ValidateAll() if the designated constraints aren't met.
func (ConfMultiError) AllErrors ¶ added in v0.0.8
func (m ConfMultiError) AllErrors() []error
AllErrors returns a list of validation violation errors.
func (ConfMultiError) Error ¶ added in v0.0.8
func (m ConfMultiError) Error() string
Error returns a concatenation of all the error messages it wraps.
type ConfValidationError ¶
type ConfValidationError struct {
// contains filtered or unexported fields
}
ConfValidationError is the validation error returned by Conf.Validate if the designated constraints aren't met.
func (ConfValidationError) Cause ¶
func (e ConfValidationError) Cause() error
Cause function returns cause value.
func (ConfValidationError) Error ¶
func (e ConfValidationError) Error() string
Error satisfies the builtin error interface
func (ConfValidationError) ErrorName ¶
func (e ConfValidationError) ErrorName() string
ErrorName returns error name.
func (ConfValidationError) Field ¶
func (e ConfValidationError) Field() string
Field function returns field value.
func (ConfValidationError) Key ¶
func (e ConfValidationError) Key() bool
Key function returns key value.
func (ConfValidationError) Reason ¶
func (e ConfValidationError) Reason() string
Reason function returns reason value.
type DBType ¶ added in v0.0.21
type DBType int32
dbMySQL Gorm Drivers mysql || postgres || sqlite || sqlserver
func (DBType) Descriptor ¶ added in v0.0.25
func (DBType) Descriptor() protoreflect.EnumDescriptor
func (DBType) EnumDescriptor
deprecated
added in
v0.0.25
func (DBType) Number ¶ added in v0.0.25
func (x DBType) Number() protoreflect.EnumNumber
func (DBType) Type ¶ added in v0.0.25
func (DBType) Type() protoreflect.EnumType
type GormTracer ¶ added in v0.0.27
type GormTracer struct {
// contains filtered or unexported fields
}
func (*GormTracer) Initialize ¶ added in v0.0.27
func (p *GormTracer) Initialize(db *gorm.DB) error
func (*GormTracer) Name ¶ added in v0.0.27
func (p *GormTracer) Name() string
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
type LoggerConf ¶ added in v0.0.34
type LoggerConf struct { SlowThreshold *durationpb.Duration `protobuf:"bytes,1,opt,name=slowThreshold,proto3" json:"slowThreshold,omitempty"` Colorful bool `protobuf:"varint,2,opt,name=colorful,proto3" json:"colorful,omitempty"` IgnoreRecordNotFoundError bool `protobuf:"varint,3,opt,name=ignoreRecordNotFoundError,proto3" json:"ignoreRecordNotFoundError,omitempty"` ParameterizedQueries bool `protobuf:"varint,4,opt,name=parameterizedQueries,proto3" json:"parameterizedQueries,omitempty"` LogLevel int32 `protobuf:"varint,5,opt,name=logLevel,proto3" json:"logLevel,omitempty"` // contains filtered or unexported fields }
func (*LoggerConf) Descriptor
deprecated
added in
v0.0.34
func (*LoggerConf) Descriptor() ([]byte, []int)
Deprecated: Use LoggerConf.ProtoReflect.Descriptor instead.
func (*LoggerConf) GetColorful ¶ added in v0.0.34
func (x *LoggerConf) GetColorful() bool
func (*LoggerConf) GetIgnoreRecordNotFoundError ¶ added in v0.0.34
func (x *LoggerConf) GetIgnoreRecordNotFoundError() bool
func (*LoggerConf) GetLogLevel ¶ added in v0.0.34
func (x *LoggerConf) GetLogLevel() int32
func (*LoggerConf) GetParameterizedQueries ¶ added in v0.0.34
func (x *LoggerConf) GetParameterizedQueries() bool
func (*LoggerConf) GetSlowThreshold ¶ added in v0.0.34
func (x *LoggerConf) GetSlowThreshold() *durationpb.Duration
func (*LoggerConf) ProtoMessage ¶ added in v0.0.34
func (*LoggerConf) ProtoMessage()
func (*LoggerConf) ProtoReflect ¶ added in v0.0.34
func (x *LoggerConf) ProtoReflect() protoreflect.Message
func (*LoggerConf) Reset ¶ added in v0.0.34
func (x *LoggerConf) Reset()
func (*LoggerConf) String ¶ added in v0.0.34
func (x *LoggerConf) String() string
func (*LoggerConf) Validate ¶ added in v0.0.34
func (m *LoggerConf) Validate() error
Validate checks the field values on LoggerConf with the rules defined in the proto definition for this message. If any rules are violated, the first error encountered is returned, or nil if there are no violations.
func (*LoggerConf) ValidateAll ¶ added in v0.0.34
func (m *LoggerConf) ValidateAll() error
ValidateAll checks the field values on LoggerConf with the rules defined in the proto definition for this message. If any rules are violated, the result is a list of violation errors wrapped in LoggerConfMultiError, or nil if none found.
type LoggerConfMultiError ¶ added in v0.0.34
type LoggerConfMultiError []error
LoggerConfMultiError is an error wrapping multiple validation errors returned by LoggerConf.ValidateAll() if the designated constraints aren't met.
func (LoggerConfMultiError) AllErrors ¶ added in v0.0.34
func (m LoggerConfMultiError) AllErrors() []error
AllErrors returns a list of validation violation errors.
func (LoggerConfMultiError) Error ¶ added in v0.0.34
func (m LoggerConfMultiError) Error() string
Error returns a concatenation of all the error messages it wraps.
type LoggerConfValidationError ¶ added in v0.0.34
type LoggerConfValidationError struct {
// contains filtered or unexported fields
}
LoggerConfValidationError is the validation error returned by LoggerConf.Validate if the designated constraints aren't met.
func (LoggerConfValidationError) Cause ¶ added in v0.0.34
func (e LoggerConfValidationError) Cause() error
Cause function returns cause value.
func (LoggerConfValidationError) Error ¶ added in v0.0.34
func (e LoggerConfValidationError) Error() string
Error satisfies the builtin error interface
func (LoggerConfValidationError) ErrorName ¶ added in v0.0.34
func (e LoggerConfValidationError) ErrorName() string
ErrorName returns error name.
func (LoggerConfValidationError) Field ¶ added in v0.0.34
func (e LoggerConfValidationError) Field() string
Field function returns field value.
func (LoggerConfValidationError) Key ¶ added in v0.0.34
func (e LoggerConfValidationError) Key() bool
Key function returns key value.
func (LoggerConfValidationError) Reason ¶ added in v0.0.34
func (e LoggerConfValidationError) Reason() string
Reason function returns reason value.