protected override IProjectionProcessingPhase[] CreateProjectionProcessingPhases(
            IPublisher publisher, Guid projectionCorrelationId, ProjectionNamesBuilder namingBuilder,
            PartitionStateCache partitionStateCache, CoreProjection coreProjection, IODispatcher ioDispatcher,
            IProjectionProcessingPhase firstPhase)
        {

            var coreProjectionCheckpointWriter =
                new CoreProjectionCheckpointWriter(
                    namingBuilder.MakeCheckpointStreamName(), ioDispatcher, _projectionVersion, _name);
            var checkpointManager2 = new DefaultCheckpointManager(
                publisher, projectionCorrelationId, _projectionVersion, _projectionConfig.RunAs, ioDispatcher,
                _projectionConfig, _name, new PhasePositionTagger(1), namingBuilder, GetUseCheckpoints(), false,
                _sourceDefinition.DefinesFold, coreProjectionCheckpointWriter);

            IProjectionProcessingPhase writeResultsPhase;
            if (GetProducesRunningResults()
                || !string.IsNullOrEmpty(_sourceDefinition.CatalogStream) && _sourceDefinition.ByStreams)
                writeResultsPhase = new WriteQueryEofProjectionProcessingPhase(
                    1, namingBuilder.GetResultStreamName(), coreProjection, partitionStateCache, checkpointManager2,
                    checkpointManager2);
            else
                writeResultsPhase = new WriteQueryResultProjectionProcessingPhase(
                    1, namingBuilder.GetResultStreamName(), coreProjection, partitionStateCache, checkpointManager2,
                    checkpointManager2);

            return new[] {firstPhase, writeResultsPhase};
        }
Exemplo n.º 2
0
        protected override IProjectionProcessingPhase[] CreateProjectionProcessingPhases(
            IPublisher publisher, Guid projectionCorrelationId, ProjectionNamesBuilder namingBuilder,
            PartitionStateCache partitionStateCache, CoreProjection coreProjection, IODispatcher ioDispatcher,
            IProjectionProcessingPhase firstPhase)
        {
            var coreProjectionCheckpointWriter =
                new CoreProjectionCheckpointWriter(
                    namingBuilder.MakeCheckpointStreamName(), ioDispatcher, _projectionVersion, _name);
            var checkpointManager2 = new DefaultCheckpointManager(
                publisher, projectionCorrelationId, _projectionVersion, _projectionConfig.RunAs, ioDispatcher,
                _projectionConfig, _name, new PhasePositionTagger(1), namingBuilder, GetUseCheckpoints(), false,
                _sourceDefinition.DefinesFold, coreProjectionCheckpointWriter);

            IProjectionProcessingPhase writeResultsPhase;

            if (GetProducesRunningResults() ||
                !string.IsNullOrEmpty(_sourceDefinition.CatalogStream) && _sourceDefinition.ByStreams)
            {
                writeResultsPhase = new WriteQueryEofProjectionProcessingPhase(
                    1, namingBuilder.GetResultStreamName(), coreProjection, partitionStateCache, checkpointManager2,
                    checkpointManager2);
            }
            else
            {
                writeResultsPhase = new WriteQueryResultProjectionProcessingPhase(
                    1, namingBuilder.GetResultStreamName(), coreProjection, partitionStateCache, checkpointManager2,
                    checkpointManager2);
            }

            return(new[] { firstPhase, writeResultsPhase });
        }
Exemplo n.º 3
0
        private EmittedEventEnvelope[] CreateResultUpdatedEvents(string partition, string projectionResult, CheckpointTag at)
        {
            var streamId           = _namesBuilder.MakePartitionResultStreamName(partition);
            var allResultsStreamId = _namesBuilder.GetResultStreamName();

            if (string.IsNullOrEmpty(partition))
            {
                var result =
                    new EmittedEventEnvelope(
                        projectionResult == null
                            ? new EmittedDataEvent(
                            streamId, Guid.NewGuid(), "ResultRemoved", true, null, null, at, null)
                            : new EmittedDataEvent(
                            streamId, Guid.NewGuid(), "Result", true, projectionResult, null, at, null),
                        _resultStreamMetadata);

                return(new[] { result });
            }
            else
            {
                var linkTo         = new EmittedLinkTo(allResultsStreamId, Guid.NewGuid(), streamId, at, null);
                var linkToEnvelope = new EmittedEventEnvelope(linkTo, _resultStreamMetadata);
                var result         =
                    new EmittedEventEnvelope(
                        projectionResult == null
                            ? new EmittedDataEvent(
                            streamId, Guid.NewGuid(), "ResultRemoved", true, null, null, at, null,
                            linkTo.SetTargetEventNumber)
                            : new EmittedDataEvent(
                            streamId, Guid.NewGuid(), "Result", true, projectionResult, null, at, null,
                            linkTo.SetTargetEventNumber), _resultStreamMetadata);
                return(new[] { result, linkToEnvelope });
            }
        }
