public void setup()
 {
     var builder = new CheckpointStrategy.Builder();
     builder.FromStream("stream1");
     builder.AllEvents();
     _strategy = builder.Build(ProjectionMode.Persistent);
 }
 public void setup()
 {
     var builder = new CheckpointStrategy.Builder();
     builder.FromStream("stream1");
     builder.AllEvents();
     _strategy = builder.Build(ProjectionConfig.GetTest());
 }
        protected ProjectionSubscriptionBase(
            Guid projectionCorrelationId, Guid subscriptionId, CheckpointTag from,
            IHandle<ProjectionSubscriptionMessage.CommittedEventReceived> eventHandler,
            IHandle<ProjectionSubscriptionMessage.CheckpointSuggested> checkpointHandler,
            IHandle<ProjectionSubscriptionMessage.ProgressChanged> progressHandler,
            IHandle<ProjectionSubscriptionMessage.EofReached> eofHandler,
            CheckpointStrategy checkpointStrategy, long? checkpointUnhandledBytesThreshold, bool stopOnEof)
        {
            if (eventHandler == null) throw new ArgumentNullException("eventHandler");
            if (checkpointHandler == null) throw new ArgumentNullException("checkpointHandler");
            if (progressHandler == null) throw new ArgumentNullException("progressHandler");
            if (eofHandler == null) throw new ArgumentNullException("eofHandler");
            if (checkpointStrategy == null) throw new ArgumentNullException("checkpointStrategy");
            _eventHandler = eventHandler;
            _checkpointHandler = checkpointHandler;
            _progressHandler = progressHandler;
            _eofHandler = eofHandler;
            _checkpointStrategy = checkpointStrategy;
            _checkpointUnhandledBytesThreshold = checkpointUnhandledBytesThreshold;
            _stopOnEof = stopOnEof;
            _projectionCorrelationId = projectionCorrelationId;
            _subscriptionId = subscriptionId;
            _lastPassedOrCheckpointedEventPosition = null;

            _eventFilter = checkpointStrategy.EventFilter;

            _positionTagger = checkpointStrategy.PositionTagger;
            _positionTracker = new PositionTracker(_positionTagger);
            _positionTracker.UpdateByCheckpointTagInitial(@from);
        }
Пример #4
0
        public ProjectionSubscription(
            Guid projectionCorrelationId, CheckpointTag from,
            IHandle <ProjectionMessage.Projections.CommittedEventReceived> eventHandler,
            IHandle <ProjectionMessage.Projections.CheckpointSuggested> checkpointHandler,
            CheckpointStrategy checkpointStrategy, long?checkpointUnhandledBytesThreshold)
        {
            if (eventHandler == null)
            {
                throw new ArgumentNullException("eventHandler");
            }
            if (checkpointHandler == null)
            {
                throw new ArgumentNullException("checkpointHandler");
            }
            if (checkpointStrategy == null)
            {
                throw new ArgumentNullException("checkpointStrategy");
            }
            _eventHandler       = eventHandler;
            _checkpointHandler  = checkpointHandler;
            _checkpointStrategy = checkpointStrategy;
            _checkpointUnhandledBytesThreshold     = checkpointUnhandledBytesThreshold;
            _projectionCorrelationId               = projectionCorrelationId;
            _lastPassedOrCheckpointedEventPosition = from.Position;

            _eventFilter = checkpointStrategy.EventFilter;

            _positionTagger  = checkpointStrategy.PositionTagger;
            _positionTracker = new PositionTracker(_positionTagger);
            _positionTracker.UpdateByCheckpointTagInitial(from);
        }
 public Subscribe(
     Guid correlationId, Guid subscriptionId, ICoreProjection subscriber, CheckpointTag from,
     CheckpointStrategy checkpointStrategy, long checkpointUnhandledBytesThreshold, bool stopOnEof = false)
 {
     _correlationId = correlationId;
     _subscriptionId = subscriptionId;
     _subscriber = subscriber;
     _fromPosition = @from;
     _checkpointStrategy = checkpointStrategy;
     _checkpointUnhandledBytesThreshold = checkpointUnhandledBytesThreshold;
     _stopOnEof = stopOnEof;
 }
