service3

package
v0.0.0-...-0f89b48 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2021 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 ...

func (*Account) IsSufficient

func (a *Account) IsSufficient(ammount int) bool

IsSufficient ...

func (*Account) Transfer

func (a *Account) Transfer(ammount int, to *Account)

Transfer ...

type Gateway

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

Gateway ...

func (*Gateway) GetAccountsForTransfer

func (g *Gateway) GetAccountsForTransfer(ctx context.Context, fromID, toID int64) (from, to Account, err error)

GetAccountsForTransfer ...

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 ...

func (*Gateway) UpdateBalance

func (g *Gateway) UpdateBalance(ctx context.Context, a Account) (Account, error)

UpdateBalance ...

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) GetAccountsForTransfer

func (g *MockGateway) GetAccountsForTransfer(ctx context.Context, fromID, toID int64) (from, to Account, err error)

GetAccountsForTransfer ...

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 ...

func (*MockGateway) UpdateBalance

func (g *MockGateway) UpdateBalance(ctx context.Context, a Account) (Account, error)

UpdateBalance ...

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)
	GetAccountsForTransfer(ctx context.Context, fromID, toID int64) (from, to Account, err error)
	UpdateBalance(ctx context.Context, a Account) (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