Implement a strategy for using multiple geocoding APIs, including fallback mechanisms for unavailable APIs, bad results, or quota limits, and the ability to use different APIs for different query types or regions.
We need a way to effectively use multiple geocoding APIs. Situations that need to be handled: - The primary API is unavailable and we'd like to automatically fall back to another. - The primary API is returning bad/unexpected results (or quota is reached) and we'd like to automatically fall back to another. - We'd like to use different APIs for different queries, depending on whether the query is an IP address or a physical address, but also if the query is for a certain part of the world where one API is significantly better than another (eg: Yandex in Russia). Ideas for implementation: 1. Set :lookup to an array of preferred APIs (descending preference). 2. Set :lookup to a block which takes a query and returns a lookup name, or an array of names (as in #1). Need to determine: - How to "fall back" to a less-preferable API. On timeout? On any API-related exception? On any Geocoder exception? On a particular API response? On a `nil` result? And how configurable does it need to be? -