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 ¶
RateProviderFunc adapts a function to the RateProvider interface.
func (RateProviderFunc) GetRate ¶
func (f RateProviderFunc) GetRate(ctx context.Context, req RateRequest) (decimal.Decimal, error)
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.