transactions

package
v0.0.0-...-a6a5f53 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAccountNotFound     = errors.New("account not found")
	ErrInvalidAccID        = errors.New("invalid account")
	ErrInvalidAmount       = errors.New("invalid amount")
	ErrInsufficientBalance = errors.New("insufficient balance")
	ErrInsufficientCredit  = errors.New("insufficient credit")
)

Functions

This section is empty.

Types

type AccountsClient

type AccountsClient interface {
	Deposit(ctx context.Context, accID vos.AccountID, amount vos.Money) error
	Withdrawal(ctx context.Context, accID vos.AccountID, amount vos.Money) error
	ReserveCreditLimit(ctx context.Context, accID vos.AccountID, amount vos.Money) error
}

AccountsClient responsible for communicating with accounts server

type Repository

type Repository interface {
	SaveTransaction(context.Context, entities.Transaction) (vos.TransactionID, error)
}

Repository of transactions

type Usecase

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

Usecase of transactions

func NewUsecase

func NewUsecase(txRepo Repository, accClient AccountsClient) *Usecase

NewUsecase builds a tx usecase

func (Usecase) Transact

func (u Usecase) Transact(ctx context.Context, accID vos.AccountID, op operations.Operation, amount vos.Money) (vos.TransactionID, error)

Transact executes a transaction

Jump to

Keyboard shortcuts

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