@@ -45,31 +45,29 @@ defmodule Core.Domain.Invoker do
4545 def invoke ( ivk_pars ) do
4646 Logger . info ( "Invoker: invocation for #{ ivk_pars . module } /#{ ivk_pars . function } requested" )
4747
48- # could be {:error, :no_workers}
49- with { :ok , worker } <- Nodes . worker_nodes ( ) |> Scheduler . select ( ) do
50- case invoke_without_code ( worker , ivk_pars ) do
51- { :error , :code_not_found } ->
52- worker
53- |> invoke_with_code ( ivk_pars )
54- |> save_to_sinks ( ivk_pars . module , ivk_pars . function )
55-
56- res ->
57- save_to_sinks ( res , ivk_pars . module , ivk_pars . function )
48+ if Functions . exists_in_mod? ( ivk_pars . function , ivk_pars . module ) do
49+ with { :ok , worker } <- Nodes . worker_nodes ( ) |> Scheduler . select ( ) do
50+ case invoke_without_code ( worker , ivk_pars ) do
51+ { :error , :code_not_found } ->
52+ worker
53+ |> invoke_with_code ( ivk_pars )
54+ |> save_to_sinks ( ivk_pars . module , ivk_pars . function )
55+
56+ res ->
57+ save_to_sinks ( res , ivk_pars . module , ivk_pars . function )
58+ end
5859 end
60+ else
61+ { :error , :not_found }
5962 end
6063 end
6164
6265 @ spec invoke_without_code ( atom ( ) , InvokeParams . t ( ) ) ::
6366 { :ok , InvokeResult . t ( ) } | { :error , :code_not_found } | invoke_errors ( )
6467 def invoke_without_code ( worker , ivk ) do
6568 Logger . debug ( "Invoker: invoking #{ ivk . module } /#{ ivk . function } without code" )
66-
67- if Functions . exists_in_mod? ( ivk . function , ivk . module ) do
68- # send invocation without code
69- Commands . send_invoke ( worker , ivk . function , ivk . module , ivk . args )
70- else
71- { :error , :not_found }
72- end
69+ # send invocation without code
70+ Commands . send_invoke ( worker , ivk . function , ivk . module , ivk . args )
7371 end
7472
7573 @ spec invoke_with_code ( atom ( ) , InvokeParams . t ( ) ) ::
0 commit comments