provider

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2023 License: Apache-2.0 Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnectionDetails

type ConnectionDetails struct {
	Host     string
	Port     string
	User     string
	Password string
	Database string
}

type Postgre

type Postgre struct {
	// contains filtered or unexported fields
}

Postgre is a provider that uses PostgreSQL as the underlying database.

func NewPostgre

func NewPostgre(details ConnectionDetails) (*Postgre, error)

NewPostgre creates a new Postgre provider with the given connection details.

func (Postgre) Balance

func (p Postgre) Balance(UUID string) (bal uint64, err error)

Balance ...

func (Postgre) Close

func (p Postgre) Close() error

Close ...

func (Postgre) Set

func (p Postgre) Set(UUID string, value uint64) (err error)

Set ...

type Provider

type Provider interface {
	// Balance returns the balance of the player with the given UUID.
	Balance(UUID string) (uint64, error)

	// Set sets the balance of the player with the given UUID to the given value.
	Set(UUID string, value uint64) error

	io.Closer
}

Provider is an interface that defines the methods that a provider must implement.

type SQLite

type SQLite struct {
	Database *sql.DB
}

SQLite is a provider that uses SQLite as the underlying database.

func NewSQLite

func NewSQLite(path string) (*SQLite, error)

NewSQLite creates a new SQLite provider and opens the database. If the economy database does not exist, it will be created.

func (*SQLite) Balance

func (S *SQLite) Balance(UUID string) (uint64, error)

Balance ...

func (*SQLite) Close

func (S *SQLite) Close() error

Close closes the opened database connection and saves the sqlite file.

func (*SQLite) Set

func (S *SQLite) Set(UUID string, value uint64) error

Set ...

Jump to

Keyboard shortcuts

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