Exemplo n.º 4
0
        protected override IProjectionProcessingPhase[] CreateProjectionProcessingPhases(
            IPublisher publisher, IPublisher inputQueue, Guid projectionCorrelationId,
            ProjectionNamesBuilder namingBuilder,
            PartitionStateCache partitionStateCache, CoreProjection coreProjection, IODispatcher ioDispatcher,
            IProjectionProcessingPhase firstPhase)
        {
            var coreProjectionCheckpointWriter =
                new CoreProjectionCheckpointWriter(
                    namingBuilder.MakeCheckpointStreamName(), ioDispatcher, _projectionVersion, _name);
            var checkpointManager2 = new DefaultCheckpointManager(
                publisher, projectionCorrelationId, _projectionVersion, SystemAccount.Principal, ioDispatcher,
                _projectionConfig, _name, new PhasePositionTagger(1), namingBuilder, GetUseCheckpoints(), false,
                _sourceDefinition.DefinesFold, coreProjectionCheckpointWriter);

            IProjectionProcessingPhase writeResultsPhase;

            if (GetProducesRunningResults())
            {
                writeResultsPhase = new WriteQueryEofProjectionProcessingPhase(
                    publisher,
                    1,
                    namingBuilder.GetResultStreamName(),
                    coreProjection,
                    partitionStateCache,
                    checkpointManager2,
                    checkpointManager2,
                    firstPhase.EmittedStreamsTracker);
            }
            else
            {
                writeResultsPhase = new WriteQueryResultProjectionProcessingPhase(
                    publisher,
                    1,
                    namingBuilder.GetResultStreamName(),
                    coreProjection,
                    partitionStateCache,
                    checkpointManager2,
                    checkpointManager2,
                    firstPhase.EmittedStreamsTracker);
            }

            return(new[] { firstPhase, writeResultsPhase });
        }
 public ProjectionSourceDefinition Build(ProjectionNamesBuilder namingBuilder)
 {
     return new ProjectionSourceDefinition
         {
             AllEvents = _allEvents,
             AllStreams = _allStreams,
             ByStream = _byStream,
             ByCustomPartitions = _byCustomPartitions,
             Categories = (_categories ?? new List<string>()).ToArray(),
             Events = (_events ?? new List<string>()).ToArray(),
             Streams = (_streams ?? new List<string>()).ToArray(),
             DefinesStateTransform = _definesStateTransform,
             Options = _options,
             ResultStreamName = namingBuilder.GetResultStreamName(),
             PartitionResultStreamNamePattern = namingBuilder.GetPartitionResultStreamNamePattern(),
             PartitionResultCatalogStream = namingBuilder.GetPartitionResultCatalogStreamName(),
             PartitionCatalogStream = namingBuilder.GetPartitionCatalogStreamName(),
         };
 }
Exemplo n.º 6
0
 public ProjectionSourceDefinition Build(ProjectionNamesBuilder namingBuilder)
 {
     return(new ProjectionSourceDefinition
     {
         AllEvents = _allEvents,
         AllStreams = _allStreams,
         ByStream = _byStream,
         ByCustomPartitions = _byCustomPartitions,
         Categories = (_categories ?? new List <string>()).ToArray(),
         Events = (_events ?? new List <string>()).ToArray(),
         Streams = (_streams ?? new List <string>()).ToArray(),
         DefinesStateTransform = _definesStateTransform,
         Options = _options,
         ResultStreamName = namingBuilder.GetResultStreamName(),
         PartitionResultStreamNamePattern = namingBuilder.GetPartitionResultStreamNamePattern(),
         PartitionResultCatalogStream = namingBuilder.GetPartitionResultCatalogStreamName(),
         PartitionCatalogStream = namingBuilder.GetPartitionCatalogStreamName(),
     });
 }
