Packages

ExRated, the OTP GenServer with the naughty name that allows you to rate-limit calls to any service that requires it. For example, rate-limit calls to your favorite API which requires no more than `limit` API calls within a `scale` milliseconds time window.

Current section

Files

Jump to
ex_rated lib utils.ex
Raw

lib/utils.ex

defmodule ExRated.Utils do
@moduledoc false
@doc """
Determines the current version of OTP running this node. The result is
cached for fast lookups in performance-sensitive functions.
## Example
iex> rel = ExRated.Utils.get_otp_release
...> '\#{rel}' == :erlang.system_info(:otp_release)
true
"""
def get_otp_release do
case Process.get(:current_otp_release) do
nil ->
case ("#{:erlang.system_info(:otp_release)}" |> Integer.parse) do
{ver, _} when is_integer(ver) ->
Process.put(:current_otp_release, ver)
ver
_ ->
end
ver -> ver
end
end
end