protected override void Given()
            {
                base.Given();
                AllWritesSucceed();
                _tfPos1 = ExistingEvent("test-stream", "type1", "{}", "{Data: 1}");
                _tfPos2 = ExistingEvent("test-stream", "type1", "{}", "{Data: 2}");
                _tfPos3 = ExistingEvent("test-stream2", "type1", "{}", "{Data: 3}");
                ExistingEvent("test-stream2", "type1", "{}", "{Data: 4}");
                ExistingEvent("test-stream3", "type1", "{}", "{Data: 5}");
                ExistingEvent("test-stream3", "type1", "{}", "{Data: 6}");
                ExistingEvent("test-stream4", "type1", "{}", "{Data: 7}");

                ExistingEvent("catalog", "$>", null, "0@test-stream");
                ExistingEvent("catalog", "$>", null, "0@test-stream2");
                ExistingEvent("catalog", "$>", null, "0@test-stream3");

                _subscriptionId = Guid.NewGuid();
                _sourceDefinition = new QuerySourcesDefinition
                {
                    CatalogStream = "catalog",
                    AllEvents = true,
                    ByStreams = true,
                    Options = new QuerySourcesDefinitionOptions { }
                };
                _readerStrategy = ReaderStrategy.Create(0, _sourceDefinition, _timeProvider, stopOnEof: true, runAs: null);
                _readerSubscriptionOptions = new ReaderSubscriptionOptions(
                    checkpointUnhandledBytesThreshold: 10000, checkpointProcessedEventsThreshold: 100, stopOnEof: true,
                    stopAfterNEvents: null);
            }
            protected override void Given()
            {
                base.Given();
                AllWritesSucceed();
                ExistingEvent("test-stream", "$>", "{}", "{Data: 1}");
                ExistingEvent("test-stream", "$>", "{}", "{Data: 2}");
                ExistingEvent("test-stream", "$>", "{}", "{Data: 3}");

                ExistingEvent("test-stream", "eventType", "{}", "{Data: 4}");
                ExistingEvent("test-stream", "eventType", "{}", "{Data: 5}");
                ExistingEvent("test-stream", "eventType", "{}", "{Data: 6}");
                ExistingEvent("test-stream", "eventType", "{}", "{Data: 7}");

                _subscriptionId = Guid.NewGuid();
                _sourceDefinition = new QuerySourcesDefinition
                {
                    ByStreams = true,
                    AllStreams = true,
                    AllEvents = true,
                    Options = new QuerySourcesDefinitionOptions
                    {
                        IncludeLinks = false
                    }
                };
                _readerStrategy = ReaderStrategy.Create(
                    "test",
                    0,
                    _sourceDefinition,
                    _timeProvider,
                    stopOnEof: true,
                    runAs: null);
                _readerSubscriptionOptions = new ReaderSubscriptionOptions(
                    checkpointUnhandledBytesThreshold: 10000, checkpointProcessedEventsThreshold: 100, stopOnEof: true,
                    stopAfterNEvents: null);
            }
        protected override void Given()
        {
            _projectionId = Guid.NewGuid();
            _workerId = Guid.NewGuid();
            _projectionName = "projection";
            _handlerType = "JS";
            _query = "from()";

            _config = new ProjectionConfig(
                new OpenGenericPrincipal("user", "a", "b"),
                1000,
                100000,
                2000,
                200,
                true,
                true,
                true,
                true,
                true);

            var builder = new SourceDefinitionBuilder();
            builder.FromStream("s1");
            builder.FromStream("s2");
            builder.IncludeEvent("e1");
            builder.IncludeEvent("e2");
            builder.SetByStream();
            builder.SetResultStreamNameOption("result-stream");
            _definition = QuerySourcesDefinition.From(builder);
        }
            protected override void Given()
            {
                base.Given();
                AllWritesSucceed();

                _tfPos1 = ExistingEvent("test-stream", "type1", "{}", "{Data: 1}");
                _tfPos2 = ExistingEvent("test-stream", "type1", "{}", "{Data: 2}");
                _tfPos3 = ExistingEvent("test-stream", "type2", "{}", "{Data: 3}");

                GivenInitialIndexState();

                _subscriptionId = Guid.NewGuid();
                _sourceDefinition = new QuerySourcesDefinition
                {
                    AllStreams = true,
                    Events = new[] {"type1", "type2"},
                    Options = new QuerySourcesDefinitionOptions {}
                };
                _readerStrategy = ReaderStrategy.Create(
                    "test",
                    0,
                    _sourceDefinition,
                    _timeProvider,
                    stopOnEof: false,
                    runAs: null);

                _readerSubscriptionOptions = new ReaderSubscriptionOptions(
                    checkpointUnhandledBytesThreshold: 10000, checkpointProcessedEventsThreshold: 100, stopOnEof: false,
                    stopAfterNEvents: null);
            }
