fleet/server/datastore/mysql/config.go
John Murphy 6a825c11e3 Datastore refactor (#439)
Removed Gorm, replaced it with Sqlx

* Added SQL bundling command to Makfile

* Using go-kit logger

* Added soft delete capability

* Changed SearchLabel to accept a variadic param for optional omit list
instead of array

* Gorm removed

* Refactor table structures to use CURRENT_TIMESTAMP mysql function

* Moved Inmem datastore into it's own package

* Updated README

* Implemented code review suggestions from @zwass

* Removed reference to Gorm from glide.yaml
2016-11-16 21:47:49 +08:00

33 lines
750 B
Go

package mysql
import "github.com/go-kit/kit/log"
const defaultMaxAttempts int = 15
// DBOption is used to pass optional arguments to a database connection
type DBOption func(o *dbOptions) error
type dbOptions struct {
// maxAttempts configures the number of retries to connect to the DB
maxAttempts int
logger log.Logger
}
// Logger adds a logger to the datastore
func Logger(l log.Logger) DBOption {
return func(o *dbOptions) error {
o.logger = l
return nil
}
}
// LimitAttempts sets a the number of attempts
// to try establishing a connection to the database backend
// the default value is 15 attempts
func LimitAttempts(attempts int) DBOption {
return func(o *dbOptions) error {
o.maxAttempts = attempts
return nil
}
}