public EventStoreClusterClientCache(IPublisher bus,
                                            Func <IPEndPoint, IPublisher, EventStoreClusterClient> clientFactory, TimeSpan?cacheCleaningInterval = null,
                                            TimeSpan?oldCacheItemThreshold = null)
        {
            _bus           = bus ?? throw new ArgumentNullException(nameof(bus));
            _clientFactory = clientFactory ?? throw new ArgumentNullException(nameof(clientFactory));

            _cacheCleaningInterval = cacheCleaningInterval ?? _cacheCleaningInterval;
            _oldCacheItemThreshold = oldCacheItemThreshold ?? _oldCacheItemThreshold;

            _publishEnvelope = new PublishEnvelope(_bus);
            _cache           = new MemoryCache(new MemoryCacheOptions {
                ExpirationScanFrequency = _oldCacheItemThreshold
            });
        }
 protected EventSubscriptionBasedProjectionProcessingPhase(
     IPublisher publisher,
     IPublisher inputQueue,
     ICoreProjectionForProcessingPhase coreProjection,
     Guid projectionCorrelationId,
     ICoreProjectionCheckpointManager checkpointManager,
     ProjectionConfig projectionConfig,
     string projectionName,
     ILogger logger,
     CheckpointTag zeroCheckpointTag,
     PartitionStateCache partitionStateCache,
     IResultWriter resultWriter,
     Action updateStatistics,
     ReaderSubscriptionDispatcher subscriptionDispatcher,
     IReaderStrategy readerStrategy,
     bool useCheckpoints,
     bool stopOnEof,
     bool orderedPartitionProcessing,
     bool isBiState,
     IEmittedStreamsTracker emittedStreamsTracker,
     bool enableContentTypeValidation)
 {
     _publisher               = publisher;
     _inputQueue              = inputQueue;
     _coreProjection          = coreProjection;
     _projectionCorrelationId = projectionCorrelationId;
     _checkpointManager       = checkpointManager;
     _projectionConfig        = projectionConfig;
     _projectionName          = projectionName;
     _logger              = logger;
     _zeroCheckpointTag   = zeroCheckpointTag;
     _partitionStateCache = partitionStateCache;
     _resultWriter        = resultWriter;
     _updateStatistics    = updateStatistics;
     _processingQueue     = new CoreProjectionQueue(publisher,
                                                    projectionConfig.PendingEventsThreshold,
                                                    orderedPartitionProcessing);
     _processingQueue.EnsureTickPending += EnsureTickPending;
     _subscriptionDispatcher             = subscriptionDispatcher;
     _readerStrategy              = readerStrategy;
     _useCheckpoints              = useCheckpoints;
     _stopOnEof                   = stopOnEof;
     _isBiState                   = isBiState;
     _progressResultWriter        = new ProgressResultWriter(this, _resultWriter);
     _inutQueueEnvelope           = new PublishEnvelope(_inputQueue);
     _emittedStreamsTracker       = emittedStreamsTracker;
     _enableContentTypeValidation = enableContentTypeValidation;
 }