Пример #6
0
        public CoreProjection(
            string name, Guid projectionCorrelationId, IPublisher publisher,
            IProjectionStateHandler projectionStateHandler, ProjectionConfig projectionConfig,
            RequestResponseDispatcher
            <ClientMessage.ReadStreamEventsBackward, ClientMessage.ReadStreamEventsBackwardCompleted> readDispatcher,
            RequestResponseDispatcher <ClientMessage.WriteEvents, ClientMessage.WriteEventsCompleted> writeDispatcher,
            ILogger logger = null)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            if (name == "")
            {
                throw new ArgumentException("name");
            }
            if (publisher == null)
            {
                throw new ArgumentNullException("publisher");
            }
            if (projectionStateHandler == null)
            {
                throw new ArgumentNullException("projectionStateHandler");
            }
            _projectionStateHandler  = projectionStateHandler;
            _projectionCorrelationId = projectionCorrelationId;

            var namingBuilder = new ProjectionNamesBuilder();

            _projectionStateHandler.ConfigureSourceProcessingStrategy(namingBuilder);

            _name = namingBuilder.ForceProjectionName ?? name;
            //TODO: move into name builder
            _stateStreamNamePattern = namingBuilder.StateStreamName ?? ProjectionsStreamPrefix + _name + "-{0}" + ProjectionsStateStreamSuffix;
            _stateStreamName        = namingBuilder.StateStreamName ?? ProjectionsStreamPrefix + _name + ProjectionsStateStreamSuffix;
            _projectionConfig       = projectionConfig;
            _logger          = logger;
            _publisher       = publisher;
            _readDispatcher  = readDispatcher;
            _writeDispatcher = writeDispatcher;
            var builder = new CheckpointStrategy.Builder();

            _projectionStateHandler.ConfigureSourceProcessingStrategy(builder);
            _checkpointStrategy  = builder.Build(_projectionConfig.Mode);
            _partitionStateCache = new PartitionStateCache();
            _processingQueue     = new CoreProjectionQueue(
                projectionCorrelationId, publisher, projectionConfig.PendingEventsThreshold, UpdateStatistics);
            _checkpointManager = this._checkpointStrategy.CreateCheckpointManager(
                this, projectionCorrelationId, this._publisher, this._readDispatcher,
                this._writeDispatcher, this._projectionConfig, this._name, _stateStreamName);
            GoToState(State.Initial);
        }
 public EventReorderingProjectionSubscription(
     Guid projectionCorrelationId, Guid subscriptionId, CheckpointTag from,
     IHandle<ProjectionSubscriptionMessage.CommittedEventReceived> eventHandler,
     IHandle<ProjectionSubscriptionMessage.CheckpointSuggested> checkpointHandler,
     IHandle<ProjectionSubscriptionMessage.ProgressChanged> progressHandler,
     IHandle<ProjectionSubscriptionMessage.EofReached> eofHandler,
     CheckpointStrategy checkpointStrategy, long? checkpointUnhandledBytesThreshold, int processingLagMs,
     bool stopOnEof = false)
     : base(
         projectionCorrelationId, subscriptionId, @from, eventHandler, checkpointHandler, progressHandler, eofHandler, 
         checkpointStrategy, checkpointUnhandledBytesThreshold, stopOnEof)
 {
     _processingLagMs = processingLagMs;
 }
        public void setup()
        {
            _checkpointUnhandledBytesThreshold = 1000;
            Given();
            _bus = new FakePublisher();
            _projectionCorrelationId = Guid.NewGuid();
            _eventHandler = new TestHandler<ProjectionSubscriptionMessage.CommittedEventReceived>();
            _checkpointHandler = new TestHandler<ProjectionSubscriptionMessage.CheckpointSuggested>();
            _progressHandler = new TestHandler<ProjectionSubscriptionMessage.ProgressChanged>();
            _eofHandler = new TestHandler<ProjectionSubscriptionMessage.EofReached>();
            _checkpointStrategy = CreateCheckpointStrategy();
            _subscription = CreateProjectionSubscription();


            When();
        }
