                 client.end()
                 client.removeAllListeners()
         delete @_clients
+
+    is_connected: () =>
+        return @_clients? and @_clients.length > 0
 
     _connect: (cb) =>
         dbg = @_dbg("_do_connect")


    __do_query: (opts) =>
        dbg = @_dbg("_query('#{opts.query}',id='#{misc.uuid().slice(0,6)}')")
        if not @_clients?
            # TODO: should also check that client is connected.
            opts.cb?("client not yet initialized")
            return

            @_query_retry_until_success(opts)
            return

        if not @is_connected()
            dbg = @_dbg("_query")
            dbg("connecting first...")
            @connect
