|
|
Geocoder.configure(
|
|
|
# IP-address geolocation, used by ResolvePlayerCountryJob to tag each player
|
|
|
# with the country they played from.
|
|
|
#
|
|
|
# The credential is an **IPinfo Lite** token, so we use the Lite lookup: that
|
|
|
# is the endpoint the token is issued for (api.ipinfo.io/lite), and it is free
|
|
|
# and unmetered. It returns country + ASN only -- no city, no coordinates --
|
|
|
# which is all we need, since the job only reads `country_code`.
|
|
|
#
|
|
|
# Pointing this at :ipinfo_io instead still "works" (the token is accepted on
|
|
|
# ipinfo.io/<ip>/geo) but bills against the metered standard API, so a busy
|
|
|
# day can start returning 429s -- which are swallowed below and silently cost
|
|
|
# us a player's country. For a no-rate-limit / offline setup, swap in MaxMind
|
|
|
# GeoLite2 (ip_lookup: :geoip2 + the .mmdb file).
|
|
|
ip_lookup: :ipinfo_io_lite,
|
|
|
ipinfo_io_lite: { api_key: Rails.application.credentials.ipinfo_token.presence },
|
|
|
|
|
|
# A slow or unreachable geo service must never hold up the start of the game.
|
|
|
timeout: 2,
|
|
|
always_raise: [], # swallow lookup errors -> request.location returns nil
|
|
|
|
|
|
# Employees behind the same office gateway share an egress IP, so cache each
|
|
|
# lookup and reuse it instead of hammering the API once per player.
|
|
|
cache: Rails.cache,
|
|
|
cache_options: { expiration: 1.day }
|
|
|
)
|