Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Client ¶
func Client(s bandmaster.Service) *sql.DB
Client returns the underlying `sql.DB` of the given service.
It assumes that the service is ready; i.e. it might return nil if it's actually not.
NOTE: This will panic if `s` is not a `sql.Service`.
func New ¶
func New(conf *Config) bandmaster.Service
New creates a new SQL service using the provided `Config`. You may use the helpers for environment-based configuration to get a pre-configured `Config` with sane defaults.
It doesn't open any connection nor does it do any kind of I/O; i.e. it cannot fail.
Types ¶
type Env ¶
type Env struct {
Driver string `envconfig:"DRIVER" default:"postgres"`
Addr string `envconfig:"ADDR" default:"postgres://postgres:postgres@127.0.0.1:5432/postgres?sslmode=disable"`
ConnMaxLifetime time.Duration `envconfig:"CONN_MAX_LIFETIME" default:"10m"`
MaxIdleConns int `envconfig:"MAX_IDLE_CONNS" default:"1"`
MaxOpenConns int `envconfig:"MAX_OPEN_CONNS" default:"2"`
}
Env can be used to configure a SQL session via the environment.
It comes with sane defaults for a local development set-up. The default driver is setup to `posgres` with a working local address.
type Service ¶
type Service struct {
*bandmaster.ServiceBase // "inheritance"
// contains filtered or unexported fields
}