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,
                true,
                10000,
                1);

            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);
        }
コード例 #2
0
ファイル: reordering.cs プロジェクト: zerox981/EventStore
            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,
                    checkpointAfterMs: 10000, stopOnEof: false,
                    stopAfterNEvents: null);
            }
コード例 #3
0
            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 = true
                    }
                };
                _readerStrategy = ReaderStrategy.Create(
                    "test",
                    0,
                    _sourceDefinition,
                    _timeProvider,
                    stopOnEof: true,
                    runAs: null);
                _readerSubscriptionOptions = new ReaderSubscriptionOptions(
                    checkpointUnhandledBytesThreshold: 10000, checkpointProcessedEventsThreshold: 100,
                    checkpointAfterMs: 10000, stopOnEof: true,
                    stopAfterNEvents: null,
                    enableContentTypeValidation: true);
            }
コード例 #4
0
            //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(0, new TFPos(0, -1),
                                                                          new Dictionary <string, long> {
                    { "type1", -1 }, { "type2", -1 }
                });
                _maxEvents = 1;                 // reading the first event
            }
コード例 #5
0
            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);
            }
コード例 #6
0
            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);
            }
コード例 #7
0
            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;
            }
コード例 #8
0
 public void SetUp()
 {
     _bus = new InMemoryBus("test");
     _subscriptionDispatcher = new ReaderSubscriptionDispatcher(_bus);
     _testQueryDefinition    = new QuerySourcesDefinition {
         AllStreams = true, AllEvents = true
     };
 }
コード例 #9
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>();
        }
コード例 #10
0
 public ReadPage(
     Guid correlationId, IEnvelope envelope, IPrincipal user, QuerySourcesDefinition querySource, CheckpointTag fromPosition,
     int maxEvents)
 {
     User          = user;
     CorrelationId = correlationId;
     Envelope      = envelope;
     QuerySource   = querySource;
     FromPosition  = fromPosition;
     MaxEvents     = maxEvents;
 }
コード例 #11
0
 public ReadPage(
     Guid correlationId, IEnvelope envelope, IPrincipal user, QuerySourcesDefinition querySource, CheckpointTag fromPosition,
     int maxEvents)
 {
     User = user;
     CorrelationId = correlationId;
     Envelope = envelope;
     QuerySource = querySource;
     FromPosition = fromPosition;
     MaxEvents = maxEvents;
 }
コード例 #12
0
        protected override ProjectionProcessingStrategy GivenProjectionProcessingStrategy()
        {
            var sourceDefinition = _stateHandler.GetSourceDefinition();
            var source           = QuerySourcesDefinition.From(sourceDefinition).ToJson();

            return(new ParallelQueryProcessingStrategy(
                       _projectionName, _version, GivenProjectionStateHandler, _projectionConfig,
                       ProjectionSourceDefinition.From(
                           _projectionName, sourceDefinition, typeof(FakeProjectionStateHandler).GetNativeHandlerName(),
                           source), new ProjectionNamesBuilder(_projectionName, sourceDefinition), null,
                       _spoolProcessingResponseDispatcher, _subscriptionDispatcher));
        }
コード例 #13
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
     };
 }
コード例 #14
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(0, "test-stream", -1);
                _maxEvents    = 2;
            }
コード例 #15
0
 public void SetUp()
 {
     _bus      = new InMemoryBus("test");
     _consumer = new TestHandler <Message>();
     _bus.Subscribe(_consumer);
     _subscriptionDispatcher = new ReaderSubscriptionDispatcher(_bus);
     _testQueryDefinition    = GivenQuerySource();
     _feedReader             = new FeedReader(
         _subscriptionDispatcher, SystemAccount.Principal, _testQueryDefinition, GivenFromPosition(), 10,
         Guid.NewGuid(), new PublishEnvelope(_bus), new RealTimeProvider());
     Given();
     When();
 }
コード例 #16
0
        public void Handle(CoreProjectionManagementMessage.CreatePrepared message)
        {
            var command = new CreatePreparedCommand {
                Config           = new PersistedProjectionConfig(message.Config),
                HandlerType      = message.HandlerType,
                Id               = message.ProjectionId.ToString("N"),
                Name             = message.Name,
                Query            = message.Query,
                SourceDefinition = QuerySourcesDefinition.From(message.SourceDefinition),
                Version          = message.Version
            };

            _commandWriter.PublishResponse("$create-prepared", message.WorkerId, command);
        }
コード例 #17
0
        private CoreProjectionManagementMessage.CreatePrepared CreateBeginCreatePreparedMessage(ProjectionConfig config)
        {
            if (_persistedState.SourceDefinition == null)
            {
                throw new Exception(
                          "The projection cannot be loaded as stopped as it was stored in the old format.  Update the projection query text to force prepare");
            }

            var createProjectionMessage = new CoreProjectionManagementMessage.CreatePrepared(
                Id,
                _workerId,
                _name,
                new ProjectionVersion(_projectionId, _persistedState.Epoch ?? 0, _persistedState.Version ?? 1),
                config,
                QuerySourcesDefinition.From(_persistedState.SourceDefinition),
                HandlerType,
                Query);

            return(createProjectionMessage);
        }
コード例 #18
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);
                }
            }
        }
コード例 #19
0
        public FeedReader(
            PublishSubscribeDispatcher
            <Guid, ReaderSubscriptionManagement.Subscribe,
             ReaderSubscriptionManagement.ReaderSubscriptionManagementMessage, EventReaderSubscriptionMessageBase
            >
            subscriptionDispatcher, IPrincipal user, QuerySourcesDefinition querySource, CheckpointTag fromPosition,
            int maxEvents, Guid requestCorrelationId, IEnvelope replyEnvelope, ITimeProvider timeProvider)
        {
            if (subscriptionDispatcher == null)
            {
                throw new ArgumentNullException("subscriptionDispatcher");
            }
            if (querySource == null)
            {
                throw new ArgumentNullException("querySource");
            }
            if (fromPosition == null)
            {
                throw new ArgumentNullException("fromPosition");
            }
            if (replyEnvelope == null)
            {
                throw new ArgumentNullException("replyEnvelope");
            }
            if (maxEvents <= 0)
            {
                throw new ArgumentException("non-negative expected", "maxEvents");
            }

            _subscriptionDispatcher = subscriptionDispatcher;
            _user                 = user;
            _querySource          = querySource;
            _fromPosition         = fromPosition;
            _maxEvents            = maxEvents;
            _requestCorrelationId = requestCorrelationId;
            _replyEnvelope        = replyEnvelope;
            _timeProvider         = timeProvider;
        }
コード例 #20
0
            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);
            }
コード例 #21
0
            protected override void Given()
            {
                base.Given();
                AllWritesSucceed();
                _tfPos  = new TFPos[TailLength];
                _tfPos1 = ExistingEvent("test-stream", "type1", "{}", "{Data: 1}");
                _tfPos2 = ExistingEvent("test-stream", "type1", "{}", "{Data: 2}");
                _tfPos3 = ExistingEvent("test-stream", "type1", "{}", "{Data: 3}");

                for (var i = 0; i < TailLength; i++)
                {
                    _tfPos[i] = ExistingEvent("test-stream", "type1", "{}", "{Data: " + i + "}");
                }

                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,
                    checkpointAfterMs: 10000, stopOnEof: false,
                    stopAfterNEvents: null,
                    enableContentTypeValidation: true);
            }
コード例 #22
0
 public IQuerySources Build()
 {
     return(QuerySourcesDefinition.From(this));
 }
コード例 #23
0
ファイル: QueryScript.cs プロジェクト: trbngr/EventStore
        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);
            }
        }