account

package
v0.0.0-...-bffa35e Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2019 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package account provides the use-case of users accounts and it manipulations.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidAccount is returned when from account is equal to account, or account is empty
	ErrInvalidAccount = errors.New("invalid account")

	// ErrInvalidSum is returned when the sum to send is less or equal 0
	ErrInvalidSum = errors.New("invalid sum for send")

	// ErrUnexpectedError is returned when some unexpected error: like transaction can't be started or committed
	ErrUnexpectedError = errors.New("unexpected error")

	// ErrAccountNotFound is returned when account not found
	ErrAccountNotFound = errors.New("account not found")

	// ErrInSaving is returned when we can't save data to storage
	ErrInSaving = errors.New("cant save updated data")
)

Functions

func MakeHandler

func MakeHandler(bs Service, logger log.Logger) http.Handler

MakeHandler returns a handler for the account service.

func NewLoggerService

func NewLoggerService(logger log.Logger, s Service) *loggerService

NewLoggerService returns a new instance of the Service with logging.

Types

type Account

type Account struct {
	ID       string          `json:"id"`
	Balance  decimal.Decimal `json:"balance"`
	Currency string          `json:"currency"`
}

Account is a model of user's account

type Endpoints

type Endpoints struct {
	Send endpoint.Endpoint
	Get  endpoint.Endpoint
	Add  endpoint.Endpoint
}

Endpoints holds all Go kit endpoints for the Account service.

type Service

type Service interface {
	// Send - transfer money from one account to another.
	Send(from coins.AccountID, to coins.AccountID, sum decimal.Decimal) error

	// Get - returns a list of all accounts in system.
	Get() ([]*Account, error)

	// Add - add new account
	Add(account *Account) error
}

Service is the interface that provides the basic Account method.

func NewService

NewService returns a new instance of the default Service.

Jump to

Keyboard shortcuts

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