No seam for fetching rates from an outside source #49
Labels
No labels
kind
bug
kind
enhancement
kind
refactor
workflow
needs-info
workflow
needs-triage
workflow
ready-for-agent
workflow
ready-for-human
workflow
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
rosa/lucre#49
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Rates come from outside — a central bank feed, a broker, a cached file — but
the crate names no interface for one. A caller that swaps feeds, or writes a
fake feed for a test, has nothing to write against.
The crate does no I/O and should keep it that way. HTTP and async belong in
the caller or in a companion crate.
Proposal
A
RateProvidertrait for looking up a rate, withExchangeas the offlineimplementation over rates already in hand.
Open questions
ExchangeRatefor a pair, or restatinga
Moneydirectly?network feed fails in ways a table does not.
Exchangeandimplement the trait over that cache. Is that shape enough for a real caller,
or does the trait need to admit failure that is worth retrying?
should it wait until a companion crate needs it? Writing it early fixes a
shape before anything has pushed on it.
Out of scope
Triangulation, dated rates, and two-sided quotes. Each is its own issue.
Exchange::convertfails on a pair it could derive #47Closing as out of scope, recorded in
.out-of-scope/rate-provider-trait.md.The short version, taking the open questions in order:
source as a parameter, so the trait would have one implementation and no
caller.
that would implement it read differently:
desk.rate(pair)againstpast.rate(moment, pair). One signature does not cover both.for. The crate does no I/O, so an async feed fills an
Exchangeand the traitsits over the cache, one call short of the feed itself.
can. Neither answer can be checked against a real implementation yet.
Worth revisiting when a companion feed crate exists. Orphan rules make
lucrethe only crate that can define a trait such a feed and an application both name,
and at that point the shape has something real pushing on it.
Exchange::convertfails on a pair it could derive #47