rate

package
v0.0.0-...-f7c21de Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 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 Averager

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

Averager tracks the average exchange rate for a currency over a period of time.

func New

func New(opts ...Option) *Averager

New creates a new averager with the provided options.

func (*Averager) Rate

func (ra *Averager) Rate() decimal.Decimal

Rate returns the average exchange rate for the configured currency.

func (*Averager) Run

func (ra *Averager) Run(ctx context.Context)

Run starts the averager, which will update the average exchange rate for the configured currency at the configured frequency.

func (*Averager) Update

func (ra *Averager) Update() (decimal.Decimal, error)

Update updates the average exchange rate for the configured currency.

type Option

type Option func(*Averager)

An Option configures an averager.

func WithCurrency

func WithCurrency(currency string) Option

WithCurrency sets the currency for the averager.

func WithFrequency

func WithFrequency(frequency time.Duration) Option

WithFrequency sets the frequency for the averager.

func WithLogger

func WithLogger(log *zap.Logger) Option

WithLogger sets the logger for the averager.

Jump to

Keyboard shortcuts

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