Documentation
¶
Overview ¶
Package pgstore is experimental: its API and documented formats may change in a minor release; see https://nsgo.games/docs/stability/.
Package pgstore opens a cloudsave.Store in a Postgres database with the github.com/jackc/pgx/v5 driver. Several cloud save service processes may share one database: each write takes an advisory lock on the account, and migrations take one on the schema.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Open ¶
Open connects to the Postgres database dsn names (a URL or a key=value string, as pgx parses it) and returns a store on it with the schema created. Several service processes may share the database. Keep the DSN, which may hold a password, out of logs and command lines: read it from the environment or a file. Close the store to close the connections.
Example ¶
Open connects to a running Postgres database and returns a cloudsave.Store with the schema created. The example is compiled but not run; keep the DSN, which may hold a password, out of logs and command lines.
package main
import (
"context"
"fmt"
"os"
"github.com/nsgo-dev/game/pkg/online/cloudsave/pgstore"
)
func main() {
store, err := pgstore.Open(context.Background(), os.Getenv("CLOUDSAVE_DATABASE_URL"))
if err != nil {
fmt.Println(err)
return
}
defer store.Close()
}
Output:
Types ¶
This section is empty.