managed projection controls start/stop/create/update/delete lifecycle of the projection.
Inheritance: IDisposable
 protected override void Given()
 {
     _timeProvider = new FakeTimeProvider();
     _mp = new ManagedProjection(
         _bus, Guid.NewGuid(), 1, "name", true, null, _writeDispatcher, _readDispatcher, _bus, _bus, _handlerFactory,
         _timeProvider);
 }
 protected override void Given()
 {
     _timeProvider = new FakeTimeProvider();
     _mp = new ManagedProjection(
         Guid.NewGuid(),
         Guid.NewGuid(),
         1,
         "name",
         true,
         null,
         _streamDispatcher,
         _writeDispatcher,
         _readDispatcher,
         _bus,
         _timeProvider, new RequestResponseDispatcher
             <CoreProjectionManagementMessage.GetState, CoreProjectionStatusMessage.StateReport>(
             _bus, 
             v => v.CorrelationId,
             v => v.CorrelationId,
             new PublishEnvelope(_bus)), new RequestResponseDispatcher
                 <CoreProjectionManagementMessage.GetResult, CoreProjectionStatusMessage.ResultReport>(
                 _bus, 
                 v => v.CorrelationId,
                 v => v.CorrelationId,
                 new PublishEnvelope(_bus)));
 }
Exemplo n.º 3
0
        private ManagedProjection CreateManagedProjectionInstance(
            string name,
            int projectionId,
            Guid projectionCorrelationId,
            Guid workerID,
            bool isSlave                  = false,
            Guid slaveMasterWorkerId      = default(Guid),
            Guid slaveMasterCorrelationId = default(Guid))
        {
            var enabledToRun = IsProjectionEnabledToRunByMode(name);
            var workerId     = workerID;
            var managedProjectionInstance = new ManagedProjection(
                workerId,
                projectionCorrelationId,
                projectionId,
                name,
                enabledToRun,
                _logger,
                _streamDispatcher,
                _writeDispatcher,
                _readDispatcher,
                _publisher,
                _timeProvider,
                _getStateDispatcher,
                _getResultDispatcher,
                isSlave,
                slaveMasterWorkerId,
                slaveMasterCorrelationId);

            _projectionsMap.Add(projectionCorrelationId, name);
            _projections.Add(name, managedProjectionInstance);
            _logger.Debug("Adding projection {0}@{1} to list", projectionCorrelationId, name);
            return(managedProjectionInstance);
        }
Exemplo n.º 4
0
        private ManagedProjection CreateManagedProjectionInstance(string name)
        {
            var projectionCorrelationId   = Guid.NewGuid();
            var managedProjectionInstance = new ManagedProjection(
                projectionCorrelationId, name, _logger, _writeDispatcher, _readDispatcher, _coreOutput,
                _projectionStateHandlerFactory);

            _projectionsMap.Add(projectionCorrelationId, name);
            _projections.Add(name, managedProjectionInstance);
            return(managedProjectionInstance);
        }
Exemplo n.º 5
0
        private ManagedProjection CreateManagedProjectionInstance(
            string name, int projectionId, Guid projectionCorrelationId, int queueIndex, bool isSlave = false,
            IPublisher slaveResultsPublisher = null, Guid slaveMasterCorrelationId = default(Guid))
        {
            var queue = _queues[queueIndex];

            _lastUsedQueue++;
            var enabledToRun = IsProjectionEnabledToRunByMode(name);
            var managedProjectionInstance = new ManagedProjection(
                queue, projectionCorrelationId, projectionId, name, enabledToRun, _logger, _writeDispatcher,
                _readDispatcher, _inputQueue, _publisher, _projectionStateHandlerFactory, _timeProvider,
                _timeoutSchedulers[queueIndex], isSlave, slaveResultsPublisher, slaveMasterCorrelationId);

            _projectionsMap.Add(projectionCorrelationId, name);
            _projections.Add(name, managedProjectionInstance);
            return(managedProjectionInstance);
        }
