Documentation ¶
Overview ¶
Package repo provide helpers for Data Access Layer.
Index ¶
Constants ¶
const MySQLMaxKeySize = 191
MySQLMaxKeySize for indexed MySQL utf8mb4 CHAR/VARCHAR column.
Variables ¶
var (
ErrSchemaVer = errors.New("unsupported DB schema version")
)
Errors.
Functions ¶
func MySQLDuplicateEntry ¶ added in v1.4.0
MySQLDuplicateEntry returns true if err is mysql error "Duplicate entry…".
Types ¶
type Metrics ¶
type Metrics struct {
// contains filtered or unexported fields
}
Metrics contains general metrics for DAL methods.
func NewMetrics ¶
func NewMetrics(reg *prometheus.Registry, namespace, subsystem string, methodsFrom interface{}) (metric Metrics)
NewMetrics registers and returns common DAL metrics used by all services (namespace).
type MySQLConfig ¶ added in v1.4.0
type MySQLConfig struct { MySQL *mysql.Config GooseMySQLDir string SchemaVersion int64 Metric Metrics ReturnErrs []error // List of app.Err… returned by DAL methods. }
MySQLConfig contains repo configuration.
type Repo ¶
type Repo struct { DB *sqlxx.DB SchemaVer *schemaver.SchemaVer // contains filtered or unexported fields }
Repo provides access to storage.
func NewMySQL ¶ added in v1.4.0
NewMySQL creates and returns new Repo. It will also run required DB migrations and connects to DB.
func (*Repo) NoTx ¶
NoTx provides DAL method wrapper with: - converting sqlx errors which are actually bugs into panics, - ensure valid schema version while accessing DB, - general metrics for DAL methods, - wrapping errors with DAL method name.