Esempio n. 1
0
        public async Task CheckpointStoreBasicTest()
        {
            ICheckpointStore checkpointStore = CheckpointStore.Create(new StoreProvider(new InMemoryDbStoreProvider()));

            for (long i = 0; i < 10; i++)
            {
                var checkpointData = new CheckpointData(i);
                await checkpointStore.SetCheckpointDataAsync($"Endpoint{i}", checkpointData, CancellationToken.None);
            }

            IDictionary <string, CheckpointData> allCheckpointData = await checkpointStore.GetAllCheckpointDataAsync(CancellationToken.None);

            Assert.Equal(10, allCheckpointData.Count);
            long counter = 0;

            foreach (KeyValuePair <string, CheckpointData> checkpointValue in allCheckpointData)
            {
                Assert.Equal(counter, checkpointValue.Value.Offset);
                Assert.Equal($"Endpoint{counter}", checkpointValue.Key);
                counter++;
            }

            for (long i = 0; i < 10; i++)
            {
                CheckpointData checkpointData = await checkpointStore.GetCheckpointDataAsync($"Endpoint{i}", CancellationToken.None);

                Assert.NotNull(checkpointData);
                Assert.Equal(i, checkpointData.Offset);
            }
        }
Esempio n. 2
0
        public static async Task <Checkpointer> CreateAsync(string id, ICheckpointStore store)
        {
            Preconditions.CheckNotNull(id);
            Preconditions.CheckNotNull(store);

            Events.CreateStart(id);
            CheckpointData checkpointData = await store.GetCheckpointDataAsync(id, CancellationToken.None);

            var checkpointer = new Checkpointer(id, store, checkpointData);

            Events.CreateFinished(checkpointer);
            return(checkpointer);
        }
Esempio n. 3
0
        public static async Task <MasterCheckpointer> CreateAsync(string id, ICheckpointStore store)
        {
            Preconditions.CheckNotNull(id);
            Preconditions.CheckNotNull(store);

            Events.CreateStart(id);

            CheckpointData checkpointData = await store.GetCheckpointDataAsync(id, CancellationToken.None);

            long offset             = checkpointData.Offset;
            var  masterCheckpointer = new MasterCheckpointer(id, store, offset);

            Events.CreateFinished(masterCheckpointer);

            return(masterCheckpointer);
        }