Пример #3
0
        public ProjectionManager(
            IPublisher inputQueue, IPublisher publisher, IPublisher[] queues, ITimeProvider timeProvider,
            RunProjections runProjections, bool initializeSystemProjections = true)
        {
            if (inputQueue == null)
            {
                throw new ArgumentNullException("inputQueue");
            }
            if (publisher == null)
            {
                throw new ArgumentNullException("publisher");
            }
            if (queues == null)
            {
                throw new ArgumentNullException("queues");
            }
            if (queues.Length == 0)
            {
                throw new ArgumentException("At least one queue is required", "queues");
            }

            _inputQueue = inputQueue;
            _publisher  = publisher;
            _queues     = queues;

            _timeoutSchedulers = CreateTimeoutSchedulers(queues);

            _timeProvider   = timeProvider;
            _runProjections = runProjections;
            _initializeSystemProjections = initializeSystemProjections;

            _writeDispatcher =
                new RequestResponseDispatcher <ClientMessage.WriteEvents, ClientMessage.WriteEventsCompleted>(
                    publisher, v => v.CorrelationId, v => v.CorrelationId, new PublishEnvelope(_inputQueue));
            _readDispatcher =
                new RequestResponseDispatcher
                <ClientMessage.ReadStreamEventsBackward, ClientMessage.ReadStreamEventsBackwardCompleted>(
                    publisher, v => v.CorrelationId, v => v.CorrelationId, new PublishEnvelope(_inputQueue));


            _projectionStateHandlerFactory = new ProjectionStateHandlerFactory();
            _projections     = new Dictionary <string, ManagedProjection>();
            _projectionsMap  = new Dictionary <Guid, string>();
            _publishEnvelope = new PublishEnvelope(_inputQueue, crossThread: true);
        }
        public void setup0()
        {
            _envelope        = null;
            _timeProvider    = new FakeTimeProvider();
            _bus             = new InMemoryBus("bus");
            _queue           = null;
            _ioDispatcher    = new IODispatcher(_bus, new PublishEnvelope(GetInputQueue()));
            _readDispatcher  = _ioDispatcher.BackwardReader;
            _writeDispatcher = _ioDispatcher.Writer;

            _bus.Subscribe(_ioDispatcher.ForwardReader);
            _bus.Subscribe(_ioDispatcher.BackwardReader);
            _bus.Subscribe(_ioDispatcher.ForwardReader);
            _bus.Subscribe(_ioDispatcher.Writer);
            _bus.Subscribe(_ioDispatcher.StreamDeleter);
            _bus.Subscribe(_ioDispatcher);

            _consumer = new TestHandler <Message>();
            _bus.Subscribe(_consumer);
        }
Пример #5
0
        public ProjectionManager(
            IPublisher inputQueue,
            IPublisher publisher,
            IDictionary <Guid, IPublisher> queueMap,
            ITimeProvider timeProvider,
            ProjectionType runProjections,
            bool initializeSystemProjections = true)
        {
            if (inputQueue == null)
            {
                throw new ArgumentNullException("inputQueue");
            }
            if (publisher == null)
            {
                throw new ArgumentNullException("publisher");
            }
            if (queueMap == null)
            {
                throw new ArgumentNullException("queueMap");
            }
            if (queueMap.Count == 0)
            {
                throw new ArgumentException("At least one queue is required", "queueMap");
            }

            _inputQueue = inputQueue;
            _publisher  = publisher;
            _queues     = queueMap.Select(v => Tuple.Create(v.Key, v.Value)).ToArray();
            _workers    = _queues.Select(v => v.Item1).ToArray();

            _timeProvider   = timeProvider;
            _runProjections = runProjections;
            _initializeSystemProjections = initializeSystemProjections;

            _writeDispatcher =
                new RequestResponseDispatcher <ClientMessage.WriteEvents, ClientMessage.WriteEventsCompleted>(
                    publisher,
                    v => v.CorrelationId,
                    v => v.CorrelationId,
                    new PublishEnvelope(_inputQueue));
            _readDispatcher =
                new RequestResponseDispatcher
                <ClientMessage.ReadStreamEventsBackward, ClientMessage.ReadStreamEventsBackwardCompleted>(
                    publisher,
                    v => v.CorrelationId,
                    v => v.CorrelationId,
                    new PublishEnvelope(_inputQueue));
            _streamDispatcher =
                new RequestResponseDispatcher <ClientMessage.DeleteStream, ClientMessage.DeleteStreamCompleted>(
                    publisher,
                    v => v.CorrelationId,
                    v => v.CorrelationId,
                    new PublishEnvelope(_inputQueue));

            _projections        = new Dictionary <string, ManagedProjection>();
            _projectionsMap     = new Dictionary <Guid, string>();
            _publishEnvelope    = new PublishEnvelope(_inputQueue, crossThread: true);
            _getStateDispatcher =
                new RequestResponseDispatcher
                <CoreProjectionManagementMessage.GetState, CoreProjectionStatusMessage.StateReport>(
                    _publisher,
                    v => v.CorrelationId,
                    v => v.CorrelationId,
                    new PublishEnvelope(_inputQueue));
            _getResultDispatcher =
                new RequestResponseDispatcher
                <CoreProjectionManagementMessage.GetResult, CoreProjectionStatusMessage.ResultReport>(
                    _publisher,
                    v => v.CorrelationId,
                    v => v.CorrelationId,
                    new PublishEnvelope(_inputQueue));
        }