Пример #9
0
        public CoreProjection(
            string name, Guid projectionCorrelationId, IPublisher publisher,
            IProjectionStateHandler projectionStateHandler, ProjectionConfig projectionConfig, ILogger logger = null)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            if (name == "")
            {
                throw new ArgumentException("name");
            }
            if (publisher == null)
            {
                throw new ArgumentNullException("publisher");
            }
            if (projectionStateHandler == null)
            {
                throw new ArgumentNullException("projectionStateHandler");
            }
            _projectionCorrelationId = projectionCorrelationId;
            _name                   = name;
            _projectionConfig       = projectionConfig;
            _logger                 = logger;
            _publisher              = publisher;
            _projectionStateHandler = projectionStateHandler;
            _readDispatcher         =
                new RequestResponseDispatcher
                <ClientMessage.ReadEventsBackwards, ClientMessage.ReadEventsBackwardsCompleted>(
                    _publisher, v => v.CorrelationId, v => v.CorrelationId);
            _projectionCheckpointStreamId = ProjectionsStreamPrefix + _name + ProjectionCheckpointStreamSuffix;
            var builder = new CheckpointStrategy.Builder();

            _projectionStateHandler.ConfigureSourceProcessingStrategy(builder);
            _checkpointStrategy         = builder.Build(_projectionConfig.Mode);
            _eventFilter                = _checkpointStrategy.EventFilter;
            _lastProcessedEventPosition = new PositionTracker(_checkpointStrategy.PositionTagger);
            _partitionStateCache        = new PartitionStateCache();
            GoToState(State.Initial);
        }
Пример #10
0
        public ProjectionSubscription(
            Guid projectionCorrelationId, CheckpointTag from,
            IHandle<ProjectionMessage.Projections.CommittedEventReceived> eventHandler,
            IHandle<ProjectionMessage.Projections.CheckpointSuggested> checkpointHandler,
            CheckpointStrategy checkpointStrategy, long? checkpointUnhandledBytesThreshold)
        {
            if (eventHandler == null) throw new ArgumentNullException("eventHandler");
            if (checkpointHandler == null) throw new ArgumentNullException("checkpointHandler");
            if (checkpointStrategy == null) throw new ArgumentNullException("checkpointStrategy");
            _eventHandler = eventHandler;
            _checkpointHandler = checkpointHandler;
            _checkpointStrategy = checkpointStrategy;
            _checkpointUnhandledBytesThreshold = checkpointUnhandledBytesThreshold;
            _projectionCorrelationId = projectionCorrelationId;
            _lastPassedOrCheckpointedEventPosition = from.Position;

            _eventFilter = checkpointStrategy.EventFilter;

            _positionTagger = checkpointStrategy.PositionTagger;
            _positionTracker = new PositionTracker(_positionTagger);
            _positionTracker.UpdateByCheckpointTagInitial(from);
        }
 public Subscribe(
     Guid correlationId, ICoreProjection subscriber, CheckpointTag from,
     CheckpointStrategy checkpointStrategy, long checkpointUnhandledBytesThreshold)
 {
     _correlationId = correlationId;
     _subscriber = subscriber;
     _fromPosition = @from;
     _checkpointStrategy = checkpointStrategy;
     _checkpointUnhandledBytesThreshold = checkpointUnhandledBytesThreshold;
 }
 public Subscribe(
     Guid correlationId, Guid subscriptionId, ICoreProjection subscriber, CheckpointTag from,
     CheckpointStrategy checkpointStrategy, long checkpointUnhandledBytesThreshold, bool stopOnEof = false)
 {
     if (subscriber == null) throw new ArgumentNullException("subscriber");
     if (@from == null) throw new ArgumentNullException("from");
     if (checkpointStrategy == null) throw new ArgumentNullException("checkpointStrategy");
     _correlationId = correlationId;
     _subscriptionId = subscriptionId;
     _subscriber = subscriber;
     _fromPosition = @from;
     _checkpointStrategy = checkpointStrategy;
     _checkpointUnhandledBytesThreshold = checkpointUnhandledBytesThreshold;
     _stopOnEof = stopOnEof;
 }