<commit_before>/*
 * Free software licenced under 
 * GNU AFFERO GENERAL PUBLIC LICENSE
 * 
 * Check for document LICENCE forfull licence text
 * 
 * <NAME>
 */


part of redis;

class RedisConnection{
  Socket _socket = null;
  LazyStream _stream = null;
  Future _future = new Future.value();
  
  Future connect(host, port){
    return Socket.connect(host, port)
    .then((Socket sock){
      _socket = sock;
      disable_nagle(true);
      _stream =new LazyStreamFast.fromstream(_socket);
      return new Command(this);
    });
  }
  
  Future close(){
    return _socket.close();
  }

  //this doesnt send anything
  //it just wait something to come from socket
  //it parse it and execute future
  Future senddummy(){
    Completer completer = new Completer.sync();
    _future = _future.then((_) =>
        RedisParser.parseredisresponse(_stream)
        .then((v) => completer.complete(v))
    );
    return completer.future;
  }
  
  Future sendraw(List data){
    _socket.add(data);
    return senddummy();
  }
  
  Future send(object){
    var s = RedisSerialise.Serialise(object);
    return sendraw(s);
  }
  
  void disable_nagle(bool v){
    _socket.setOption(SocketOption.TCP_NODELAY,v);
  }

}<commit_msg>connection move public to private<commit_after>/*
 * Free software licenced under 
 * GNU AFFERO GENERAL PUBLIC LICENSE
 * 
 * Check for document LICENCE forfull licence text
 * 
 * <NAME>
 */


part of redis;

/// Class for server connection on server
class RedisConnection{
  Socket _socket = null;
  LazyStream _stream = null;
  Future _future = new Future.value();
  
  /// connect on Redis server as client
  Future<Command> connect(host, port){
    return Socket.connect(host, port)
    .then((Socket sock){
      _socket = sock;
      disable_nagle(true);
      _stream =new LazyStreamFast.fromstream(_socket);
      return new Command(this);
    });
  }
  
  Future close(){
    return _socket.close();
  }

  //this doesnt send anything
  //it just wait something to come from socket
  //it parse it and execute future
  Future _senddummy(){
    Completer completer = new Completer.sync();
    _future = _future.then((_) =>
        RedisParser.parseredisresponse(_stream)
        .then((v) => completer.complete(v))
    );
    return completer.future;
  }
  
  // return future that complets
  // when all prevous futures finished
  Future _getdummy(){
    Completer completer = new Completer.sync();
    _future = _future.then((_){
        completer.complete("dummy data");
      }
    );
    return completer.future;
  }
  
  Future _sendraw(List data){
    _socket.add(data);
    return _senddummy();
  }
  
  Future _send(object){
    var s = RedisSerialise.Serialise(object);
    return _sendraw(s);
  }
  
  void disable_nagle(bool v){
    _socket.setOption(SocketOption.TCP_NODELAY,v);
  }

}
{'fraction_non_alphanumeric': 0.11013060360042358, 'fraction_numerical': 0.0, 'mean_word_length': 2.947075208913649, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5353000', 'n_tokens_mistral': 923, 'n_tokens_neox': 897, 'n_words': 241}