service3

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	ID      int64 `db:"aikawarazu"`
	Balance int   `db:"tekitode"`
}

Account ...

type Gateway

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

Gateway ...

func (*Gateway) DecreaseBalance

func (g *Gateway) DecreaseBalance(ctx context.Context, id int64, ammount int) (Account, error)

DecreaseBalance ...

func (*Gateway) IncreaseBalance

func (g *Gateway) IncreaseBalance(ctx context.Context, id int64, ammount int) (Account, error)

IncreaseBalance ...

func (*Gateway) IsBalanceSufficient

func (g *Gateway) IsBalanceSufficient(ctx context.Context, accountID int64, ammount int) (bool, error)

IsBalanceSufficient ...

func (*Gateway) OpenAccount

func (g *Gateway) OpenAccount(ctx context.Context, initialAmmount int) (Account, error)

OpenAccount ...

func (*Gateway) RunInTransaction

func (g *Gateway) RunInTransaction(ctx context.Context, txFn func(context.Context) (interface{}, error)) (interface{}, error)

RunInTransaction ...

type MockDB

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

MockDB ...

func NewMockDB

func NewMockDB() *MockDB

NewMockDB ...

type MockGateway

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

MockGateway ...

func (*MockGateway) DecreaseBalance

func (g *MockGateway) DecreaseBalance(ctx context.Context, id int64, ammount int) (Account, error)

DecreaseBalance ...

func (*MockGateway) IncreaseBalance

func (g *MockGateway) IncreaseBalance(ctx context.Context, id int64, ammount int) (Account, error)

IncreaseBalance ...

func (*MockGateway) IsBalanceSufficient

func (g *MockGateway) IsBalanceSufficient(ctx context.Context, accountID int64, ammount int) (bool, error)

IsBalanceSufficient ...

func (*MockGateway) OpenAccount

func (g *MockGateway) OpenAccount(ctx context.Context, initialAmmount int) (Account, error)

OpenAccount ...

func (*MockGateway) RunInTransaction

func (g *MockGateway) RunInTransaction(ctx context.Context, txFn func(context.Context) (interface{}, error)) (interface{}, error)

RunInTransaction ...

type Provider

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

Provider ...

func NewProvider

func NewProvider(r Repository) *Provider

NewProvider ...

func (*Provider) OpenAccount

func (p *Provider) OpenAccount(ctx context.Context, initialAmmount int) (Account, error)

OpenAccount ...

func (*Provider) Transfer

func (p *Provider) Transfer(ctx context.Context, ammount int, fromID, toID int64) (from, to Account, err error)

Transfer ...

type Repository

type Repository interface {
	RunInTransaction(context.Context, func(context.Context) (interface{}, error)) (interface{}, error)
	OpenAccount(ctx context.Context, initialAmmount int) (Account, error)
	IsBalanceSufficient(ctx context.Context, accountID int64, ammount int) (bool, error)
	IncreaseBalance(ctx context.Context, accountID int64, ammount int) (Account, error)
	DecreaseBalance(ctx context.Context, accountID int64, ammount int) (Account, error)
}

Repository ...

func NewGateway

func NewGateway(db *sqlxx.Accessor) Repository

NewGateway ...

func NewMockGateway

func NewMockGateway(db *MockDB) Repository

NewMockGateway ...

Jump to

Keyboard shortcuts

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