import "github.com/egdaemon/eg/runtime/x/wasi/egpostgresql"
Package egpostgresql provides functionality for setting up a postgresql service within eg environments. Specifically allows for waiting for the postgresql service to become available and configuring local access.
<a name="Auto"></a>
func Auto(ctx context.Context, _ eg.Op) (err error)
Wait for postgresql to become available and then configure the instance for use by root and egd users.
<details><summary>Example</summary> <p>package main
import (
"context"
"log"
"github.com/egdaemon/eg/runtime/wasi/eg"
"github.com/egdaemon/eg/runtime/x/wasi/egpostgresql"
)
func main() {
var (
err error
)
ctx := context.Background()
err = eg.Perform(
ctx,
egpostgresql.Auto, // wait for postgresql to become ready
egpostgresql.RecreateDatabase("example"), // create a database.
egpostgresql.InsertSuperuser("soandso"), // create a superuser to use.
)
if err != nil {
log.Fatalln(err)
}
}
</p>
</details>
<a name="AutoLocatePort"></a>
func AutoLocatePort(ctx context.Context) int
attempts to determine what port postgresql is listening on
<a name="Environ"></a>
func Environ() []string
build a environment that sets up postgresql the standard postgresql variables.
<a name="InsertSuperuser"></a>
func InsertSuperuser(name string) eg.OpFn
Create a superuser with the provided name.
<a name="LocatePort"></a>
func LocatePort(ctx context.Context, begin, end int) int
determine what port postgresql is listening on within a given range. if it can't determine the port it returns the default pg port 5432.
<a name="RecreateDatabase"></a>
func RecreateDatabase(name string) eg.OpFn
Forcibly recreate a database.
<a name="Runtime"></a>
func Runtime() shell.Command
Create a shell runtime that properly sets up the postgresql environment.