Пример #5
0
            protected override void Given()
            {
                base.Given();
                AllWritesSucceed();
                ExistingEvent("stream-a", "type1", "{}", "{Data: 1}");
                ExistingEvent("stream-b", "type1", "{}", "{Data: 2}");

                GivenOtherEvents();

                _subscriptionId = Guid.NewGuid();
                _sourceDefinition = new QuerySourcesDefinition
                    {
                        Streams =  new []{"stream-a", "stream-b"},
                        AllEvents = true,
                        Options = new QuerySourcesDefinitionOptions {ReorderEvents = true, ProcessingLag = 100}
                    };
                _readerStrategy = ReaderStrategy.Create(
                    "test",
                    0,
                    _sourceDefinition,
                    _timeProvider,
                    stopOnEof: false,
                    runAs: null);

                _readerSubscriptionOptions = new ReaderSubscriptionOptions(
                    checkpointUnhandledBytesThreshold: 10000, checkpointProcessedEventsThreshold: 100, stopOnEof: false,
                    stopAfterNEvents: null);
            }
Пример #6
0
 public void SetUp()
 {
     _bus = new InMemoryBus("test");
     _subscriptionDispatcher =
         new PublishSubscribeDispatcher
             <ReaderSubscriptionManagement.Subscribe,
                 ReaderSubscriptionManagement.ReaderSubscriptionManagementMessage,
                 EventReaderSubscriptionMessage>(_bus, v => v.SubscriptionId, v => v.SubscriptionId);
     _testQueryDefinition = new QuerySourcesDefinition {AllStreams = true, AllEvents = true};
 }
