// Path: redis-storage/src/main/java/com/offbynull/actors/redisclient/SortedSetItem.java
// public final class SortedSetItem {
// 
//     private final double score;
//     private final Object item;
// 
//     /**
//      * Constructs a {@link SortedSetItem} object.
//      * @param score score
//      * @param item item
//      */
//     public SortedSetItem(double score, Object item) {
//         this.score = score;
//         this.item = item;
//     }
// 
//     /**
//      * Get score.
//      * @return score
//      */
//     public double getScore() {
//         return score;
//     }
// 
//     /**
//      * Get item.
//      * @param <T> expected type
//      * @return item
//      * @throws ClassCastException if expected type is not the type stored
//      */
//     public <T> T getItem() {
//         return (T) item;
//     }
// 
// }
// 
// Path: redis-storage/src/main/java/com/offbynull/actors/redisclient/Transaction.java
// public final class Transaction {
// 
//     private final TransactionBlock block;
//     private final boolean retry;
// 
//     /**
//      * Constructs a {@link Transaction} object.
//      * @param retry if {@code true}, transaction will be retried until it passes
//      * @param block block that defines queued transaction operations
//      * @throws NullPointerException if any argument is {@code null}
//      */
//     public Transaction(boolean retry, TransactionBlock block) {
//         Validate.notNull(block);
//         this.retry = retry;
//         this.block = block;
//     }
// 
//     /**
//      * Get retry flag.
//      * @return if {@code true}, transaction will be retried until it passes
//      */
//     public boolean isRetry() {
//         return retry;
//     }
// 
//     /**
//      * Get transaction block.
//      * @return block that defines queued transaction operations
//      */
//     public TransactionBlock getBlock() {
//         return block;
//     }
// 
// }


import com.offbynull.actors.address.Address;
import org.apache.commons.lang3.Validate;
import java.util.Collection;
import com.offbynull.actors.redisclient.Connection;
import com.offbynull.actors.redisclient.ConnectionException;
import com.offbynull.actors.redisclient.SortedSetItem;
import com.offbynull.actors.redisclient.Transaction;
import com.offbynull.actors.redisclient.TransactionResult;
import com.offbynull.actors.redisclient.Watch;
        //
        // long precisionLossTime = 1L << 53L;
        // Instant i = Instant.ofEpochMilli(precisionLossTime);
        // ZonedDateTime zdt = ZonedDateTime.ofInstant(i, ZoneId.systemDefault());
        // System.out.println(zdt);
        //
        // +287396-10-12T01:59:00.992-07:00[America/Los_Angeles]
        //
        //
        // Tests on redis-cli confirm this (tested on 64-bit Redis). 2^53 = 9007199254740992... when we use that as the score for a
        // member in a sorted set and get it back out, we get back the exact same score...
        // 127.0.0.1:6379> zadd ztest  9007199254740992 "a"
        // (integer) 1
        // 127.0.0.1:6379> zrange ztest 0 1000 WITHSCORES
        // 1) "a"
        // 2) "9007199254740992"
        //
        // When we use a larger number, we get back a score that has precision loss in the integer portion....
        // 127.0.0.1:6379> zadd ztest  99999007199254740992 "b"
        // (integer) 1
        // 127.0.0.1:6379> zrange ztest 0 1000 WITHSCORES
        // 1) "b"
        // 2) "9.9999007199254741e+19"
        //
        //
        // We can safely ignore the precision loss from the conversion to a double -- the year 287396 is too far off to care about.
    }
    
    // peek the timestamp of the next item in the inspection queue
    private long peekTimestamp() throws ConnectionException {
// Path: redis-storage/src/main/java/com/offbynull/actors/redisclient/SortedSetItem.java
// public final class SortedSetItem {
// 
//     private final double score;
//     private final Object item;
// 
//     /**
//      * Constructs a {@link SortedSetItem} object.
//      * @param score score
//      * @param item item
//      */
//     public SortedSetItem(double score, Object item) {
//         this.score = score;
//         this.item = item;
//     }
// 
//     /**
//      * Get score.
//      * @return score
//      */
//     public double getScore() {
//         return score;
//     }
// 
//     /**
//      * Get item.
//      * @param <T> expected type
//      * @return item
//      * @throws ClassCastException if expected type is not the type stored
//      */
//     public <T> T getItem() {
//         return (T) item;
//     }
// 
// }
// 
// Path: redis-storage/src/main/java/com/offbynull/actors/redisclient/Transaction.java
// public final class Transaction {
// 
//     private final TransactionBlock block;
//     private final boolean retry;
// 
//     /**
//      * Constructs a {@link Transaction} object.
//      * @param retry if {@code true}, transaction will be retried until it passes
//      * @param block block that defines queued transaction operations
//      * @throws NullPointerException if any argument is {@code null}
//      */
//     public Transaction(boolean retry, TransactionBlock block) {
//         Validate.notNull(block);
//         this.retry = retry;
//         this.block = block;
//     }
// 
//     /**
//      * Get retry flag.
//      * @return if {@code true}, transaction will be retried until it passes
//      */
//     public boolean isRetry() {
//         return retry;
//     }
// 
//     /**
//      * Get transaction block.
//      * @return block that defines queued transaction operations
//      */
//     public TransactionBlock getBlock() {
//         return block;
//     }
// 
// }


// Path: redis-storage/src/main/java/com/offbynull/actors/gateways/actor/stores/redis/TimestampQueue.java
import com.offbynull.actors.address.Address;
import org.apache.commons.lang3.Validate;
import java.util.Collection;
import com.offbynull.actors.redisclient.Connection;
import com.offbynull.actors.redisclient.ConnectionException;
import com.offbynull.actors.redisclient.SortedSetItem;
import com.offbynull.actors.redisclient.Transaction;
import com.offbynull.actors.redisclient.TransactionResult;
import com.offbynull.actors.redisclient.Watch;

        //
        // long precisionLossTime = 1L << 53L;
        // Instant i = Instant.ofEpochMilli(precisionLossTime);
        // ZonedDateTime zdt = ZonedDateTime.ofInstant(i, ZoneId.systemDefault());
        // System.out.println(zdt);
        //
        // +287396-10-12T01:59:00.992-07:00[America/Los_Angeles]
        //
        //
        // Tests on redis-cli confirm this (tested on 64-bit Redis). 2^53 = 9007199254740992... when we use that as the score for a
        // member in a sorted set and get it back out, we get back the exact same score...
        // 127.0.0.1:6379> zadd ztest  9007199254740992 "a"
        // (integer) 1
        // 127.0.0.1:6379> zrange ztest 0 1000 WITHSCORES
        // 1) "a"
        // 2) "9007199254740992"
        //
        // When we use a larger number, we get back a score that has precision loss in the integer portion....
        // 127.0.0.1:6379> zadd ztest  99999007199254740992 "b"
        // (integer) 1
        // 127.0.0.1:6379> zrange ztest 0 1000 WITHSCORES
        // 1) "b"
        // 2) "9.9999007199254741e+19"
        //
        //
        // We can safely ignore the precision loss from the conversion to a double -- the year 287396 is too far off to care about.
    }
    
    // peek the timestamp of the next item in the inspection queue
    private long peekTimestamp() throws ConnectionException {
        Collection<SortedSetItem> result = connection.zrangeWithScores(queueKey, 0L, 0L, ConversionUtils::byteArrayToString);