Esempio n. 1
0
 public Subscriber(
     IStandardLogger logger, IStreamClientFactory streamClientFactory, ISubscriptionListener subscriptionListener,
     IResolutionManager resolutionManager, ISortingManager sortingManager, IHandlingManager handlingManager,
     IStreamStateRepo streamStateRepo,
     SubscriberOptions options)
 {
     _logger = logger;
     _streamClientFactory  = streamClientFactory;
     _subscriptionListener = subscriptionListener;
     _resolutionManager    = resolutionManager;
     _sortingManager       = sortingManager;
     _handlingManager      = handlingManager;
     _streamStateRepo      = streamStateRepo;
     _options = options;
 }
        public ISubscriber Create(IStandardLogger logger, IStreamClientFactory streamClientFactory, IStreamStateRepo streamStateRepo, IBusinessEventResolver resolver, ISubscriberEventSorter sorter, ISubscriberEventHandler handler, SubscriberFactoryOptions factoryOptions, IList <SubscriptionStreamId> subscriptionStreamIds)
        {
            var handlingManagerAwaiter = new HandlingManagerAwaiter(factoryOptions.MaxParallelHandlerExecutions);
            var handlingQueue          = new HandlingQueue(new QueueAwaiter(), factoryOptions.MaxHandlingQueuesSharedSize);
            var handlerRunner          = new HandlingManagerHandlerRunner(logger, handlingManagerAwaiter, streamStateRepo, handler);
            var handlerTasks           = new HandlingManagerTaskCollection();
            var handlingManager        = new HandlingManager(logger, handlingManagerAwaiter, streamStateRepo, handlingQueue, handlerRunner, handlerTasks);

            var sortingQueue   = new SortingQueue(new QueueAwaiter(), factoryOptions.MaxSortingQueueSize);
            var sortingManager = new SortingManager(logger, sortingQueue, sorter, handlingManager);

            var resolutionQueue   = new ResolutionQueue(new QueueAwaiter(), factoryOptions.MaxResolutionQueueSize);
            var resolutionManager = new ResolutionManager(logger, resolver, streamStateRepo, resolutionQueue, sortingManager);

            var listener = new SubscriptionListener(logger, streamClientFactory, resolutionManager);

            var subscriberOptions = new SubscriberOptions(subscriptionStreamIds);

            return(new Subscriber(logger, streamClientFactory, listener, resolutionManager, sortingManager, handlingManager, streamStateRepo, subscriberOptions));
        }