Documentation
¶
Overview ¶
Package account provides handlers for work with accounts in the system.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Account ¶
type Account struct {
TableName struct{} `json:"-" sql:"select:accounts_view,alias:accounts"`
ID ID `json:"id" sql:"id,pk,type:varchar(255)"`
Balance decimal.Decimal `json:"balance" sql:"balance,notnull,type:'decimal(16,4)'"`
Currency Currency `json:"currency" sql:"currency,notnull,type:varchar(3)"`
Deleted bool `json:"-" sql:"deleted,notnull"`
}
Account is a wallet in the system.
type Currency ¶
type Currency string
Currency type represents available currencies
const (
CurrencyUSD Currency = "USD"
)
type Repository ¶
type Repository interface {
// Store account in the repository
Store(account *Account) error
// Find account in the repository with specified id
Find(id ID) (*Account, error)
// FindAll returns all accounts registered in the system
FindAll() []*Account
// MarkDeleted is mark as deleted specified account in the system
MarkDeleted(id ID) error
}
Repository interface for accounts storing and operations.
type Service ¶
type Service interface {
// New registers a new account in the system, with desired Balance.
New(id ID, currency Currency, balance decimal.Decimal) error
// Load returns a read model of an account.
Load(id ID) (*Account, error)
// LoadAll returns all accounts registered in the system.
LoadAll() []*Account
// Delete uses to delete account from the system. Actually mark it as deleted.
Delete(id ID) error
}
Service is the interface that provides account methods.
func NewLoggingService ¶
NewLoggingService returns a new instance of a logging Service.
func NewMetricsService ¶
NewMetricsService returns an instance of a metrics Service.
func NewService ¶
func NewService(accounts Repository) Service
NewService creates an account service with necessary dependencies.
Click to show internal directories.
Click to hide internal directories.