Exemplo n.º 7
0
        public static ProjectionSourceDefinition From(
            string name, IQuerySources sources, string handlerType, string query)
        {
            var namingBuilder = new ProjectionNamesBuilder(name, sources);

            return(new ProjectionSourceDefinition
            {
                AllEvents = sources.AllEvents,
                AllStreams = sources.AllStreams,
                ByStream = sources.ByStreams,
                ByCustomPartitions = sources.ByCustomPartitions,
                Categories = (sources.Categories ?? new string[0]).ToArray(),
                Events = (sources.Events ?? new string[0]).ToArray(),
                Streams = (sources.Streams ?? new string[0]).ToArray(),
                CatalogStream = sources.CatalogStream,
                LimitingCommitPosition = sources.LimitingCommitPosition,
                Options =
                    new QuerySourceOptions
                {
                    DefinesStateTransform = sources.DefinesStateTransform,
                    DefinesCatalogTransform = sources.DefinesCatalogTransform,
                    ProducesResults = sources.ProducesResults,
                    DefinesFold = sources.DefinesFold,
                    HandlesDeletedNotifications = sources.HandlesDeletedNotifications,
                    ForceProjectionName = sources.ForceProjectionNameOption,
                    IncludeLinks = sources.IncludeLinksOption,
                    DisableParallelism = sources.DisableParallelismOption,
                    PartitionResultStreamNamePattern = sources.PartitionResultStreamNamePatternOption,
                    ProcessingLag = sources.ProcessingLagOption.GetValueOrDefault(),
                    IsBiState = sources.IsBiState,
                    ReorderEvents = sources.ReorderEventsOption,
                    ResultStreamName = sources.ResultStreamNameOption,
                },
                ResultStreamName = namingBuilder.GetResultStreamName(),
                PartitionResultStreamNamePattern = namingBuilder.GetPartitionResultStreamNamePattern(),
                PartitionResultCatalogStream = namingBuilder.GetPartitionResultCatalogStreamName(),
                PartitionCatalogStream = namingBuilder.GetPartitionCatalogStreamName(),
                HandlerType = handlerType,
                Query = query
            });
        }
 public static ProjectionSourceDefinition From(
     string name, IQuerySources sources, string handlerType, string query)
 {
     var namingBuilder = new ProjectionNamesBuilder(name, sources);
     return new ProjectionSourceDefinition
     {
         AllEvents = sources.AllEvents,
         AllStreams = sources.AllStreams,
         ByStream = sources.ByStreams,
         ByCustomPartitions = sources.ByCustomPartitions,
         Categories = (sources.Categories ?? new string[0]).ToArray(),
         Events = (sources.Events ?? new string[0]).ToArray(),
         Streams = (sources.Streams ?? new string[0]).ToArray(),
         CatalogStream = sources.CatalogStream,
         LimitingCommitPosition = sources.LimitingCommitPosition,
         Options =
             new QuerySourceOptions
             {
                 DefinesStateTransform = sources.DefinesStateTransform,
                 ProducesResults = sources.ProducesResults,
                 DefinesFold = sources.DefinesFold,
                 ForceProjectionName = sources.ForceProjectionNameOption,
                 IncludeLinks = sources.IncludeLinksOption,
                 PartitionResultStreamNamePattern = sources.PartitionResultStreamNamePatternOption,
                 ProcessingLag = sources.ProcessingLagOption.GetValueOrDefault(),
                 ReorderEvents = sources.ReorderEventsOption,
                 ResultStreamName = sources.ResultStreamNameOption,
             },
         ResultStreamName = namingBuilder.GetResultStreamName(),
         PartitionResultStreamNamePattern = namingBuilder.GetPartitionResultStreamNamePattern(),
         PartitionResultCatalogStream = namingBuilder.GetPartitionResultCatalogStreamName(),
         PartitionCatalogStream = namingBuilder.GetPartitionCatalogStreamName(),
         HandlerType = handlerType,
         Query = query
     };
 }
        protected override IProjectionProcessingPhase[] CreateProjectionProcessingPhases(
            IPublisher publisher,
            IPublisher inputQueue,
            Guid projectionCorrelationId,
            ProjectionNamesBuilder namingBuilder,
            PartitionStateCache partitionStateCache,
            CoreProjection coreProjection,
            IODispatcher ioDispatcher,
            IProjectionProcessingPhase firstPhase)
        {
            var coreProjectionCheckpointWriter =
                new CoreProjectionCheckpointWriter(
                    namingBuilder.MakeCheckpointStreamName(),
                    ioDispatcher,
                    _projectionVersion,
                    _name);
            var checkpointManager2 = new DefaultCheckpointManager(
                publisher,
                projectionCorrelationId,
                _projectionVersion,
                _projectionConfig.RunAs,
                ioDispatcher,
                _projectionConfig,
                _name,
                new PhasePositionTagger(1),
                namingBuilder,
                GetUseCheckpoints(),
                false,
                _sourceDefinition.DefinesFold,
                coreProjectionCheckpointWriter);

            var writeResultsPhase = new WriteQueryEofProjectionProcessingPhase(
                publisher,
                1,
                namingBuilder.GetResultStreamName(),
                coreProjection,
                partitionStateCache,
                checkpointManager2,
                checkpointManager2,
                firstPhase.EmittedStreamsTracker);

            return new[] {firstPhase, writeResultsPhase};
        }