persistence

package
v0.0.0-...-a657b10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 29, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultPGURl is exported for testing purposes
	DefaultPGURL = "postgres://edhgo:edhgodev@localhost:5432/edhgo?sslmode=disable"
)

Functions

func NewDB

func NewDB(dbURL string) (*sql.DB, error)

NewDB returns a migrated app database or an error. If it is passed an empty string, it will attempt to connect to the default testing DB

func NewPostgres

func NewPostgres(migdir string, dbURL string) (*sql.DB, error)

NewPostgres returns a migrated sql.DB with a Postgres database connection migdir is the relative path to the migrations directory.

func NewRedis

func NewRedis(url string, pass string, opts Config) (*redisDB, error)

NewRedis returns a new Redis Persistence that can be used in the application to persist and update state.

func NewSQLite

func NewSQLite(path string) (*sql.DB, error)

NewSQLite returns a DB object to persist data for the application.

Types

type Config

type Config map[string]string

type KV

type KV interface {
	Put(key Key, val Value) (Value, error)
	Get(key Key) (Value, bool, error)
}

CLEANUP remove this interface KV is the KV store for the game engine to work with.

type Key

type Key string

Key is a type for handling and validating Keys in the game engine

func (Key) String

func (k Key) String() (string, error)

String returns the string of the Key

type Persistence

type Persistence interface {
	Put(key Key, val Value) (Value, error)
	Get(key Key) (Value, bool, error)
}

Persistence allows us to use any database for persisting the state of this app if it can fulfill the Persistence layer.

type Value

type Value string

Value is a type for handling and validating Values in the game engine

func (Value) String

func (v Value) String() (string, error)

String returns the string of Value.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL