Documentation
¶
Index ¶
- type Config
- type PGMConfig
- type PGManager
- func (m *PGManager) AvailableVersions(ctx context.Context) ([]string, error)
- func (m *PGManager) Bin(ctx context.Context, version string) (binDir string, unlock func() error, _ error)
- func (m *PGManager) Install(ctx context.Context, version string) error
- func (m *PGManager) InstalledVersions() ([]string, error)
- func (m *PGManager) Remove(version string) error
- type Server
- func (s *Server) Config() Config
- func (s *Server) ConnectionURL(ctx context.Context) (string, error)
- func (s *Server) Create(ctx context.Context) error
- func (s *Server) ID() string
- func (s *Server) Logfile(ctx context.Context) (string, error)
- func (s *Server) Start(ctx context.Context) error
- func (s *Server) Status(ctx context.Context) (Status, error)
- func (s *Server) Stop(ctx context.Context) error
- type Status
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// PostgresVersion is the version of the postgres binaries to use. Default is "17.2.0"
PostgresVersion string `json:"postgres_version,omitempty"`
// CacheDir is the directory containing the cache. Default is pgdevserver under the xdg cache directory
CacheDir string `json:"-"`
// Name is a way to distinguish between multiple servers that otherwise have the same configuration.
// Default is "default".
Name string `json:"name,omitempty"`
// PostgresOptions are additional options to pass to postgres on startup.
PostgresOptions []string `json:"postgres_options,omitempty"`
// InitDBArgs are additional arguments to pass to initdb when creating the cluster.
InitDBArgs []string `json:"init_db_args,omitempty"`
// Port is the port to use for the cluster. If empty, a random port will be selected.
Port string `json:"port,omitempty"`
// PGManager is the PGManager to use for installing postgres. If nil, a default PGManager will be used.
PGManager *PGManager
}
type PGMConfig ¶
type PGMConfig struct {
// MavenURL is the base URL for maven repositories. Default is https://repo1.maven.org/maven2.
MavenURL string
// CacheDir is the directory containing the cache. Default is pgm under the xdg cache directory
CacheDir string
// HTTPClient is the http client to use for downloading files.
HTTPClient *http.Client
}
type PGManager ¶
type PGManager struct {
// contains filtered or unexported fields
}
func NewPGManager ¶
func (*PGManager) AvailableVersions ¶
AvailableVersions returns a list of available versions of postgres
func (*PGManager) Bin ¶
func (m *PGManager) Bin(ctx context.Context, version string) (binDir string, unlock func() error, _ error)
Bin obtains a read lock for the given version and returns a path to the bin directory. The caller must call the returned unlock function when done with the bin directory. Use this to run pg_ctl, initdb, etc.
func (*PGManager) InstalledVersions ¶
InstalledVersions returns a list of installed postgres versions
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func ServerFromCache ¶
ServerFromCache returns a server from the cache by ID.
func ServersFromCache ¶
ServersFromCache returns all the servers in the cache.
func (*Server) Config ¶
Config returns the configuration of the server after it has been initialized with defaults.
func (*Server) ConnectionURL ¶
ConnectionURL returns the current connection URL of this server. When using dynamic ports, the ConnectionURL could change each time the server is started from a stopped state.