async Task <ISequentialStore <Item> > GetSequentialStore(string entityName)
        {
            IEntityStore <byte[], Item> entityStore     = this.GetEntityStore <Item>(entityName);
            ISequentialStore <Item>     sequentialStore = await SequentialStore <Item> .Create(entityStore);

            return(sequentialStore);
        }
示例#2
0
        public async Task CreateWithOffsetTest()
        {
            IEntityStore <byte[], Item> entityStore     = this.GetEntityStore <Item>($"testEntity{Guid.NewGuid().ToString()}");
            ISequentialStore <Item>     sequentialStore = await SequentialStore <Item> .Create(entityStore, 10150);

            long offset = await sequentialStore.Append(new Item { Prop1 = 10 });

            Assert.Equal(10150, offset);

            sequentialStore = await SequentialStore <Item> .Create(entityStore);

            for (int i = 0; i < 10; i++)
            {
                offset = await sequentialStore.Append(new Item { Prop1 = 20 });

                Assert.Equal(10151 + i, offset);
            }

            sequentialStore = await SequentialStore <Item> .Create(entityStore);

            offset = await sequentialStore.Append(new Item { Prop1 = 20 });

            Assert.Equal(10161, offset);

            IList <(long, Item)> batch = (await sequentialStore.GetBatch(0, 100)).ToList();

            Assert.Equal(12, batch.Count);
            long expectedOffset = 10150;

            foreach ((long itemOffset, Item _) in batch)
            {
                Assert.Equal(itemOffset, expectedOffset++);
            }
        }
示例#3
0
        async Task <ISequentialStore <Item> > GetSequentialStore(string entityName, Option <long> defaultHeadOffset)
        {
            IEntityStore <byte[], Item> entityStore     = this.GetEntityStore <Item>(entityName);
            ISequentialStore <Item>     sequentialStore = await defaultHeadOffset
                                                          .Map(d => SequentialStore <Item> .Create(entityStore, d))
                                                          .GetOrElse(() => SequentialStore <Item> .Create(entityStore));

            return(sequentialStore);
        }
        public async Task CreateTest()
        {
            IEntityStore <byte[], Item> entityStore     = this.GetEntityStore <Item>("testEntity");
            ISequentialStore <Item>     sequentialStore = await SequentialStore <Item> .Create(entityStore);

            long offset = await sequentialStore.Append(new Item { Prop1 = 10 });

            Assert.Equal(0, offset);

            sequentialStore = await SequentialStore <Item> .Create(entityStore);

            offset = await sequentialStore.Append(new Item { Prop1 = 20 });

            Assert.Equal(1, offset);
        }
示例#5
0
        public async Task CreateTest()
        {
            string entityName = $"testEntity{Guid.NewGuid().ToString()}";
            IEntityStore <byte[], Item> entityStore     = this.GetEntityStore <Item>(entityName);
            ISequentialStore <Item>     sequentialStore = await SequentialStore <Item> .Create(entityStore, entityName);

            long offset = await sequentialStore.Append(new Item { Prop1 = 10 });

            Assert.Equal(0, offset);

            sequentialStore = await SequentialStore <Item> .Create(entityStore, entityName);

            offset = await sequentialStore.Append(new Item { Prop1 = 20 });

            Assert.Equal(1, offset);
        }