Documentation ¶
Overview ¶
Package psqldocker provides functions to start, stop and configure a PostgreSQL docker container. The purpose of this package is mainly for testing.
The docker container is created programatically using the github.com/ory/dockertest package.
Index ¶
- Variables
- type Container
- type Option
- func WithContainerName(name string) Option
- func WithDBPort(name string) Option
- func WithExpiration(seconds uint) Option
- func WithImageTag(tag string) Option
- func WithPingRetryTimeout(seconds uint) Option
- func WithPool(pool *dockertest.Pool) Option
- func WithPoolEndpoint(endpoint string) Option
- func WithSQL(sql string) Option
- func WithTimescaleDB() Option
Constants ¶
This section is empty.
Variables ¶
var ErrWithPoolAndWithPoolEndpoint = errors.New(
"with pool and with pool endpoint are mutually exclusive",
)
ErrWithPoolAndWithPoolEndpoint is returned when both WithPool and WithPoolEndpoint options are given to the NewContainer constructor.
Functions ¶
This section is empty.
Types ¶
type Container ¶
type Container struct {
// contains filtered or unexported fields
}
Container represents a Docker container running a PostgreSQL image.
func NewContainer ¶
NewContainer starts a new psql database in a docker container.
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option configures an BTC Node Docker.
func WithContainerName ¶
WithContainerName configures the PSQL Container Name, if empty, a random one will be picked.
func WithDBPort ¶
WithDBPort sets database port running in the container, default 5432.
func WithExpiration ¶ added in v1.1.0
WithExpiration terminates the container after a period has passed.
func WithImageTag ¶
WithImageTag configures the PSQL Container image tag, default: alpine.
func WithPingRetryTimeout ¶ added in v1.1.0
WithPingRetryTimeout sets the timeout in seconds for the ping retry function.
func WithPool ¶
func WithPool(pool *dockertest.Pool) Option
WithPool sets the docker container getPool. ! This is mutually exclusive with WithPoolEndpoint, and an error will be thrown if both are used.
func WithPoolEndpoint ¶ added in v1.1.0
WithPoolEndpoint sets the docker container pool endpoint. ! This is mutually exclusive with WithPool, and an error will be thrown if both are used.
func WithTimescaleDB ¶ added in v1.2.0
func WithTimescaleDB() Option
WithTimescaleDB allows using the TimescaleDB repository and images. This option also updates the image tag to 'latest-pg15' as the default alpine is invalid.