Skip to content

Commit

Permalink
Merge pull request #26 from emqx/do_connect_after_start
Browse files Browse the repository at this point in the history
chore: connect to gRPC server when starting the grpc_client
  • Loading branch information
terry-xiaoyu authored Oct 20, 2023
2 parents 252a930 + b406879 commit 189cb21
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/client/grpc_client.erl
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
, handle_call/3
, handle_cast/2
, handle_info/2
, handle_continue/2
, terminate/2
, code_change/3
]).
Expand Down Expand Up @@ -263,7 +264,16 @@ init([Pool, Id, Server = {_, _, _}, ClientOpts0]) ->
server = Server,
encoding = Encoding,
streams = #{},
client_opts = Opts})}.
client_opts = Opts}), {continue, connect}}.

handle_continue(connect, State) ->
case do_connect(State) of
{error, Reason} ->
logger:error("[grpc_client] connect to ~p failed: ~p", [State#state.server, Reason]),
{noreply, State};
NState ->
{noreply, NState}
end.

handle_call(Req, From, State = #state{gun_pid = undefined}) ->
case do_connect(State) of
Expand Down

0 comments on commit 189cb21

Please sign in to comment.