Exemplo n.º 6
0
        private ManagedProjection CreateManagedProjectionInstance(string name)
        {
            var        projectionCorrelationId = Guid.NewGuid();
            IPublisher queue;

            if (_lastUsedQueue >= _queues.Length)
            {
                _lastUsedQueue = 0;
            }
            queue = _queues[_lastUsedQueue];
            _lastUsedQueue++;

            var managedProjectionInstance = new ManagedProjection(queue,
                                                                  projectionCorrelationId, name, _logger, _writeDispatcher, _readDispatcher, _inputQueue,
                                                                  _projectionStateHandlerFactory);

            _projectionsMap.Add(projectionCorrelationId, name);
            _projections.Add(name, managedProjectionInstance);
            return(managedProjectionInstance);
        }
Exemplo n.º 7
0
        private ManagedProjection CreateManagedProjectionInstance(string name, int projectionId)
        {
            var projectionCorrelationId = Guid.NewGuid();

            if (_lastUsedQueue >= _queues.Length)
            {
                _lastUsedQueue = 0;
            }
            var queueIndex = _lastUsedQueue;
            var queue      = _queues[queueIndex];

            _lastUsedQueue++;
            var enabledToRun = IsProjectionEnabledToRunByMode(name);
            var managedProjectionInstance = new ManagedProjection(queue,
                                                                  projectionCorrelationId, projectionId, name, enabledToRun, _logger, _writeDispatcher, _readDispatcher, _inputQueue, _publisher,
                                                                  _projectionStateHandlerFactory, _timeProvider, _timeoutSchedulers[queueIndex]);

            _projectionsMap.Add(projectionCorrelationId, name);
            _projections.Add(name, managedProjectionInstance);
            return(managedProjectionInstance);
        }
Exemplo n.º 8
0
            public void CreateAndInitializeNewProjection(
                ProjectionManager projectionManager, Action <ManagedProjection> completed, Guid projectionCorrelationId,
                int queueIndex, bool isSlave  = false, IPublisher slaveResultsPublisher = null,
                Guid slaveMasterCorrelationId = default(Guid))
            {
                var projection = projectionManager.CreateManagedProjectionInstance(
                    _name, _projectionId, projectionCorrelationId, queueIndex, isSlave, slaveResultsPublisher,
                    slaveMasterCorrelationId);

                projection.InitializeNew(
                    () => completed(projection),
                    new ManagedProjection.PersistedState
                {
                    Enabled             = _enabled,
                    HandlerType         = _handlerType,
                    Query               = _query,
                    Mode                = _projectionMode,
                    EmitEnabled         = _emitEnabled,
                    CheckpointsDisabled = !_checkpointsEnabled,
                    Epoch               = -1,
                    Version             = -1,
                    RunAs               = _enableRunAs ? ManagedProjection.SerializePrincipal(_runAs) : null,
                });
            }
Exemplo n.º 9
0
 protected ManagedProjectionStateBase(ManagedProjection managedProjection)
 {
     _managedProjection = managedProjection;
 }
 public void empty_name_throws_argument_exception2()
 {
     var mp = new ManagedProjection(
         Guid.NewGuid(), "", null, _writeDispatcher, _readDispatcher, _bus, _handlerFactory);
 }
 public void empty_guid_throws_invali_argument_exception2()
 {
     var mp = new ManagedProjection(
         Guid.Empty, "name", null, _writeDispatcher, _readDispatcher, _bus, _handlerFactory);
 }
Exemplo n.º 12
0
 protected ManagedProjectionStateBase(ManagedProjection managedProjection)
 {
     _managedProjection = managedProjection;
 }
 protected override void Given()
 {
     _mp = new ManagedProjection(
         _bus, Guid.NewGuid(), "name", null, _writeDispatcher, _readDispatcher, _bus, _handlerFactory);
 }
 public void null_name_throws_argument_null_exception()
 {
     var mp = new ManagedProjection(_bus,
         Guid.NewGuid(), null, null, _writeDispatcher, _readDispatcher, _bus, _handlerFactory);
 }