@@ -0,0 +1,2045 @@
+package com.zachpendleton.sidekiq.reporter;%0A%0Aimport org.apache.log4j.Logger;%0Aimport redis.clients.jedis.Jedis;%0A%0A/**%0A * A Sidekiq queue with a name and a length.%0A */%0Apublic class SidekiqQueue %7B%0A    private static final Logger logger = Logger.getLogger(SidekiqQueue.class);%0A%0A    private Jedis connection;%0A%0A    private final String name;%0A%0A    SidekiqQueue(String name) %7B%0A        this.name = name;%0A    %7D%0A%0A    /**%0A     * Connect to the Redis server hosting this queue.%0A     *%0A     * @param host the hostname of the Redis server%0A     * @param port the port the Redis server is listening on%0A     *%0A     * @return success boolean%0A     */%0A    public boolean connect(String host, int port) %7B%0A        return connect(host, port, 0);%0A    %7D%0A%0A    /**%0A     * Connect to the Redis server hosting this queue.%0A     *%0A     * @param host the hostname of the Redis server%0A     * @param port the port the Redis server is listening on%0A     * @param databaseId the database ID containing Sidekiq information%0A     *%0A     * @return success boolean%0A     */%0A    public boolean connect(String host, int port, int databaseId) %7B%0A        connection = new Jedis(host, port);%0A%0A        if (connection.isConnected()) %7B%0A            connection.select(databaseId);%0A        %7D%0A%0A        return connection.isConnected();%0A    %7D%0A%0A    /**%0A     * Disconnect from the Redis server.%0A     */%0A    public void disconnect() %7B%0A        if (connection != null && connection.isConnected()) %7B%0A            connection.disconnect();%0A        %7D%0A    %7D%0A%0A    /**%0A     * Fetch the queue size from the Redis server.%0A     *%0A     * @return the size of the queue%0A     */%0A    public long getSize() %7B%0A        if (connection == null %7C%7C !connection.isConnected()) %7B%0A            logger.warn(%22attempted to access queue '%22 + queueKey() + %22' without connecting to redis%22);%0A            return 0;%0A        %7D%0A%0A        return connection.llen(queueKey());%0A    %7D%0A%0A    /**%0A     * Construct the Redis key for this queue.%0A     *%0A     * @return a key name%0A     */%0A    private String queueKey() %7B%0A        return %22queue:%22 + name;%0A    %7D%0A%7D%0A

add sidekiq queue domain object