transfer

package
v0.0.0-...-e55fb6d Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidAmount = errors.New("amount must be greater than zero")
	ErrSameAccount   = errors.New("cannot transfer to the same account")

	ErrInsufficientFunds = errors.New("insufficient funds")
)

Functions

This section is empty.

Types

type Clock

type Clock func() time.Time

type ErrAccountNotFound

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

func NewErrAccountNotFound

func NewErrAccountNotFound(account ulid.ULID, which string) *ErrAccountNotFound

func (*ErrAccountNotFound) Error

func (e *ErrAccountNotFound) Error() string

func (*ErrAccountNotFound) Unwrap

func (e *ErrAccountNotFound) Unwrap() error

type IDGen

type IDGen func() ulid.ULID

type NewTx

type NewTx struct {
	From   ulid.ULID
	To     ulid.ULID
	Amount decimal.Decimal
}

type Service

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

func NewService

func NewService(s Storage, id IDGen, clock Clock) *Service

func (*Service) New

func (s *Service) New(ctx context.Context, tx NewTx) (ulid.ULID, error)

func (*Service) Retrieve

func (s *Service) Retrieve(ctx context.Context, id ulid.ULID) (*Transaction, error)

type Storage

type Storage interface {
	CreateTx(ctx context.Context, tx Transaction) error
	GetTx(ctx context.Context, id ulid.ULID) (*Transaction, error)
}

type Transaction

type Transaction struct {
	ID        ulid.ULID
	From      ulid.ULID
	To        ulid.ULID
	Amount    decimal.Decimal
	CreatedAt time.Time
}

Jump to

Keyboard shortcuts

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