Esempio n. 1
0
        public async Task create_stream()
        {
            var stream = _streams.Open("stream_1");
            await stream.AppendAsync("payload");

            var acc = new Recorder();
            await Store.ReadForwardAsync("stream_1", 0, acc);

            Assert.Equal(1, acc.Length);
            Assert.Equal("payload", acc[0].Payload);
        }
Esempio n. 2
0
        public void open_should_return_stream()
        {
            var stream = _store.Open("id");

            Assert.IsType <Stream>(stream);
            Assert.True(stream.IsWritable);
        }
Esempio n. 3
0
        public async Task is_empty()
        {
            var stream = _streams.Open("brand_new_stream");

            Assert.True(await stream.IsEmpty());

            await stream.AppendAsync("a");

            Assert.False(await stream.IsEmpty());
        }
Esempio n. 4
0
        public async Task WriteSequentialStream(int writes)
        {
            var stream   = _streams.Open("visits");
            var progress = new ProgressBar(40);

            progress.Report(0);

            int written = 0;

            async Task Write(int c)
            {
                await stream.AppendAsync(c, c.ToString()).ConfigureAwait(false);

                Interlocked.Increment(ref written);
                // ReSharper disable once AccessToDisposedClosure
                progress.Report((double)written / writes);
            }

            var worker = new ActionBlock <int>(Write, _unboundedOptions);

            var sw = new Stopwatch();

            sw.Start();

            for (int c = 1; c <= writes; c++)
            {
                await worker.SendAsync(c);
            }

            worker.Complete();
            await worker.Completion;

            sw.Stop();

            progress.Dispose();

            _reporter.Report($"Written {writes} in {sw.ElapsedMilliseconds}ms (batch time)");
        }
Esempio n. 5
0
 public Task PushAsync(string views, object payload)
 {
     return(_streamsFactory.Open(views).AppendAsync(payload));
 }
Esempio n. 6
0
 public IStream OpenStream(string id)
 {
     return(_streamsFactory.Open(id));
 }