interfaces

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package interfaces defines the contracts required for external dependency injection.

RateProvider is context- and date-aware: implementations receive a RateRequest containing the transaction currency, functional currency, and effective date. They MUST be deterministic for the same request during one validation and thread-safe when a ledger is shared across goroutines.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RateProvider

type RateProvider interface {
	// GetRate returns the exchange rate for a request, or an error if the rate
	// cannot be determined. Implementations should honor ctx cancellation and
	// deadlines.
	GetRate(ctx context.Context, req RateRequest) (decimal.Decimal, error)
}

RateProvider abstracts the source of foreign exchange rates.

Implementations MUST be deterministic for the same request during one validation and MUST be thread-safe when the ledger is shared concurrently.

type RateProviderFunc

type RateProviderFunc func(ctx context.Context, req RateRequest) (decimal.Decimal, error)

RateProviderFunc adapts a function to the RateProvider interface.

func (RateProviderFunc) GetRate

GetRate calls f(ctx, req).

type RateRequest

type RateRequest struct {
	// Base is the transaction currency.
	Base currency.Code
	// Quote is the functional currency.
	Quote currency.Code
	// AsOf is the transaction effective date in UTC.
	AsOf time.Time
}

RateRequest identifies a rate lookup.

Base is the transaction currency, Quote is the functional currency, and the returned rate is quote units per one base unit. AsOf is the transaction's effective date in UTC.

Jump to

Keyboard shortcuts

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