LG-8508: ArcGIS API: Use full URL paths instead of shared domain for greater flexibility#7777
Conversation
005eb26 to
b6a30a0
Compare
b6a30a0 to
84f5a58
Compare
app/services/arcgis_api/geocoder.rb
Outdated
There was a problem hiding this comment.
my comment might have gotten lost, but I think we can remove these constants and just inline usage of the configs (since we removed Figaro a long time ago, reading from the config is a very cheap struct property read)
There was a problem hiding this comment.
Oh right! Okay make sense.
I'll need to update how the mock works too, but that should be easy enough. Glad to get rid of some code...
…o they can be swapped for fallback services
84f5a58 to
b7a1963
Compare
3780e81 to
d314dfd
Compare
|
Just want to note an important step: When you switch over to another service, it'll still keep the old token from the previous service (naturally). In case of a failure, someone'll need to bust the cache manually. |
Could we include the domain as part of the cache key? |
Oh, interesting! I was thinking about just implementing the token retry on 401 approach we talked about a while back, but this could be quicker. So, this would be a dynamic cache keyname, right? Something like FULL_API_CACHE_TOKEN_KEY = "#{URI(SUGGEST_TOKEN_URL).host}}_API_TOKEN_CACHE_KEY"
# ...
Rails.cache.write(FULL_API_CACHE_TOKEN_KEY, token, expires_at: expires_at)? |
Yup exactly that! |
|
@zachmargolis love it!
Looking here, I saw some other conventions that could work better. I settled on:
🤷 |
🎫 Ticket
🛠 Summary of changes
This change uses fully qualified URL paths for each endpoint.
Before, we were using a single root URL and sharing it across paths. This works for GSA-hosted ArcGIS, but it doesn't work for ESRI-hosted (cloud) ArcGIS Online because the host domains are different for generateToken and the geocoding services (see https://developers.arcgis.com/rest/users-groups-and-items/root.htm and https://developers.arcgis.com/rest/geocode/api-reference/geocoding-suggest.htm — one uses a subdomain
arcgis, the other does not).After, this change would depend on fully-qualified URLs so that we can swap in an alternative ArcGIS service if needed.
📜 Testing Plan
Provide a checklist of steps to confirm the changes.