Implement swappable provider infrastructure #561

Closed
josefarias wants to merge 17 commits from jose/providers into main

17 Commits

Author SHA1 Message Date
Jose Farias
ae54f7a9be Remove unnecessary inheritance 2024-03-25 22:37:34 -06:00
Jose Farias
eb222a728f Decouple module names from being provided 2024-03-25 22:35:28 -06:00
Jose Farias
1bd5f545f0 Don't fetch on Money#exchange_to — fetch should be write only 2024-03-25 21:05:42 -06:00
Jose Farias
c49782ebfa Nix anemic abstractions
* The `Provided::<Concept>` classes were anemic. It's fine for the model to know how to call a provider that provides it directly.
It's also better to have the model instantiate domain objects.
And, finally, it makes more sense for the class making the HTTP requests to be aware of retries.

* The base implementations for provider methods were moved from `Provider::Base` to `Provider::Null`.
They were part of the base so that every provider responds to every providable method, which is unnecessary.
Let's be less defensive about it. Things will likely break with NoMethodError anyway in the edge case this was trying to guard against.

* Previously, when HTTP providers like Synth failed, they would raise. Now they return an inspectable response object of the same shape as when requests are successful, but it returns false for `#success?`. This is handy for debugging when you'll likely want to inspect the raw response. We can still raise on the Maybe side if needed. But that's a Maybe concern not a provider concern.

* `ExchangeRate#find_rate` doesn't raise anymore in preparation for opting into fetching — which should only happen on writes.
2024-03-25 20:59:00 -06:00
Jose Farias
fc1a0b361f real_estate_valuations -> real_estate_valuations_provider 2024-03-25 19:36:37 -06:00
Jose Farias
ef7ced2e4c Make providers aware of their env var as a fallback 2024-03-25 19:35:31 -06:00
Jose Farias
824dd10485 Add zillow to known providers 2024-03-24 22:23:46 -06:00
Jose Farias
d1ed066044 Scale the providers artificially 2024-03-24 21:43:56 -06:00
Jose Farias
20b3a2df89 Cosmetic changes 2024-03-24 20:37:02 -06:00
Jose Farias
60367ee8b7 fetch_exchange_rate -> fetch 2024-03-24 20:30:32 -06:00
Jose Farias
ad08e337ef Make naming uniform 2024-03-24 20:27:17 -06:00
Jose Farias
63b8683820 Turn Providable into a concern 2024-03-24 20:14:44 -06:00
Jose Farias
c6f1d99f75 local -> null
I think any local implementation will fall short and won't be useful.
Probably best to not try to support it at all.
2024-03-24 20:02:56 -06:00
Jose Farias
0b5f4af45c Ignore localhost in vcr 2024-03-24 19:49:18 -06:00
Jose Farias
11f2eab04c Fall back to SYNTH_API_KEY 2024-03-24 19:45:24 -06:00
Jose Farias
67c66b65e5 Use specific date so vcr always matches 2024-03-24 19:44:54 -06:00
Jose Farias
5ca1e3edee Implement providing missing exchange rates 2024-03-24 15:38:49 -06:00