db

package
v0.0.0-...-816ca63 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2024 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InMemory = iota
	Pebble
	CQL
	SQL
)

Variables

This section is empty.

Functions

func OpenSQLDB

func OpenSQLDB(config SQLConfig) (db *sql.DB, err error)

func RunMigration

func RunMigration(args MigrationArgs) (err error)

Types

type CQLConfig

type CQLConfig struct {
	Hosts    []string
	Keyspace string
}

type Config

type Config struct {
	Type   int
	Pebble PebbleConfig
	CQL    CQLConfig
	SQL    SQLConfig
	Logger *slog.Logger
}

type Interface

type Interface interface {
	Shorts() ShortStore
	Users() UserStore
}

func New

func New(config Config) Interface

func NewCQLDB

func NewCQLDB(config CQLConfig) Interface

func NewInMemory

func NewInMemory() Interface

func NewPebble

func NewPebble(config PebbleConfig) Interface

func NewSQLDB

func NewSQLDB(config SQLConfig) Interface

type ListResults

type ListResults struct {
	Matching []ShortData
}

type MigrationArgs

type MigrationArgs struct {
	Logger    *slog.Logger
	SchemaDir string
	Basename  string
	Extension string
	DryRun    bool
	Migrator  Migrator
}

type Migrator

type Migrator interface {
	InitDB() (err error)
	ApplySchema(schema Schema, dry_run bool) (err error)
	Complete()
}

type PebbleConfig

type PebbleConfig struct {
	Path string
}

type SQLConfig

type SQLConfig struct {
	Driver     string // mysql
	ConnString string // Connection string
}

type Schema

type Schema struct {
	Schema   string
	Filename string
}

type ShortData

type ShortData struct {
	Short string `json:"Short"`
	Long  string `json:"Long"`
	Owner uint64 `json:"Owner"`
}

func Decode

func Decode(b []byte) (d ShortData, err error)

func ToShortData

func ToShortData(s schema.ShortStruct) ShortData

func (ShortData) Encode

func (s ShortData) Encode() (b []byte, err error)

func (ShortData) ToShortStruct

func (s ShortData) ToShortStruct() schema.ShortStruct

type ShortStore

type ShortStore interface {
	Put(data ShortData) error
	Get(short string) (ShortData, error)
	Delete(data ShortData) error
	List(start, end string) (ListResults, error)
}

type UserData

type UserData struct {
	Email string `json:"Email"`
	Name  string `json:"Name"`
	Id    uint64 `json:"Id"`
}

func ToUserData

func ToUserData(u schema.UsersStruct) UserData

func (UserData) ToUsersStruct

func (u UserData) ToUsersStruct() schema.UsersStruct

type UserStore

type UserStore interface {
	LookupOrCreate(queryUser UserData) (user UserData)
	Get(id uint64) (user UserData, err error)
	Delete(id uint64) (err error)
}

Directories

Path Synopsis
app
sqlschema
app

Jump to

Keyboard shortcuts

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