sqlstore

package
v0.0.0-...-97274ee Latest Latest
Warning

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

Go to latest
Published: May 3, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DBPingAttempts    = 18
	DBPingTimeoutSecs = 10
	ExitDBOpen        = 101
	ExitPing          = 102
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountStore

type AccountStore struct {
	Store *Store
}

AccountStore ...

func (*AccountStore) Create

func (r *AccountStore) Create(u *model.Account) error

Create Account with balance = 0

func (*AccountStore) Delete

func (r *AccountStore) Delete(id string) error

Delete account by id

func (*AccountStore) Find

func (r *AccountStore) Find(id string) (*model.Account, error)

Find Return account by id

func (*AccountStore) GetBalance

func (r *AccountStore) GetBalance(id string) (float64, error)

GetBalance Get the account balance

func (*AccountStore) SetBalance

func (r *AccountStore) SetBalance(id string, balance float64) error

SetBalance account balance by id

func (*AccountStore) UpdateBalance

func (r *AccountStore) UpdateBalance(id string, balance float64) error

UpdateBalance Increase the account balance

type JobStore

type JobStore struct {
	Store *Store
}

func (*JobStore) CancelTransactionAndCorrectBalance

func (j *JobStore) CancelTransactionAndCorrectBalance(jobRunInterval time.Duration, accountId int) (err error)

type Store

type Store struct {
	Db *sql.DB
	// contains filtered or unexported fields
}

Store ...

func CreateNewAndConnect

func CreateNewAndConnect(cfg config.Config) *Store

CreateNewAndConnect ...

func (*Store) Account

func (s *Store) Account() store.AccountStore

Account sql store

func (*Store) Close

func (s *Store) Close()

Close db connection

func (*Store) Job

func (s *Store) Job() store.JobStore

Job sql store

func (*Store) Transaction

func (s *Store) Transaction() store.TransactionStore

Transaction sql store

type TransactionStore

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

func (*TransactionStore) Fetch

func (t *TransactionStore) Fetch(count int) ([]model.Transaction, error)

Fetch list of transaction

func (*TransactionStore) Save

func (t *TransactionStore) Save(request *model.IncomingRequest, status string) error

Save the transaction

func (*TransactionStore) Update

func (t *TransactionStore) Update(id int) error

Update the transaction record to CANCELLED

Jump to

Keyboard shortcuts

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