Пример #7
0
 public CreatePrepared(
     Guid projectionId,
     Guid workerId,
     string name,
     ProjectionVersion version,
     ProjectionConfig config,
     QuerySourcesDefinition sourceDefinition,
     string handlerType,
     string query,
     bool enableContentTypeValidation)
     : base(projectionId, workerId)
 {
     if (name == null)
     {
         throw new ArgumentNullException("name");
     }
     if (config == null)
     {
         throw new ArgumentNullException("config");
     }
     if (sourceDefinition == null)
     {
         throw new ArgumentNullException("sourceDefinition");
     }
     if (handlerType == null)
     {
         throw new ArgumentNullException("handlerType");
     }
     if (query == null)
     {
         throw new ArgumentNullException("query");
     }
     _name                        = name;
     _version                     = version;
     _config                      = config;
     _sourceDefinition            = sourceDefinition;
     _handlerType                 = handlerType;
     _query                       = query;
     _enableContentTypeValidation = enableContentTypeValidation;
 }
            //private TFPos _tfPos2;
            //private TFPos _tfPos3;

            protected override void Given()
            {
                base.Given();
                _tfPos1 = ExistingEvent("test-stream", "type1", "{}", "{Data: 1}");
                //_tfPos2 = ExistingEvent("test-stream", "type1", "{}", "{Data: 2}");
                //_tfPos3 = ExistingEvent("test-stream", "type2", "{}", "{Data: 3}");

                ExistingEvent("$et-type1", "$>", TFPosToMetadata(_tfPos1), "0@test-stream");
                NoStream("$et-type2");
                NoStream("$et");
                //NOTE: the following events should be late written
                //ExistingEvent("$et-type2", "$>", "", "2@test-stream");
                //ExistingEvent("$et-type1", "$>", "", "1@test-stream");

                _querySourcesDefinition = new QuerySourcesDefinition
                    {
                        AllStreams = true,
                        Events = new[] {"type1", "type2"},
                        Options = new QuerySourcesDefinitionOptions {}
                    };
                _fromPosition = CheckpointTag.FromEventTypeIndexPositions(new TFPos(0, -1), new Dictionary<string, int>{{"type1", -1}, {"type2", -1}});
                _maxEvents = 1; // reading the first event
            }
            protected override void Given()
            {
                base.Given();
                AllWritesSucceed();
                _tfPos1 = ExistingEvent("test-stream", "type1", "{}", "{Data: 1}");
                _tfPos2 = ExistingEvent("test-stream", "type1", "{}", "{Data: 2}");
                _tfPos3 = ExistingEvent("test-stream2", "type1", "{}", "{Data: 3}");
                ExistingEvent("test-stream2", "type1", "{}", "{Data: 4}");
                ExistingEvent("test-stream3", "type1", "{}", "{Data: 5}");
                ExistingEvent("test-stream3", "type1", "{}", "{Data: 6}");
                ExistingEvent("test-stream4", "type1", "{}", "{Data: 7}");

                ExistingEvent("$$test-stream", "$metadata", "", "{Meta: 1}");
                ExistingEvent("$$test-stream2", "$metadata", "", "{Meta: 2}");
                ExistingEvent("$$test-stream3", "$metadata", "", "{Meta: 3}");


                ExistingEvent("$streams", "$>", null, "0@test-stream");
                ExistingEvent("$streams", "$>", null, "0@test-stream2");
                ExistingEvent("$streams", "$>", null, "0@test-stream3");
                ExistingEvent("$streams", "$>", null, "0@test-stream4");
                NoOtherStreams();

                _subscriptionId = Guid.NewGuid();
                _sourceDefinition = new QuerySourcesDefinition
                {
                    CatalogStream = "$all",
                    AllEvents = true,
                    ByStreams = true,
                    Options = new QuerySourcesDefinitionOptions { }
                };
                _readerStrategy = new ParallelQueryAllStreamsMasterReaderStrategy(
                    0, SystemAccount.Principal, _timeProvider);
                _readerSubscriptionOptions = new ReaderSubscriptionOptions(
                    checkpointUnhandledBytesThreshold: 10000, checkpointProcessedEventsThreshold: 100, stopOnEof: true,
                    stopAfterNEvents: null);
            }
            protected override void Given()
            {
                base.Given();
                _tfPos1 = ExistingEvent("test-stream", "type1", "{}", "{Data: 1}");
                _tfPos2 = ExistingEvent("test-stream", "type1", "{}", "{Data: 2}");
                _tfPos3 = ExistingEvent("test-stream", "type2", "{}", "{Data: 3}");

                // writes reordered due to batching or timeouts in system projection
                ExistingEvent("$et-type1", "$>", TFPosToMetadata(_tfPos1), "0@test-stream");
                ExistingEvent("$et-type2", "$>", TFPosToMetadata(_tfPos3), "2@test-stream");
                ExistingEvent("$et-type1", "$>", TFPosToMetadata(_tfPos2), "1@test-stream");
                NoStream("$et");
                _querySourcesDefinition = new QuerySourcesDefinition
                    {
                        AllStreams = true,
                        Events = new[] {"type1", "type2"},
                        Options = new QuerySourcesDefinitionOptions {}
                    };
                _fromPosition = CheckpointTag.FromEventTypeIndexPositions(
                    new TFPos(0, -1), new Dictionary<string, int> {{"type1", -1}, {"type2", -1}});
                _maxEvents = 3;
            }
 public CreatePrepared(
     Guid projectionId,
     Guid workerId,
     string name,
     ProjectionVersion version,
     ProjectionConfig config,
     QuerySourcesDefinition sourceDefinition,
     string handlerType,
     string query)
     : base(projectionId, workerId)
 {
     if (name == null) throw new ArgumentNullException("name");
     if (config == null) throw new ArgumentNullException("config");
     if (sourceDefinition == null) throw new ArgumentNullException("sourceDefinition");
     if (handlerType == null) throw new ArgumentNullException("handlerType");
     if (query == null) throw new ArgumentNullException("query");
     _name = name;
     _version = version;
     _config = config;
     _sourceDefinition = sourceDefinition;
     _handlerType = handlerType;
     _query = query;
 }
