backend

package
v0.0.0-...-82f7c04 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

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

Backend represents the instance which manages the database.

func New

func New() (*Backend, error)

New returns a new backend struct mainly containing a database connection, according to the read config file.

func (*Backend) GetBalance

func (b *Backend) GetBalance(accountID uuid.UUID) (int, error)

GetBalance returns the balance of the account corresponding to the given account id.

func (*Backend) UpdateAccount

func (b *Backend) UpdateAccount(accountID uuid.UUID, amount int64) (int, error)

UpdateAccount updates the balance account by adding (or subtracted) the given amount. It returns the updated balance.

type Config

type Config struct {
	// DBName is the database name
	DBName string `json:"db_name"`
	// User is the database user
	User string `json:"user"`
	// Password is the database password for the used user
	Password string `json:"password"`
	// Addr is the database address
	Addr string `json:"addr"`
	// Port is the database port
	Port int `json:"port"`
	// SkipVerify is a bool which determines if the backend
	// must skips the ssl mode or not.
	SkipVerify bool `json:"skip_verify,omitempty"`
	// contains filtered or unexported fields
}

Config is the backend configuration.

func (*Config) Valid

func (c *Config) Valid() error

Valid returns an error if the config is not valid.

Jump to

Keyboard shortcuts

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