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:
parent
7499f8deea
commit
613e75f7ee
@ -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}.
|
||||
|
||||
|
@ -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.>">>,
|
||||
|
@ -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}.
|
||||
|
Loading…
x
Reference in New Issue
Block a user