コード例 #1
0
        public void Setup()
        {
            _state = null;
            _projection = null;
            Given();
            _logged = new List<string>();
            _stateHandlerFactory = new ProjectionStateHandlerFactory();
            _stateHandler = _stateHandlerFactory.Create(
                "JS", _projection, logger: s =>
                    {
                        if (s.StartsWith("P:"))
                            Console.WriteLine(s);
                        else
                            _logged.Add(s);
                    }); // skip prelude debug output
            _source = _stateHandler.GetSourceDefinition();

            if (_state != null)
                _stateHandler.Load(_state);
            else
                _stateHandler.Initialize();

            if (_sharedState != null)
                _stateHandler.LoadShared(_sharedState);
            When();
        }
コード例 #2
0
 public void Handle(EventReaderSubscriptionMessage.CommittedEventReceived message)
 {
     //TODO:  make sure this is no longer required : if (_state != State.StateLoaded)
     if (IsOutOfOrderSubscriptionMessage(message))
     {
         return;
     }
     RegisterSubscriptionMessage(message);
     try
     {
         var eventTag               = message.CheckpointTag;
         var correlationId          = Guid.NewGuid();
         var committedEventWorkItem = new SpoolStreamProcessingWorkItem(
             this, _resultWriter, _loadBalancer, message, _slaves, _spoolProcessingResponseDispatcher,
             _subscriptionStartedAtLastCommitPosition, _currentSubscriptionId, correlationId,
             _stateHandler.GetSourceDefinition().DefinesCatalogTransform);
         _spoolProcessingWorkItems.Add(correlationId, committedEventWorkItem);
         _processingQueue.EnqueueTask(committedEventWorkItem, eventTag);
         if (_state == PhaseState.Running) // prevent processing mostly one projection
         {
             EnsureTickPending();
         }
     }
     catch (Exception ex)
     {
         _coreProjection.SetFaulted(ex);
     }
 }
コード例 #3
0
        public void Setup()
        {
            _state      = null;
            _projection = null;
            Given();
            _logged = new List <string>();
            _stateHandlerFactory =
                new ProjectionStateHandlerFactory(CompilationTimeout, ExecutionTimeout, JavascriptProjectionRuntime.Interpreted);
            _stateHandler = CreateStateHandler();
            _source       = _stateHandler.GetSourceDefinition();

            if (_state != null)
            {
                _stateHandler.Load(_state);
            }
            else
            {
                _stateHandler.Initialize();
            }

            if (_sharedState != null)
            {
                _stateHandler.LoadShared(_sharedState);
            }
            When();
        }
コード例 #4
0
        public void Setup()
        {
            _state      = null;
            _projection = null;
            Given();
            _logged = new List <string>();
            _stateHandlerFactory = new ProjectionStateHandlerFactory();
            _stateHandler        = _stateHandlerFactory.Create(
                "JS", _projection, logger: (s, _) => {
                if (s.StartsWith("P:"))
                {
                    Console.WriteLine(s);
                }
                else
                {
                    _logged.Add(s);
                }
            });                     // skip prelude debug output
            _source = _stateHandler.GetSourceDefinition();

            if (_state != null)
            {
                _stateHandler.Load(_state);
            }
            else
            {
                _stateHandler.Initialize();
            }

            if (_sharedState != null)
            {
                _stateHandler.LoadShared(_sharedState);
            }
            When();
        }
コード例 #5
0
        public void Handle(CoreProjectionManagementMessage.CreateAndPrepare message)
        {
            try
            {
                //TODO: factory method can throw
                IProjectionStateHandler stateHandler = message.HandlerFactory();
                string name             = message.Name;
                var    sourceDefinition = ProjectionSourceDefinition.From(
                    name, stateHandler.GetSourceDefinition(), message.HandlerType, message.Query);
                var projectionVersion = message.Version;
                var projectionConfig  = message.Config;
                var namesBuilder      = new ProjectionNamesBuilder(name, sourceDefinition);

                var projectionProcessingStrategy = _processingStrategySelector.CreateProjectionProcessingStrategy(
                    name, projectionVersion, namesBuilder,
                    sourceDefinition, projectionConfig, message.HandlerFactory, stateHandler);

                var slaveProjections = projectionProcessingStrategy.GetSlaveProjections();
                CreateCoreProjection(message.ProjectionId, projectionConfig.RunAs, projectionProcessingStrategy);
                message.Envelope.ReplyWith(
                    new CoreProjectionManagementMessage.Prepared(
                        message.ProjectionId, sourceDefinition, slaveProjections));
            }
            catch (Exception ex)
            {
                message.Envelope.ReplyWith(
                    new CoreProjectionManagementMessage.Faulted(message.ProjectionId, ex.Message));
            }
        }
コード例 #6
0
        public void Setup()
        {
            _state      = null;
            _projection = null;
            Given();
            _logged = new List <string>();
            _stateHandlerFactory = new ProjectionStateHandlerFactory(TimeSpan.FromMilliseconds(1000), TimeSpan.FromMilliseconds(500), JavascriptProjectionRuntime.Legacy);
            _stateHandler        = CreateStateHandler();
            _source = _stateHandler.GetSourceDefinition();

            if (_state != null)
            {
                _stateHandler.Load(_state);
            }
            else
            {
                _stateHandler.Initialize();
            }

            if (_sharedState != null)
            {
                _stateHandler.LoadShared(_sharedState);
            }
            When();
        }
コード例 #7
0
        public void Setup()
        {
            _state      = null;
            _projection = null;
            Given();
            _logged = new List <string>();
            _stateHandlerFactory = new ProjectionStateHandlerFactory();
            _stateHandler        = CreateStateHandler();
            _source = _stateHandler.GetSourceDefinition();

            if (_state != null)
            {
                _stateHandler.Load(_state);
            }
            else
            {
                _stateHandler.Initialize();
            }

            if (_sharedState != null)
            {
                _stateHandler.LoadShared(_sharedState);
            }
            When();
        }
コード例 #8
0
 public void Handle(CoreProjectionManagementMessage.CreateAndPrepareSlave message)
 {
     try
     {
         //TODO: factory method can throw!
         IProjectionStateHandler stateHandler = message.HandlerFactory();
         string name                         = message.Name;
         var    sourceDefinition             = ProjectionSourceDefinition.From(name, stateHandler.GetSourceDefinition(), null, null);
         var    projectionVersion            = message.Version;
         var    projectionConfig             = message.Config.SetIsSlave();
         var    projectionProcessingStrategy =
             _processingStrategySelector.CreateSlaveProjectionProcessingStrategy(
                 name, projectionVersion, sourceDefinition, projectionConfig, stateHandler,
                 message.ResultsPublisher, message.MasterCoreProjectionId, this);
         CreateCoreProjection(message.ProjectionId, projectionConfig.RunAs, projectionProcessingStrategy);
         message.Envelope.ReplyWith(
             new CoreProjectionManagementMessage.Prepared(
                 message.ProjectionId, sourceDefinition, slaveProjections: null));
     }
     catch (Exception ex)
     {
         message.Envelope.ReplyWith(
             new CoreProjectionManagementMessage.Faulted(message.ProjectionId, ex.Message));
     }
 }