Skip to content

Commit

Permalink
Add ability to pass callback to wrek_vert:exec
Browse files Browse the repository at this point in the history
  • Loading branch information
rkallos committed Jan 8, 2019
1 parent 941dc84 commit ee3e6d7
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/wrek_vert.erl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
-export([
exec/3,
exec/4,
exec/5,
get/3,
get/4,
get_all/1,
Expand Down Expand Up @@ -47,6 +48,13 @@ exec(Pid, Dir0, Cmd0, Env) ->
gen_server:call(Pid, {exec, Dir0, Cmd0, Env}).


-spec exec(pid(), file:filename_all(), string(), list(), fun((any()) -> any())) ->
fun(() -> ok | {error, any()}).

exec(Pid, Dir0, Cmd0, Env, EventFun) ->
gen_server:call(Pid, {exec, Dir0, Cmd0, Env, EventFun}).


-spec get(pid(), any(), any()) -> any().

get(Pid, Who, Key) ->
Expand Down Expand Up @@ -101,6 +109,10 @@ handle_call({exec, Dir, Cmd, Env}, _From, State = #state{event_mgr = EvMgr}) ->
Result = fun() -> wrek_exec:exec(Dir, Cmd, Env, EventFun) end,
{reply, Result, State};

handle_call({exec, Dir, Cmd, Env, EventFun}, _From, State) ->
Result = fun() -> wrek_exec:exec(Dir, Cmd, Env, EventFun) end,
{reply, Result, State};

handle_call({get, Who0, Key, Default}, _From, State) ->
Who = case Who0 of
me -> name(State);
Expand Down

0 comments on commit ee3e6d7

Please sign in to comment.