Esempio n. 1
0
        /// <summary>
        /// Claim the next batch of sequence numbers for publishing.
        /// </summary>
        /// <param name="batchDescriptor">batchDescriptor to be updated for the batch range.</param>
        /// <returns>the updated batchDescriptor.</returns>
        public BatchDescriptor Next(BatchDescriptor batchDescriptor)
        {
            if (_gatingSequences == null)
            {
                throw new NullReferenceException("gatingSequences must be set before claiming sequences");
            }

            long sequence = _claimStrategy.IncrementAndGet(batchDescriptor.Size, _gatingSequences);

            batchDescriptor.End = sequence;
            return(batchDescriptor);
        }
Esempio n. 2
0
 /// <summary>
 /// Publish the batch of events in sequence.
 /// </summary>
 /// <param name="batchDescriptor">batchDescriptor to be published.</param>
 public void Publish(BatchDescriptor batchDescriptor)
 {
     Publish(batchDescriptor.End, batchDescriptor.Size);
 }
Esempio n. 3
0
        /// <summary>
        /// Claim the next batch of sequence numbers for publishing with a timeout.
        /// If the timeout occurs the sequence will not be claimed and a <see cref="TimeoutException"/> will be thrown.
        ///
        /// </summary>
        /// <param name="batchDescriptor">batchDescriptor to be updated for the batch range.</param>
        /// <param name="timeout">timeout period to wait</param>
        /// <returns>the updated batchDescriptor.</returns>
        public BatchDescriptor Next(BatchDescriptor batchDescriptor, TimeSpan timeout)
        {
            WaitForCapacity(batchDescriptor.Size, timeout);

            return(Next(batchDescriptor));
        }
Esempio n. 4
0
 /// <summary>
 /// Publish the batch of events in sequence.
 /// </summary>
 /// <param name="batchDescriptor">batchDescriptor to be published.</param>
 public void Publish(BatchDescriptor batchDescriptor)
 {
     Publish(batchDescriptor.End, batchDescriptor.Size);
 }
Esempio n. 5
0
        /// <summary>
        /// Claim the next batch of sequence numbers for publishing with a timeout.
        /// If the timeout occurs the sequence will not be claimed and a <see cref="TimeoutException"/> will be thrown.
        /// 
        /// </summary>
        /// <param name="batchDescriptor">batchDescriptor to be updated for the batch range.</param>
        /// <param name="timeout">timeout period to wait</param>
        /// <returns>the updated batchDescriptor.</returns>
        public BatchDescriptor Next(BatchDescriptor batchDescriptor, TimeSpan timeout)
        {
            WaitForCapacity(batchDescriptor.Size, timeout);

            return Next(batchDescriptor);
        }
Esempio n. 6
0
        /// <summary>
        /// Claim the next batch of sequence numbers for publishing.
        /// </summary>
        /// <param name="batchDescriptor">batchDescriptor to be updated for the batch range.</param>
        /// <returns>the updated batchDescriptor.</returns>
        public BatchDescriptor Next(BatchDescriptor batchDescriptor)
        {
            if (_gatingSequences == null)
            {
                throw new NullReferenceException("gatingSequences must be set before claiming sequences");
            }

            long sequence = _claimStrategy.IncrementAndGet(batchDescriptor.Size, _gatingSequences);
            batchDescriptor.End = sequence;
            return batchDescriptor;
        }