Example #1
0
        public static async Task <long[]> GetNextSequencesAsync(this ISequenceSourceAsync seq, DynamoMetadataType meta, int noOfSequences)
        {
            var newCounter = await seq.IncrementAsync(meta, noOfSequences).ConfigAwait();

            var firstId = newCounter - noOfSequences + 1;
            var ids     = new long[noOfSequences];

            for (var i = 0; i < noOfSequences; i++)
            {
                ids[i] = firstId + i;
            }
            return(ids);
        }
Example #2
0
 public static async Task ResetAsync <T>(this ISequenceSourceAsync seq, int startingAt = 0, CancellationToken token = default)
 {
     var tableName = DynamoMetadata.GetType <T>().Name;
     await seq.ResetAsync(tableName, startingAt, token).ConfigAwait();
 }
Example #3
0
        public static async Task <long> IncrementAsync <T>(this ISequenceSourceAsync seq, int amount = 1, CancellationToken token = default)
        {
            var tableName = DynamoMetadata.GetType <T>().Name;

            return(await seq.IncrementAsync(tableName, amount, token).ConfigAwait());
        }
Example #4
0
 public static async Task <long> IncrementAsync(this ISequenceSourceAsync seq, DynamoMetadataType meta, int amount = 1,
                                                CancellationToken token = default)
 {
     return(await seq.IncrementAsync(meta.Name, amount, token).ConfigAwait());
 }
Example #5
0
 public static async Task <long[]> GetNextSequencesAsync <T>(this ISequenceSourceAsync seq, int noOfSequences, CancellationToken token = default)
 {
     return(await GetNextSequencesAsync(seq, DynamoMetadata.GetType <T>(), noOfSequences).ConfigAwait());
 }
Example #6
0
        public static async Task <long> CurrentAsync <T>(this ISequenceSourceAsync seq, CancellationToken token = default)
        {
            var tableName = DynamoMetadata.GetType <T>().Name;

            return(await seq.IncrementAsync(tableName, 0, token));
        }