Example #1
0
        public void Restore()
        {
            var restoreEnumerator = persistentStorage.Restore().GetEnumerator();

            if (!restoreEnumerator.MoveNext())
            {
                persistedMessageId = lastMessageId = -1;
                data = new InfiniteArray <Message>(0, dataArrayOptions);
                RestoreSubscriptions();
                return;
            }

            data = new InfiniteArray <Message>(restoreEnumerator.Current.ID, dataArrayOptions);
            data.Add(restoreEnumerator.Current);

            while (restoreEnumerator.MoveNext())
            {
                data.Add(restoreEnumerator.Current);
            }

            currentData = new DataSnapshot()
            {
                StartMessageId = data.GetFirstItemIndex(),
                Data           = data.GetDataBlocks()
            };

            persistedMessageId = lastMessageId = currentData.Data[^ 1].Span[^ 1].ID;
Example #2
0
 internal TopicWriter(Topic topic, Func <PublisherAck, CancellationToken, Task> ackHandler, TopicWriterOptions topicWriterOptions)
 {
     this.topic      = topic;
     this.ackHandler = ackHandler;
     confirmationIntervalMilliseconds = topicWriterOptions.ConfirmationIntervalMilliseconds;
     lastAckedMessageId      = -1;
     cancellationTokenSource = new CancellationTokenSource();
     idMap = new InfiniteArray <IdPair>(0, new InfiniteArrayOptions
     {
         MinimumFreeBlocks = 4,
         DataListCapacity  = 128,
         BlockLength       = 10000
     });
 }