Documentation ¶
Overview ¶
Package dockerdb allows user to create virtual databases using docker. Tested with PostgreSQL, MySQL, MS SQL.
Index ¶
- Variables
- func Pull(ctx context.Context, image DockerHubName) error
- func Run(ctx context.Context, ID string) error
- func SetMaxWaitTime(sec time.Duration)
- type Config
- func (c *Config) ActualPort(port nat.Port) *Config
- func (c *Config) Build() Config
- func (c *Config) DBName(name string) *Config
- func (c *Config) DBPassword(password string) *Config
- func (c *Config) DBUser(user string) *Config
- func (c *Config) DockerEnv(env []string) *Config
- func (c *Config) GetActualPort() nat.Port
- func (c *Config) GetDBName() string
- func (c *Config) GetDBPassword() string
- func (c *Config) GetDBUser() string
- func (c *Config) GetEnvDocker() []string
- func (c *Config) GetSQLConnStr() string
- func (c *Config) GetStandardDBPort() nat.Port
- func (c *Config) NoSQL(checkWakeUp func(conf Config) (stop bool), tries int, sleepTime time.Duration) *Config
- func (c *Config) PullImage() *Config
- func (c *Config) SQL() *Config
- func (c *Config) SQLConnStr(connString string) *Config
- func (c *Config) StandardDBPort(port nat.Port) *Config
- func (c *Config) Vendor(vendor DockerHubName) *Config
- type DockerHubName
- type VDB
- func (ddb *VDB) Clear(ctx context.Context) (err error)
- func (ddb *VDB) GetPort() (port nat.Port)
- func (ddb *VDB) Kill(ctx context.Context, signal string) (err error)
- func (ddb *VDB) Pause(ctx context.Context) (err error)
- func (ddb *VDB) Remove(ctx context.Context) (err error)
- func (ddb *VDB) Restart(ctx context.Context) (err error)
- func (ddb *VDB) Run(ctx context.Context) (err error)
- func (ddb *VDB) SQL() (db *sql.DB)
- func (ddb *VDB) Stop(ctx context.Context) (err error)
- func (ddb *VDB) Unpause(ctx context.Context) (err error)
Constants ¶
This section is empty.
Variables ¶
var (
ErrUnknown = errors.New("unknown error")
)
Functions ¶
func Pull ¶
func Pull(ctx context.Context, image DockerHubName) error
Pull pulls an image from net. WARNING!! USE IT CAREFULLY! DOWNLOADING SOME db IMAGES MAY TAKE SOME TIME. Tested with PostgreSQL, MySQL, MS SQL.
func SetMaxWaitTime ¶
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
func EmptyConfig ¶
func EmptyConfig() *Config
func (*Config) ActualPort ¶
ActualPort allows you to set the actual port for the database. Random unused port is used by default.
func (*Config) Build ¶
Build builds the config. After building, the config can be used and can't be changed.
func (*Config) DBPassword ¶
DBPassword sets the password of the database.
func (*Config) GetActualPort ¶
func (*Config) GetDBPassword ¶
func (*Config) GetEnvDocker ¶
func (*Config) GetSQLConnStr ¶
func (*Config) GetStandardDBPort ¶
func (*Config) NoSQL ¶
func (c *Config) NoSQL(checkWakeUp func(conf Config) (stop bool), tries int, sleepTime time.Duration) *Config
NoSQL sets db kind to NoSQL.
func (*Config) SQLConnStr ¶
SQLConnStr sets the SQL connection string. (Use it only for unsupported databases).
func (*Config) StandardDBPort ¶
StandardDBPort represents the standard port of the database which can be used to connect to it.
func (*Config) Vendor ¶
func (c *Config) Vendor(vendor DockerHubName) *Config
Vendor sets the vendor of the database.
type DockerHubName ¶
type DockerHubName string
const ( Postgres15 DockerHubName = "postgres:15" Postgres14 DockerHubName = "postgres:14" Postgres13 DockerHubName = "postgres:13" Postgres12 DockerHubName = "postgres:12" Postgres11 DockerHubName = "postgres:11" MySQL5Image DockerHubName = "mysql:5.7" MySQL8Image DockerHubName = "mysql:8" KeyDBImage DockerHubName = "eqalpha/keydb" RedisImage DockerHubName = "redis" ScyllaDBImage DockerHubName = "scylladb/scylla" )
type VDB ¶
type VDB struct {
// contains filtered or unexported fields
}