Documentation ¶
Overview ¶
Package domain contains the heart of the domain model.
Package contains the heart of the domain model.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrIdempotencyKeyExists = errors.New("such Idempotency Key already exists")
View Source
var ErrInsufficientFunds = errors.New("insufficient funds")
View Source
var ErrNotFound = errors.New("not found")
Functions ¶
This section is empty.
Types ¶
type AccountRepository ¶
type AccountRepository interface { // Store create or update given account Store(ctx context.Context, account *Account) error // Find fetching single account Find(ctx context.Context, id AccountID) (*Account, error) // FindAll fetching all accounts FindAll(ctx context.Context) ([]Account, error) // AddMoney makes given account more rich AddMoney(ctx context.Context, id AccountID, amount Money) error // SubtractMoney makes given account more poor SubtractMoney(ctx context.Context, id AccountID, amount Money) error // On create new instance of Repository on given db connection or transaction On(db orm.DB) AccountRepository }
type Currency ¶
func NewCurrency ¶
type Money ¶
Money base datatype to store money. Underline using immutable arbitrary precision fixed-point decimal.
func NewMoneyFromFloat ¶
NewMoneyFromFloat use this method to create new hardcoded money value
type Payment ¶
type Payment struct { ID PaymentID CreatedAt time.Time Amount Money Direction PaymentDirection `pg:"type:payment_directions"` Account AccountID FromAccount AccountID ToAccount AccountID }
Payment is the central class in the domain model.
type PaymentDirection ¶
type PaymentDirection string
const ( PaymentIncoming PaymentDirection = "incoming" PaymentOutcoming PaymentDirection = "outgoing" )
type PaymentRepository ¶
type PaymentRepository interface { // Store create or update given payment Store(ctx context.Context, payment *Payment) error // Find fetching single payment Find(ctx context.Context, id PaymentID) (*Payment, error) // FindAll fetching all payments FindAll(ctx context.Context) ([]Payment, error) // RegisterIdempotencyKey key which prevent duplicate writes. Client can't send us more than 1 request with same key. RegisterIdempotencyKey(ctx context.Context, idempotencyKey uuid.UUID) error // RemoveIdempotencyKey just removing key. RemoveIdempotencyKey(ctx context.Context, idempotencyKey uuid.UUID) error // On create new instance of Repository on given db connection or transaction On(db orm.DB) PaymentRepository }
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package account provides the use-case of accounts management.
|
Package account provides the use-case of accounts management. |
Package mock is a generated GoMock package.
|
Package mock is a generated GoMock package. |
Package payment provides the use-case of payments management.
|
Package payment provides the use-case of payments management. |
Click to show internal directories.
Click to hide internal directories.