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();
        }
Esempio n. 2
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();
        }
Esempio n. 3
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();
        }
Esempio n. 4
0
 public void setup()
 {
     _state      = null;
     _projection = null;
     Given();
     _logged = new List <string>();
     _stateHandlerFactory = new ProjectionStateHandlerFactory();
     _stateHandler        = _stateHandlerFactory.Create(
         "JS", _projection, s =>
     {
         if (!s.StartsWith("P:"))
         {
             _logged.Add(s);
         }
         else
         {
             Console.WriteLine(s);
         }
     });         // skip prelude debug output
     _source = new SourceRecorder();
     _stateHandler.ConfigureSourceProcessingStrategy(_source);
     if (_state != null)
     {
         _stateHandler.Load(_state);
     }
     else
     {
         _stateHandler.Initialize();
     }
 }
        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();
        }
Esempio n. 6
0
        public static IProjectionStateHandler CreateStateHandler(
            ISingletonTimeoutScheduler singletonTimeoutScheduler,
            ILogger logger,
            string handlerType,
            string query)
        {
            var stateHandler = new ProjectionStateHandlerFactory().Create(
                handlerType,
                query,
                logger: logger.Trace,
                cancelCallbackFactory:
                singletonTimeoutScheduler == null ? (Action <int, Action>)null : singletonTimeoutScheduler.Schedule);

            return(stateHandler);
        }
        public static IProjectionStateHandler CreateStateHandler(ProjectionStateHandlerFactory factory,
                                                                 ISingletonTimeoutScheduler singletonTimeoutScheduler,
                                                                 ILogger logger,
                                                                 string handlerType,
                                                                 string query,
                                                                 bool enableContentTypeValidation)
        {
            var stateHandler = factory.Create(
                handlerType,
                query,
                enableContentTypeValidation,
                logger: logger.Verbose,
                cancelCallbackFactory:
                singletonTimeoutScheduler == null ? null : singletonTimeoutScheduler.Schedule);

            return(stateHandler);
        }
        public void can_compile_million_times()
        {
            for (var i = 0; i < 10000000; i++)
            {
                if (_stateHandler != null)
                {
                    _stateHandler.Dispose();
                }
                _stateHandler = null;

/*
 *              _state = null;
 */
                _projection          = null;
                _projection          = @"
                fromAll();
                on_raw(function(state, event, streamId, eventType, sequenceNumber, metadata) {
                    emit('output-stream' + sequenceNumber, 'emitted-event' + sequenceNumber, {a: JSON.parse(event).a});
                    return {};
                });
            ";
                _logged              = new List <string>();
                _stateHandlerFactory = new ProjectionStateHandlerFactory();
                _stateHandler        = _stateHandlerFactory.Create(
                    "JS", _projection, s =>
                {
                    if (!s.StartsWith("P:"))
                    {
                        _logged.Add(s);
                    }
                    else
                    {
                        _logDelegate(s);
                    }
                });         // skip prelude debug output

/*
 *              if (_state != null)
 *                  _stateHandler.Load(_state);
 *              else
 *                  _stateHandler.Initialize();
 */
                Console.Write(".");
            }
        }
 public ProjectionCoreService(
     Guid workerId,
     IPublisher inputQueue,
     IPublisher publisher,
     ReaderSubscriptionDispatcher subscriptionDispatcher,
     ITimeProvider timeProvider,
     IODispatcher ioDispatcher,
     ISingletonTimeoutScheduler timeoutScheduler, ProjectionsStandardComponents configuration)
 {
     _workerId                   = workerId;
     _inputQueue                 = inputQueue;
     _publisher                  = publisher;
     _ioDispatcher               = ioDispatcher;
     _timeoutScheduler           = timeoutScheduler;
     _subscriptionDispatcher     = subscriptionDispatcher;
     _timeProvider               = timeProvider;
     _processingStrategySelector = new ProcessingStrategySelector(_subscriptionDispatcher);
     _factory = new ProjectionStateHandlerFactory(TimeSpan.FromMilliseconds(configuration.ProjectionCompilationTimeout),
                                                  TimeSpan.FromMilliseconds(configuration.ProjectionExecutionTimeout), configuration.ProjectionRuntime);
 }
 public void setup()
 {
     _stateHandlerFactory = new ProjectionStateHandlerFactory();
 }
Esempio n. 11
0
 public void Setup()
 {
     _stateHandlerFactory = new ProjectionStateHandlerFactory(TimeSpan.FromMilliseconds(1000),
                                                              TimeSpan.FromMilliseconds(500), JavascriptProjectionRuntime.Legacy);
 }
 public void Setup()
 {
     _stateHandlerFactory =
         new ProjectionStateHandlerFactory(TimeSpan.FromMilliseconds(250), TimeSpan.FromMilliseconds(100));
 }
 public void Setup()
 {
     _stateHandlerFactory =
         new ProjectionStateHandlerFactory(TimeSpan.FromMilliseconds(250), TimeSpan.FromMilliseconds(100), JavascriptProjectionRuntime.Interpreted);
 }