dbsql

package module
v0.0.0-...-94840cc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 20, 2023 License: MIT Imports: 15 Imported by: 0

README

DB SQL

go get -u github.com/rumorshub/dbsql

License

Distributed under MIT License, please see license file within the code for more details.

Documentation

Index

Constants

View Source
const PluginName = "db.sql"

Variables

View Source
var ErrConfigNotFound = errors.New("sql driver config not found")

Functions

This section is empty.

Types

type Channel

type Channel struct {
	io.Closer
	Config Config
	// contains filtered or unexported fields
}

func (*Channel) Close

func (c *Channel) Close() error

func (*Channel) DB

func (c *Channel) DB() (*sql.DB, string, error)

type ChannelsConfig

type ChannelsConfig map[string]Config

type Config

type Config struct {
	DriverName      string         `mapstructure:"driver_name" json:"driver_name,omitempty" yaml:"driver_name,omitempty"`
	DataSourceName  string         `mapstructure:"dsn" json:"dsn,omitempty" yaml:"data_source_name,omitempty"`
	Ping            bool           `mapstructure:"ping" json:"ping,omitempty" yaml:"ping,omitempty"`
	MaxIdleConns    *int           `mapstructure:"max_idle_conns" json:"max_idle_conns,omitempty" yaml:"max_idle_conns,omitempty"`
	MaxOpenConns    *int           `mapstructure:"max_open_conns" json:"max_open_conns,omitempty" yaml:"max_open_conns,omitempty"`
	ConnMaxLifetime *time.Duration `mapstructure:"conn_max_lifetime" json:"conn_max_lifetime,omitempty" yaml:"conn_max_lifetime,omitempty"`
	ConnMaxIdleTime *time.Duration `mapstructure:"conn_max_idle_time" json:"conn_max_idle_time,omitempty" yaml:"conn_max_idle_time,omitempty"`
}

type Configurer

type Configurer interface {
	Has(name string) bool
	UnmarshalKey(name string, out interface{}) error
}

type DBOpener

type DBOpener struct {
	io.Closer
	Channels map[string]*Channel
	// contains filtered or unexported fields
}

func NewOpener

func NewOpener() *DBOpener

func (*DBOpener) AddChannel

func (o *DBOpener) AddChannel(name string, config Config)

func (*DBOpener) Close

func (o *DBOpener) Close() error

func (*DBOpener) OpenDB

func (o *DBOpener) OpenDB(name string) (*sql.DB, string, error)

type Opener

type Opener interface {
	OpenDB(name string) (*sql.DB, string, error)
}

type Plugin

type Plugin struct {
	// contains filtered or unexported fields
}

func (*Plugin) DBOpener

func (p *Plugin) DBOpener() *DBOpener

func (*Plugin) Init

func (p *Plugin) Init(cfg Configurer) error

func (*Plugin) Name

func (p *Plugin) Name() string

func (*Plugin) Provides

func (p *Plugin) Provides() []*dep.Out

func (*Plugin) Serve

func (p *Plugin) Serve() chan error

func (*Plugin) Stop

func (p *Plugin) Stop(context.Context) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL