Documentation ¶
Index ¶
- Constants
- Variables
- func Config(opts ...opt) *config
- func WithDatabase(database string) opt
- func WithLocale(locale string) opt
- func WithLogger(logger *zap.Logger) opt
- func WithPGConfig(conf map[string]string) opt
- func WithPGLogger(logger io.Writer) opt
- func WithPort(port uint32) opt
- func WithRepository(url string) opt
- func WithRuntimePath(path string) opt
- func WithStartTimeout(d time.Duration) opt
- func WithVersion(version PostgresVersion) opt
- type CacheLocator
- type EmbeddedPostgres
- func (ep *EmbeddedPostgres) Connect(ctx context.Context) (*pgxpool.Pool, error)
- func (ep *EmbeddedPostgres) ConnectionString() string
- func (ep *EmbeddedPostgres) Ping(ctx context.Context) error
- func (ep *EmbeddedPostgres) RecoverStop(ctx context.Context)
- func (ep *EmbeddedPostgres) Start(ctx context.Context) error
- func (ep *EmbeddedPostgres) Stop(_ context.Context) error
- func (ep *EmbeddedPostgres) URL() string
- type PostgresVersion
- type RemoteFetchStrategy
- type VersionStrategy
Constants ¶
const ( V14 = PostgresVersion("14.5.0") V13 = PostgresVersion("13.8.0") V12 = PostgresVersion("12.12.0") V11 = PostgresVersion("11.17.0") V10 = PostgresVersion("10.22.0") V9 = PostgresVersion("9.6.24") )
Predefined supported Postgres versions
Variables ¶
var ErrPortNotAvailable = errors.New("port not available")
Functions ¶
func WithDatabase ¶
func WithDatabase(database string) opt
func WithLogger ¶ added in v0.2.0
func WithPGConfig ¶ added in v0.2.0
func WithPGLogger ¶
WithLogger sets the logger for postgres output
func WithRepository ¶
func WithRepository(url string) opt
WithRepository sets BinaryRepositoryURL to fetch PG Binary in case of Maven proxy
func WithRuntimePath ¶
func WithRuntimePath(path string) opt
func WithStartTimeout ¶
func WithVersion ¶
func WithVersion(version PostgresVersion) opt
WithVersion will set the Postgres binary version
Types ¶
type CacheLocator ¶
CacheLocator retrieves the location of the Postgres binary cache returning it to location. The result of whether this cache is present will be returned to exists.
type EmbeddedPostgres ¶
type EmbeddedPostgres struct {
// contains filtered or unexported fields
}
EmbeddedPostgres maintains all configuration and runtime functions for maintaining the lifecycle of one Postgres process.
func NewDatabase ¶
func NewDatabase(config ...*config) *EmbeddedPostgres
NewDatabase creates a new EmbeddedPostgres struct that can be used to start and stop a Postgres process. When called with no parameters it will assume a default configuration state provided by the DefaultConfig method. When called with parameters the first Config parameter will be used for configuration.
func (*EmbeddedPostgres) ConnectionString ¶
func (ep *EmbeddedPostgres) ConnectionString() string
func (*EmbeddedPostgres) RecoverStop ¶
func (ep *EmbeddedPostgres) RecoverStop(ctx context.Context)
RecoverStop returns a deferrable function that will teardown in the event of a panic.
func (*EmbeddedPostgres) Start ¶
func (ep *EmbeddedPostgres) Start(ctx context.Context) error
Start will try to start the configured Postgres process returning an error when there were any problems with invocation. If any error occurs Start will try to also Stop the Postgres process in order to not leave any sub-process running.
func (*EmbeddedPostgres) Stop ¶
func (ep *EmbeddedPostgres) Stop(_ context.Context) error
Stop will try to stop the Postgres process gracefully returning an error when there were any problems.
func (*EmbeddedPostgres) URL ¶
func (ep *EmbeddedPostgres) URL() string
type PostgresVersion ¶
type PostgresVersion string
PostgresVersion represents the semantic version used to fetch and run the Postgres process
type RemoteFetchStrategy ¶
type RemoteFetchStrategy func() error
RemoteFetchStrategy provides a strategy to fetch a Postgres binary so that it is available for use.
type VersionStrategy ¶
type VersionStrategy func() (operatingSystem string, architecture string, postgresVersion PostgresVersion)
VersionStrategy provides a strategy that can be used to determine which version of Postgres should be used based on the operating system, architecture and desired Postgres version.