Пример #12
0
        private void GetSources()
        {
            if (_getSources == null)
                throw new InvalidOperationException("'get_sources' command handler has not been registered");
            var sourcesJson = _getSources();


            _sources = sourcesJson.ParseJson<QuerySourcesDefinition>();
        }
Пример #13
0
            protected override void Given()
            {
                base.Given();
                ExistingEvent("test-stream", "type1", "{}", "{Data: 1}");
                ExistingEvent("test-stream", "type1", "{}", "{Data: 2}");
                ExistingEvent("test-stream", "type2", "{}", "{Data: 3}");

                _querySourcesDefinition = new QuerySourcesDefinition {Streams = new[] {"test-stream"}, AllEvents = true};
                _fromPosition = CheckpointTag.FromStreamPosition("test-stream", -1);
                _maxEvents = 2;
            }
Пример #14
0
 public void SetUp()
 {
     _bus = new InMemoryBus("test");
     _consumer = new TestHandler<Message>();
     _bus.Subscribe(_consumer);
     _subscriptionDispatcher =
         new PublishSubscribeDispatcher
             <ReaderSubscriptionManagement.Subscribe,
                 ReaderSubscriptionManagement.ReaderSubscriptionManagementMessage,
                 EventReaderSubscriptionMessage>(_bus, v => v.SubscriptionId, v => v.SubscriptionId);
     _testQueryDefinition = GivenQuerySource();
     _feedReader = new FeedReader(
         _subscriptionDispatcher, SystemAccount.Principal, _testQueryDefinition, GivenFromPosition(), 10,
         Guid.NewGuid(), new PublishEnvelope(_bus), new RealTimeProvider());
     Given();
     When();
 }
Пример #15
0
 public void SetUp()
 {
     _bus = new InMemoryBus("test");
     _subscriptionDispatcher = new ReaderSubscriptionDispatcher(_bus);
     _testQueryDefinition = new QuerySourcesDefinition {AllStreams = true, AllEvents = true};
 }
Пример #16
0
        private void GetSources()
        {
            if (_getSources == null)
                throw new InvalidOperationException("'get_sources' command handler has not been registered");
            var sourcesJson = _getSources();

            Console.WriteLine(sourcesJson);

            _sources = sourcesJson.ParseJson<QuerySourcesDefinition>();

            if (_sources.AllStreams)
                Console.WriteLine("All streams requested");
            else
            {
                foreach (var category in _sources.Categories)
                    Console.WriteLine("Category {0} requested", category);
                foreach (var stream in _sources.Streams)
                    Console.WriteLine("Stream {0} requested", stream);
            }
            if (_sources.AllEvents)
                Console.WriteLine("All events requested");
            else
            {
                foreach (var @event in _sources.Events)
                    Console.WriteLine("Event {0} requested", @event);
            }
        }