Karta.PublicSuffix.Refresh (Karta v1.0.0)

Fetches the Public Suffix List every day (an Oban cron job) from the URL the operator configures (config :karta, Karta.PublicSuffix, url:, set from KARTA_PUBLIC_SUFFIX_URL; by default https://publicsuffix.org/list/public_suffix_list.dat in production, none in development and tests), and keeps it in the database for every node (Karta.PublicSuffix.Fetched, used through Karta.PublicSuffix.load/0).

  • The request. GET the URL, with the tag of the copy Karta has (If-None-Match): 304 means it is current. No redirect is followed and nothing is retried (the next day's run is the retry); the whole answer must arrive within 60 seconds and be at most Karta.PublicSuffix.Rules.max_size/0 bytes.
  • The check. A 200 answer is used only when Karta.PublicSuffix.Rules.check/1 accepts it; the same list again changes nothing but the time.
  • Failures (an error, another status, a list that fails the check) are kept on the row with their time and logged; the copy before them stays in use, else the vendored list.

The URL comes from configuration only, never from a request.

Summary

Functions

Fetches the list once: {:ok, :updated} (a new copy, now in use on this node), {:ok, :unchanged}, {:error, :off} without a URL, or {:error, reason}. Options: url, req_options (extra Req options; tests use plug:) and now, each instead of the configuration's.

Functions

run(opts \\ [])

@spec run(keyword()) :: {:ok, :updated | :unchanged} | {:error, :off | String.t()}

Fetches the list once: {:ok, :updated} (a new copy, now in use on this node), {:ok, :unchanged}, {:error, :off} without a URL, or {:error, reason}. Options: url, req_options (extra Req options; tests use plug:) and now, each instead of the configuration's.