Skip to content

Commit

Permalink
Properly handle price validator timeouts with catch
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanIvanoff committed Oct 14, 2024
1 parent e70b175 commit 8039910
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/sanbase/prices/validator/validator.ex
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,14 @@ defmodule Sanbase.Price.Validator do
@spec valid_price?(String.t(), String.t(), float()) :: true | {:error, String.t()}
def valid_price?(slug, quote_asset, price) when quote_asset in ["BTC", "USD"] do
GenServer.call(node_name(slug), {:valid_price?, slug, quote_asset, price}, 1000)

# The price validation is nice but not necessary. In case it times out,
# just ingest the price so it's not lost.
rescue
_ ->
# The price validation is nice but not necessary. In case it times out,
# just ingest the price so it's not lost.
true
_ -> true
catch
:exit, _ -> true
_ -> true
end

def slug_to_number(slug) do
Expand Down

0 comments on commit 8039910

Please sign in to comment.