1
0
mirror of https://github.com/mainflux/mainflux.git synced 2025-04-26 13:48:53 +08:00

Add disconnect on gen_server terminate() (#913)

Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
This commit is contained in:
Drasko DRASKOVIC 2019-10-27 17:57:43 +01:00 committed by GitHub
parent 7499f8deea
commit 613e75f7ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 6 deletions

View File

@ -88,6 +88,7 @@ handle_cast(_Request, State) ->
handle_info(_Info, State) ->
{noreply, State}.
terminate(_Reason, _State) ->
[].
terminate(Reason, #state{conn = GrpcConn} = State) ->
grpc_client:stop(GrpcConn),
{stop, Reason, State}.

View File

@ -49,8 +49,9 @@ handle_cast({publish, Subject, Message}, #state{conn = NatsConn} = State) ->
handle_info(_Info, State) ->
{noreply, State}.
terminate(_Reason, _State) ->
[].
terminate(Reason, #state{conn = NatsConn} = State) ->
nats:disconnect(NatsConn),
{stop, Reason, State}.
subscribe(NatsConn) ->
Subject = <<"channel.>">>,

View File

@ -42,5 +42,6 @@ handle_cast({publish, Message}, #state{conn = RedisConn} = State) ->
handle_info(_Info, State) ->
{noreply, State}.
terminate(_Reason, _State) ->
[].
terminate(Reason, #state{conn = RedisConn} = State) ->
eredis:stop(RedisConn),
{stop, Reason, State}.