Expression.V2.Compat (expression v2.41.4)

Compatibility module to make the transition from V1 to V2 a bit easier, hopefully.

It does a few things:

  • It swaps out V2 callbacks for V1 callbacks when evaluating expressions with V1.
  • It does some patching of the context to match V1's assumptions:
    • case insensitive context keys
    • casting of integers
    • casting of datetimes
  • It compares the output of V1 to V2, if those aren't equal it will log an error and return the V1 response.
  • If there is no error it will return the value from V2.

NOTE: This module does twice the work because it runs V1 and V2 sequentially and then compares the result before returning a value.

NOTE: This was throwing more errors in prod than anticipated, hacking in a revert temporarily

Summary

Functions

attempt_boolean(binary)

attempt_datetime(binary)

attempt_float(binary)

attempt_integer(binary)

evaluate!(expression, context \\ %{}, callback_module \\ Expression.Callbacks.Standard)

evaluate_as_string!(expression, context, callback_module \\ Expression.Callbacks.Standard)

evaluate_block!(expression, context \\ %{}, callback_module \\ Callbacks.Standard, opts \\ [])

log_error(expression, context, v1_resp, v2_resp)

normalize_value(datetime)

patch_v1_context(datetime)

patch_v1_key(key)

return_or_raise(expression, context, v1_resp, v2_resp)

return_or_raise_binaries(expression, context, v1_resp, v2_resp)

unpack_returned_value(other)