anchor.diff:  %% @end
   %%--------------------------------------------------------------------
   -spec gateway_loop(State :: #{atom() => term()}) -> no_return().
  -gateway_loop(#{port_fd := PortFD, id := {_, N} = ID, db_hostname := Hostname, db_port := Port} = State) ->
  +gateway_loop(#{port_fd := PortFD, id := {_, N} = ID, db_hostname := Hostname, db_port := Port, start_time := ST } = State) ->
       try port_command(PortFD, <<"ping">>) of
           true -> ok
       catch
  
positive.code: delete(#model_config{bucket = Bucket, name = ModelName} = ModelConfig, Key, Pred) ->
      datastore:run_synchronized(ModelName, to_binary({?MODULE, Key}),
          fun() ->
              {ok, DB} = get_db(),
              
              case Pred() of
                  true ->
                      case get(ModelConfig, Key) of
  
negative.code:             {port_comm_error, Reason} ->
                  ?error("[CouchBase Gateway ~p] Unable to communicate with port due to: ~p", [ID, Reason]),
                  State#{status => failed};
              restart when CT > MinRestartTime ->
                  State#{status => restarting};
              restart ->
                  State;
              Other ->
                  ?warning("[CouchBase Gateway ~p] ~p", [ID, Other]),
                  State
          after timer:seconds(1) ->
              State
          end,
      case NewState of
          #{status := running} ->
              gateway_loop(NewState);
          #{status := closed} ->
              ok;
          #{status := restarting} ->
              catch port_close(PortFD),
              start_gateway(self(), N, Hostname, Port);
          #{status := failed} ->
              catch port_close(PortFD),
              start_gateway(self(), N, Hostname, Port)
      end.
  
  