register

package
v0.0.0-...-de70ca6 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config interface {
	Logger() logging.Logger
	RegistrationBasePrice() float64
	DataDSN() string
}

Config is the configuration for the Registerer

type Exchanger

type Exchanger interface {
	// Exchange will perform the conversion
	Exchange(ctx context.Context, basePrice float64, currency string) (float64, error)
}

Exchanger will convert from one currency to another

type Person

type Person struct {
	ID       int
	FullName string
	Phone    string
	Currency string
	Price    float64
}

Person is a copy/sub-set of data.Person so that the relationship does not leak. It also allows us to remove/hide and internal fields

type Registerer

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

Registerer validates the supplied person, calculates the price in the requested currency and saves the result. It will return an error when: -the person object does not include all the fields -the currency is invalid -the exchange rate cannot be loaded -the data layer throws an error.

func NewRegisterer

func NewRegisterer(cfg Config, exchanger Exchanger) *Registerer

NewRegisterer creates and initializes a Registerer

func (*Registerer) Do

func (r *Registerer) Do(ctx context.Context, in *Person) (int, error)

Do is API for this struct

Jump to

Keyboard shortcuts

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