summaryrefslogtreecommitdiff
path: root/components/data_link_bert_rpc/src/connection.erl
diff options
context:
space:
mode:
Diffstat (limited to 'components/data_link_bert_rpc/src/connection.erl')
-rw-r--r--components/data_link_bert_rpc/src/connection.erl16
1 files changed, 16 insertions, 0 deletions
diff --git a/components/data_link_bert_rpc/src/connection.erl b/components/data_link_bert_rpc/src/connection.erl
index aec31a8..7fd63cb 100644
--- a/components/data_link_bert_rpc/src/connection.erl
+++ b/components/data_link_bert_rpc/src/connection.erl
@@ -28,6 +28,8 @@
-export([setup/6]).
-export([send/2]).
-export([send/3]).
+-export([is_connection_up/1]).
+-export([is_connection_up/2]).
-export([terminate_connection/1]).
-export([terminate_connection/2]).
@@ -84,6 +86,19 @@ terminate_connection(IP, Port) ->
_Err -> {error, connection_not_found}
end.
+
+is_connection_up(Pid) when is_pid(Pid) ->
+ is_process_alive(Pid).
+
+is_connection_up(IP, Port) ->
+ case connection_manager:find_connection_by_address(IP, Port) of
+ {ok, Pid} ->
+ is_connection_up(Pid);
+
+ _Err ->
+ false
+ end.
+
%%%===================================================================
%%% gen_server callbacks
%%%===================================================================
@@ -169,6 +184,7 @@ handle_cast({send, Data}, St) ->
[ ?MODULE, Data]),
gen_tcp:send(St#st.sock, term_to_binary(Data)),
+
{noreply, St};
handle_cast(_Msg, State) ->