Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Account ¶
type Account struct { ID int64 `db:"id"` UID string `db:"uid"` Currency string `db:"currency"` Balance int64 `db:"balance"` CreatedAt time.Time `db:"created_at"` }
Account define account entity
type AccountRepository ¶
type AccountRepository interface { // GetAll return all accounts in storage GetAll(ctx context.Context) ([]Account, error) // Store save new account in storage Store(ctx context.Context, account *Account) error // Update balance for given account by incrementing on given value UpdateBalance(ctx context.Context, uid string, incr int64) error }
AccountRepository declare repository for accounts
type Factory ¶
type Factory interface { // Context creates new scope for repository activities Scope() Scope // AccountRepository return account repository instance AccountRepository() AccountRepository // PaymentRepository return payment repository instance PaymentRepository() PaymentRepository }
Factory define accessors to all repositories
type Payment ¶
type Payment struct { ID int64 `db:"id"` Amount int64 `db:"amount"` PayerAccountUID string `db:"payer_account_uid"` RecipientAccountUID string `db:"recipient_account_uid"` CreatedAt time.Time `db:"created_at"` }
Payment define payment entity
type PaymentRepository ¶
type PaymentRepository interface { // GetAll return all payments in storage GetAll(ctx context.Context) ([]Payment, error) // Store save new payment in storage Store(ctx context.Context, payment *Payment) error }
PaymentRepository declare repository for payments
type Scope ¶
type Scope interface { // WithContext initializes scope with context and return new context to use in repository's operations WithContext(ctx context.Context) (context.Context, error) // Complete finish current scope Complete(ctx context.Context) error // Cancel cancel current scope Cancel(ctx context.Context) error }
Scope define some operation context for repository operations (unit of work) It's safe to call Cancel/Complete multiple times, only the first one will be actually done
Click to show internal directories.
Click to hide internal directories.