在金融科技领域,我们经常不得不处理大量的货币汇率数据。我们从不同的来源获取数据,每个人都有自己的想法,如何推断明天,后天,下个月,甚至未来三年的汇率。如果有人知道如何正确预测课程,关闭业务并愚蠢地换钱是正确的。有些资料来源更值得信赖,有些资料完全是垃圾,很少有包含几乎正确值的杂物,但对于异国情侣。我们的工作是每秒筛选这些成千上万的价值并确定向客户展示什么。我们需要从大量的灰尘和淤泥中过滤出唯一正确的值,就像火烈鸟在晚餐时一样。

火烈鸟的一大特色是大而弯曲的喙,借助它们可以过滤掉水或淤泥中的食物。
- 维基
Vela, . , N ( , ).
, . Vela - :
defmodule Pairs do
use Vela,
eurusd: [sorter: &Kernel.<=/2],
eurgbp: [limit: 3, errors: 1],
eurcad: [validator: Pairs]
@behaviour Vela.Validator
@impl Vela.Validator
def valid?(:eurcad, rate), do: rate > 0
end
-
validator, (. ); - , ,
:__errors__; -
sorter, (LIFO, . ); -
:limit; -
Vela.
iex|1 > pairs = %Pairs{}
iex|2 > Vela.put(pairs, :eurcad, 1.0)
#⇒ %Pairs{..., eurcad: [1.0], ...}
iex|3 > Vela.put(pairs, :eurcad, -1.0)
#⇒ %Pairs{__errors__: [eurcad: -1.0], ...}
iex|4 > pairs |> Vela.put(:eurusd, 2.0) |> Vela.put(:eurusd, 1.0)
#⇒ %Pairs{... eurusd: [1.0, 2.0]}
Vela Access, Kernel: Kernel.get_in/2, Kernel.put_in/3, Kernel.update_in/3, Kernel.pop_in/2, and Kernel.get_and_update_in/3.
:
- (
&MyMod.my_fun/1), ; - ,
&MyMod.my_fun/2,serie, value; - ,
Vela.Validator; -
threshold, — —compare_by, . Comparison .
, , {serie, value} :__errors_.
, , . Vela , compare_by ( Kernel.</2); (Vela.value() -> number()). & &1.
, comparator (min/max); , Date.diff/2 , .
threshold, {min, max} . , comparator, compare_by. , , compare_by: &DateTime.to_unix/1 ( ) threshold: 1, , ±band .
, Vela.equal?/2 . equal?/2 compare/2, , ==/2.
Vela.purge/1, ( validator timestamps). Vela.slice/1, keyword , .
get_in/2/pop_in/2 .
Vela GenServer/Agent. , , Vela, , .
@impl Vela.Validator
def valid?(_key, %Rate{} = rate),
do: Rate.age(rate) < @death_age
Vela.purge/1 , . Vela.slice/1, ( ), — — .
!