gresrun / jesque

An implementation of Resque in Java.
http://gresrun.github.io/jesque
Apache License 2.0
630 stars 131 forks source link

Redis username configuration #67

Closed dwilkie closed 9 years ago

dwilkie commented 9 years ago

I'm using RedisToGo and the Redis URL that I need to connect to is of the form:

redis://user:password@subdomain.redistogo.com:9259/

I can see that the ConfigBuilder accepts a withPort, withHost and withPassword but it does not provide a withUser.

FYI have the following code to extract the details from the REDIS_PROVIDER_URL (compatible with Sidekiq)

    final ConfigBuilder configBuilder = new ConfigBuilder();

    try {
      URI redisUrl = new URI(System.getProperty("REDIS_PROVIDER", "127.0.0.1"));

      String redisHost = redisUrl.getHost();
      int redisPort = redisUrl.getPort();
      String redisUserInfo = redisUrl.getUserInfo();

      if (redisHost != null) {
        configBuilder.withHost(redisHost);
      }

      if (redisPort > -1) {
        configBuilder.withPort(redisPort);
      }

      if (redisUserInfo != null) {
        configBuilder.withPassword(redisUserInfo);
      }

      // need to split the UserInfo into username and password here and set it with:
      // configBuilder.withUser(); and  configBuilder.withUser();
    }
    catch (URISyntaxException e) {
      System.err.println(e.toString());
      System.exit(1);
    }

    final Config config = configBuilder.build();
gresrun commented 9 years ago

Redis doesn't support usernames, it only supports passwords It looks like you only use the password, according to this RedisToGo support page. (NOTE: Jesque uses Jedis to connect to Redis)