package redis.client;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import com.google.common.base.Charsets;
import com.google.common.util.concurrent.ListenableFuture;

import redis.Command;
import redis.reply.BulkReply;
import redis.reply.IntegerReply;
import redis.reply.MultiBulkReply;
import redis.reply.Reply;
import redis.reply.StatusReply;

public class RedisClient extends RedisClientBase {
  protected Pipeline pipeline = new Pipeline();

  public RedisClient(String host, int port) throws IOException {
    this(host, port, Executors.newSingleThreadExecutor());
  }

  public RedisClient(String host, int port, ExecutorService es) throws IOException {
    super(host, port, es);
  }

  public Pipeline pipeline() {
    return pipeline;
  }
  {{#commands}}
  
  private static final String {{name}} = "{{name1}}";
  {{#split_command}}
  private static final String {{name}}2 = "{{name2}}";
  private static final byte[] {{name}}2_BYTES = {{name}}2.getBytes(Charsets.US_ASCII);
  {{/split_command}}
  private static final byte[] {{name}}_BYTES = {{name}}.getBytes(Charsets.US_ASCII);
  private static final int {{name}}_VERSION = parseVersion("{{version}}");

  {{<method}}
  {{$method}}execute{{/method}}
  {{/method}}
  {{/commands}}

  public class Pipeline {
    {{#commands}}

    {{<method}}
      {{$return}}ListenableFuture<{{reply}}>{{/return}}
      {{$method}}pipeline{{/method}}
    {{/method}}
    {{/commands}}
  }
}
