Example #1
0
        public MainWindow(ISubscriber<PlayerCommand> commandChannel, IPublisher<RichYouTubeClip> finishedChannel)
        {
            InitializeComponent();
            this.finishedChannel = finishedChannel;

            finishedTimer = new Timer(TimerExpired);

            progressTimer = new System.Timers.Timer(1000);
            progressTimer.AutoReset = true;
            progressTimer.Elapsed += new System.Timers.ElapsedEventHandler(progressTimer_Elapsed);

            var fiber     = new DispatcherFiber(Dispatcher);
            commandChannel.Subscribe(fiber, OnPlayerCommand);
            fiber.Start();

            WindowStyle = WindowStyle.None;
            WindowState = WindowState.Maximized;
            ShowInTaskbar = false;

            Cursor = Cursors.None;
            try
            {
                tv.Initialize();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error initialize remote control", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
		public DomainParticipantTransportSource(IDomainParticipant participant, string senderTopic, string receiverTopic)
		{
			_participant = participant;

			var bdt = new ByteDataTypeSupport();
			var result = bdt.RegisterType(participant, bdt.TypeName);
			if (result != ReturnCode.Ok)
				throw new Exception("Unable to register type: " + result);

			_publisher = _participant.CreatePublisher();
			_subscriber = _participant.CreateSubscriber();

			var senderTopicQos = new TopicQos();
			participant.GetDefaultTopicQos(ref senderTopicQos);

			var receiverTopicQos = new TopicQos();
			participant.GetDefaultTopicQos(ref receiverTopicQos);

			_senderTopic = participant.CreateTopic(senderTopic, bdt.TypeName, senderTopicQos);
			_receiverTopic = participant.CreateTopic(receiverTopic, bdt.TypeName, receiverTopicQos);

			_dataWriter = (ByteDataWriter)_publisher.CreateDataWriter(_senderTopic);
			_dataToSendHandle = _dataWriter.RegisterInstance(_dataToSend);

			var dataReaderQos = new DataReaderQos();
			_subscriber.GetDefaultDataReaderQos(ref dataReaderQos);
			_dataReader = (ByteDataReader)_subscriber.CreateDataReader(_receiverTopic, dataReaderQos, this, StatusKind.Any);
		}
Example #3
0
		public ApiModule(ICompositeApp compositeApp, ICommandRegistry registry, IPublisher publisher)
			: base(BaseRoute)
		{
			_compositeApp = compositeApp;
			_registry = registry;
			_publisher = publisher;

			Get[string.Empty] = _ => GetComposite();

			Get[AgentMetadataRoute] = p => GetAgent(stripExtension((string)p.agentSystemName));

			Get[ReadModelMetadataRoute] = p => GetReadModel((string)p.agentSystemName, stripExtension((string)p.readModelName));

			Get[InputModelMetadataRoute] = p => GetInputModel(stripExtension((string)p.inputModelName));

			Get[PublicationRecordRoute] = p => GetPublicationRecord((Guid)p.identifier);

			Get[InputModelMetadataForCommandRoute] = p => GetInputModelMetadata(stripExtension((string)p.commandName));

			Get[CommandMetadataRoute] = p => GetCommandMetadata(stripExtension((string)p.commandName));

			Get[QueryMetadataRoute] = p => GetQueryMetadata(stripExtension((string)p.queryName));

			Get[CommandIsSupportedRoute] = p => GetCommandIsSupported(stripExtension((string)p.commandName));

			Get[QueryForReadModelRoute] = p => QueryForReadmodel((string)p.queryName, (string)p.methodName);

			Get[QueryMethodRoute] = p => GetQueryMethod((string) p.queryName, (string) p.methodName);

			Post[PublishCommandRoute] = p => PublishCommand(this.Bind<IInputModel>());
		}
        public SlaveResultWriter(IPublisher resultsPublisher, Guid masterCoreProjectionId)
        {
            if (resultsPublisher == null) throw new ArgumentNullException("resultsPublisher");

            _resultsPublisher = resultsPublisher;
            _masterCoreProjectionId = masterCoreProjectionId;
        }
        protected CommunicationController(IPublisher publisher)
        {
            Ensure.NotNull(publisher, "publisher");

            _publisher = publisher;
            Client = new HttpAsyncClient();
        }
        /// <summary>
        /// Instantiates a <see cref="MarketDataSubscription"/>
        /// </summary>
        /// <param name="logger">The logger</param>
        /// <param name="repositoryFactory">The repository to store and retrieve market data</param>
        /// <param name="marketDataProvider">The provider for refreshing market data</param>
        /// <param name="stockListProvider">The provider for lists of stocks for which to retrieve data</param>
        /// <param name="quotesPublisher"></param>
        /// <param name="subscriptionData">The subscriptionData data for determining</param>
        public MarketDataSubscription(ILog logger,
            IMarketDataRepositoryFactory repositoryFactory,
            IMarketDataProvider marketDataProvider,
            IStockListProvider stockListProvider,
            IPublisher<NewQuotesData> quotesPublisher,
            Subscription subscriptionData)
        {
            // perform null checks
            if (logger == null)
                throw new ArgumentNullException("logger");
            if (repositoryFactory == null)
                throw new ArgumentNullException("repositoryFactory");
            if (marketDataProvider == null)
                throw new ArgumentNullException("marketDataProvider");
            if (subscriptionData == null)
                throw new ArgumentNullException("subscriptionData");

            // set dependencies
            _logger = logger;
            _repositoryFactory = repositoryFactory;
            _marketDataProvider = marketDataProvider;
            _stockListProvider = stockListProvider;
            _quotesPublisher = quotesPublisher;
            _subscriptionData = subscriptionData;

            // set up timer
            _timer = new Timer(obj => GetLatestQuotes());

            // status initialized to idle
            Status = SubscriptionStatus.Idle;
        }
		public IAuthenticationProvider BuildAuthenticationProvider(IPublisher mainQueue, IBus mainBus, IPublisher workersQueue, InMemoryBus[] workerBusses)
		{
			var passwordHashAlgorithm = new Rfc2898PasswordHashAlgorithm();
			var dispatcher = new IODispatcher(mainQueue, new PublishEnvelope(workersQueue, crossThread: true));
			
			foreach (var bus in workerBusses) {
				bus.Subscribe(dispatcher.ForwardReader);
				bus.Subscribe(dispatcher.BackwardReader);
				bus.Subscribe(dispatcher.Writer);
				bus.Subscribe(dispatcher.StreamDeleter);
				bus.Subscribe(dispatcher);
			}

			// USER MANAGEMENT
			var ioDispatcher = new IODispatcher(mainQueue, new PublishEnvelope(mainQueue));
			mainBus.Subscribe(ioDispatcher.BackwardReader);
			mainBus.Subscribe(ioDispatcher.ForwardReader);
			mainBus.Subscribe(ioDispatcher.Writer);
			mainBus.Subscribe(ioDispatcher.StreamDeleter);
			mainBus.Subscribe(ioDispatcher);

			var userManagement = new UserManagementService(mainQueue, ioDispatcher, passwordHashAlgorithm, skipInitializeStandardUsersCheck: false);
			mainBus.Subscribe<UserManagementMessage.Create>(userManagement);
			mainBus.Subscribe<UserManagementMessage.Update>(userManagement);
			mainBus.Subscribe<UserManagementMessage.Enable>(userManagement);
			mainBus.Subscribe<UserManagementMessage.Disable>(userManagement);
			mainBus.Subscribe<UserManagementMessage.Delete>(userManagement);
			mainBus.Subscribe<UserManagementMessage.ResetPassword>(userManagement);
			mainBus.Subscribe<UserManagementMessage.ChangePassword>(userManagement);
			mainBus.Subscribe<UserManagementMessage.Get>(userManagement);
			mainBus.Subscribe<UserManagementMessage.GetAll>(userManagement);
			mainBus.Subscribe<SystemMessage.BecomeMaster>(userManagement);
			
			return new InternalAuthenticationProvider(dispatcher, passwordHashAlgorithm, ESConsts.CachedPrincipalCount);
		}
		public void Setup()
		{

			_testCommand = A.Fake<ICommand>();
			_publisher = A.Fake<IPublisher>();
			_compositeApp = A.Fake<ICompositeApp>();
			_registry = A.Fake<ICommandRegistry>();
			_formatter = A.Fake<IResponseFormatter>();
			_publicationRecord = A.Fake<ICommandPublicationRecord>();
			_jsonSerializer = new DefaultJsonSerializer();
			_xmlSerializer = new DefaultXmlSerializer();

			A.CallTo(() => _testCommand.Created).Returns(DateTime.MaxValue);
			A.CallTo(() => _testCommand.CreatedBy).Returns(new Guid("ba5f18dc-e287-4d9e-ae71-c6989b10d778"));
			A.CallTo(() => _testCommand.Identifier).Returns(new Guid("ba5f18dc-e287-4d9e-ae71-c6989b10d778"));
			A.CallTo(() => _formatter.Serializers).Returns(new List<ISerializer> { _jsonSerializer, _xmlSerializer });
			A.CallTo(() => _publicationRecord.Dispatched).Returns(true);
			A.CallTo(() => _publicationRecord.Error).Returns(false);
			A.CallTo(() => _publicationRecord.Completed).Returns(true);
			A.CallTo(() => _publicationRecord.Created).Returns(DateTime.MinValue);
			A.CallTo(() => _publicationRecord.MessageLocation).Returns(new Uri("http://localhost/fake/message"));
			A.CallTo(() => _publicationRecord.MessageType).Returns(typeof(IPublicationRecord));
			A.CallTo(() => _publicationRecord.CreatedBy).Returns(Guid.Empty);
			A.CallTo(() => _compositeApp.GetCommandForInputModel(A.Dummy<IInputModel>())).Returns(_testCommand);
			A.CallTo(() => _publisher.PublishMessage(A.Fake<ICommand>())).Returns(_publicationId);
			A.CallTo(() => _registry.GetPublicationRecord(_publicationId)).Returns(_publicationRecord);

			_euclidApi = new ApiModule(_compositeApp, _registry, _publisher);
		}
 protected CoreProjectionCheckpointManager(
     ICoreProjection coreProjection, IPublisher publisher, Guid projectionCorrelationId,
     RequestResponseDispatcher
         <ClientMessage.ReadStreamEventsBackward, ClientMessage.ReadStreamEventsBackwardCompleted> readDispatcher,
     RequestResponseDispatcher<ClientMessage.WriteEvents, ClientMessage.WriteEventsCompleted> writeDispatcher,
     ProjectionConfig projectionConfig, string name,
     PositionTagger positionTagger)
 {
     if (coreProjection == null) throw new ArgumentNullException("coreProjection");
     if (publisher == null) throw new ArgumentNullException("publisher");
     if (readDispatcher == null) throw new ArgumentNullException("readDispatcher");
     if (writeDispatcher == null) throw new ArgumentNullException("writeDispatcher");
     if (projectionConfig == null) throw new ArgumentNullException("projectionConfig");
     if (name == null) throw new ArgumentNullException("name");
     if (positionTagger == null) throw new ArgumentNullException("positionTagger");
     if (name == "") throw new ArgumentException("name");
     _lastProcessedEventPosition = new PositionTracker(positionTagger);
     _coreProjection = coreProjection;
     _publisher = publisher;
     _projectionCorrelationId = projectionCorrelationId;
     _readDispatcher = readDispatcher;
     _writeDispatcher = writeDispatcher;
     _projectionConfig = projectionConfig;
     _logger = LogManager.GetLoggerFor<CoreProjectionCheckpointManager>();
     _name = name;
     _positionTagger = positionTagger;
 }
 protected override IProjectionProcessingPhase[] CreateProjectionProcessingPhases(
     IPublisher publisher, Guid projectionCorrelationId, ProjectionNamesBuilder namingBuilder,
     PartitionStateCache partitionStateCache, CoreProjection coreProjection, IODispatcher ioDispatcher,
     IProjectionProcessingPhase firstPhase)
 {
     return new[] {firstPhase};
 }
        protected CoreProjectionCheckpointManager(
            IPublisher publisher, Guid projectionCorrelationId, ProjectionConfig projectionConfig, string name,
            PositionTagger positionTagger, ProjectionNamesBuilder namingBuilder, bool usePersistentCheckpoints,
            bool producesRunningResults)
        {
            if (publisher == null) throw new ArgumentNullException("publisher");
            if (projectionConfig == null) throw new ArgumentNullException("projectionConfig");
            if (name == null) throw new ArgumentNullException("name");
            if (positionTagger == null) throw new ArgumentNullException("positionTagger");
            if (namingBuilder == null) throw new ArgumentNullException("namingBuilder");
            if (name == "") throw new ArgumentException("name");

            _lastProcessedEventPosition = new PositionTracker(positionTagger);
            _zeroTag = positionTagger.MakeZeroCheckpointTag();

            _publisher = publisher;
            _projectionCorrelationId = projectionCorrelationId;
            _projectionConfig = projectionConfig;
            _logger = LogManager.GetLoggerFor<CoreProjectionCheckpointManager>();
            _namingBuilder = namingBuilder;
            _usePersistentCheckpoints = usePersistentCheckpoints;
            _producesRunningResults = producesRunningResults;
            _requestedCheckpointState = new PartitionState("", null, _zeroTag);
            _currentProjectionState = new PartitionState("", null, _zeroTag);
        }
        protected override IProjectionProcessingPhase[] CreateProjectionProcessingPhases(
            IPublisher publisher, Guid projectionCorrelationId, ProjectionNamesBuilder namingBuilder,
            PartitionStateCache partitionStateCache, CoreProjection coreProjection, IODispatcher ioDispatcher,
            IProjectionProcessingPhase firstPhase)
        {

            var coreProjectionCheckpointWriter =
                new CoreProjectionCheckpointWriter(
                    namingBuilder.MakeCheckpointStreamName(), ioDispatcher, _projectionVersion, _name);
            var checkpointManager2 = new DefaultCheckpointManager(
                publisher, projectionCorrelationId, _projectionVersion, _projectionConfig.RunAs, ioDispatcher,
                _projectionConfig, _name, new PhasePositionTagger(1), namingBuilder, GetUseCheckpoints(), false,
                _sourceDefinition.DefinesFold, coreProjectionCheckpointWriter);

            IProjectionProcessingPhase writeResultsPhase;
            if (GetProducesRunningResults()
                || !string.IsNullOrEmpty(_sourceDefinition.CatalogStream) && _sourceDefinition.ByStreams)
                writeResultsPhase = new WriteQueryEofProjectionProcessingPhase(
                    1, namingBuilder.GetResultStreamName(), coreProjection, partitionStateCache, checkpointManager2,
                    checkpointManager2);
            else
                writeResultsPhase = new WriteQueryResultProjectionProcessingPhase(
                    1, namingBuilder.GetResultStreamName(), coreProjection, partitionStateCache, checkpointManager2,
                    checkpointManager2);

            return new[] {firstPhase, writeResultsPhase};
        }
 public ProjectsController(IProjectsService projects, IUsersService users, IImagesService images, IPublisher publisher)
 {
     this.projects = projects;
     this.users = users;
     this.images = images;
     this.publisher = publisher;
 }
Example #14
0
        public NotificationService(IBus bus, ILogger logger, ILogEventBuilder eventBuilder)
        {
            _repository = new NotificationRepository();
            _notificationPlayerRepository = new NotificationPlayerRepository();
            _notificationRepository = new NotificationRepository();
            //_publisher = new RabbitMqPublisher()
            //{
            //    MessageLookups = new List<MessageConfig>()
            //    {
            //        new MessageConfig()
            //        {
            //            ExchangeName = "PB.Events",
            //            MessageType = typeof (NotificationCreated),
            //            RoutingKey = ""
            //        }
            //    }
            //};

            _bus = bus;
            _logger = logger;
            _eventBuilder = eventBuilder;

            _publisher = new RabbitMqPublisher(ConfigurationManager.AppSettings["Queue.Uri"])
            {
                MessageLookups = new List<MessageConfig>()
                {
                    new MessageConfig()
                    {
                        ExchangeName = "PB.Events",
                        MessageType = typeof (NotificationCreated),
                        RoutingKey = ""
                    }
                }
            };
        }
Example #15
0
 public EventDistributionPoint CreatePausedEventDistributionPoint(Guid distributionPointId, IPublisher publisher, CheckpointTag checkpointTag)
 {
     if (_allStreams)
     {
         var distributionPoint = new TransactionFileReaderEventDistributionPoint(
             publisher, distributionPointId,
             new EventPosition(checkpointTag.CommitPosition.Value, checkpointTag.PreparePosition.Value));
         return distributionPoint;
     }
     else if (_streams != null && _streams.Count == 1)
     {
         var streamName = checkpointTag.Streams.Keys.First();
         //TODO: handle if not the same
         return CreatePausedStreamReaderEventDistributionPoint(distributionPointId, publisher, checkpointTag, streamName,
             resolveLinkTos: true, category: null);
     }
     else if (_categories != null && _categories.Count == 1)
     {
         var streamName = checkpointTag.Streams.Keys.First();
         return CreatePausedStreamReaderEventDistributionPoint(distributionPointId, publisher, checkpointTag, streamName,
             resolveLinkTos: true, category: _categories.First());
     }
     else
         throw new NotSupportedException();
 }
        protected CoreProjectionCheckpointManager(
            ICoreProjection coreProjection, IPublisher publisher, Guid projectionCorrelationId,
            RequestResponseDispatcher<ClientMessage.ReadStreamEventsBackward, ClientMessage.ReadStreamEventsBackwardCompleted> readDispatcher,
            RequestResponseDispatcher<ClientMessage.WriteEvents, ClientMessage.WriteEventsCompleted> writeDispatcher,
            ProjectionConfig projectionConfig, string name, PositionTagger positionTagger,
            ProjectionNamesBuilder namingBuilder, bool useCheckpoints, bool emitStateUpdated,
            bool emitPartitionCheckpoints)
        {
            if (coreProjection == null) throw new ArgumentNullException("coreProjection");
            if (publisher == null) throw new ArgumentNullException("publisher");
            if (readDispatcher == null) throw new ArgumentNullException("readDispatcher");
            if (writeDispatcher == null) throw new ArgumentNullException("writeDispatcher");
            if (projectionConfig == null) throw new ArgumentNullException("projectionConfig");
            if (name == null) throw new ArgumentNullException("name");
            if (positionTagger == null) throw new ArgumentNullException("positionTagger");
            if (namingBuilder == null) throw new ArgumentNullException("namingBuilder");
            if (name == "") throw new ArgumentException("name");

            if (emitPartitionCheckpoints && emitStateUpdated)
                throw new InvalidOperationException("EmitPartitionCheckpoints && EmitStateUpdated cannot be both set");
            _lastProcessedEventPosition = new PositionTracker(positionTagger);
            _coreProjection = coreProjection;
            _publisher = publisher;
            _projectionCorrelationId = projectionCorrelationId;
            _readDispatcher = readDispatcher;
            _writeDispatcher = writeDispatcher;
            _projectionConfig = projectionConfig;
            _logger = LogManager.GetLoggerFor<CoreProjectionCheckpointManager>();
            _name = name;
            _positionTagger = positionTagger;
            _namingBuilder = namingBuilder;
            _useCheckpoints = useCheckpoints;
            _emitStateUpdated = emitStateUpdated;
            _emitPartitionCheckpoints = emitPartitionCheckpoints;
        }
        public ReadIndex(IPublisher bus,
                         int readerCount,
                         Func<ITransactionFileSequentialReader> seqReaderFactory,
                         Func<ITransactionFileReader> readerFactory,
                         ITableIndex tableIndex,
                         IHasher hasher,
                         ILRUCache<string, StreamCacheInfo> streamInfoCache)
        {
            Ensure.NotNull(bus, "bus");
            Ensure.Positive(readerCount, "readerCount");
            Ensure.NotNull(seqReaderFactory, "seqReaderFactory");
            Ensure.NotNull(readerFactory, "readerFactory");
            Ensure.NotNull(tableIndex, "tableIndex");
            Ensure.NotNull(hasher, "hasher");
            Ensure.NotNull(streamInfoCache, "streamInfoCache");

            _bus = bus;
            _tableIndex = tableIndex;
            _hasher = hasher;
            _streamInfoCache = streamInfoCache;

            for (int i = 0; i < readerCount; ++i)
            {
                _seqReaders.Push(seqReaderFactory());
                _readers.Push(readerFactory());
            }
        }
        public WriteQueryResultProjectionProcessingPhaseBase(
            IPublisher publisher,
            int phase,
            string resultStream,
            ICoreProjectionForProcessingPhase coreProjection,
            PartitionStateCache stateCache,
            ICoreProjectionCheckpointManager checkpointManager,
            IEmittedEventWriter emittedEventWriter,
            IEmittedStreamsTracker emittedStreamsTracker)
        {
            if (resultStream == null) throw new ArgumentNullException("resultStream");
            if (coreProjection == null) throw new ArgumentNullException("coreProjection");
            if (stateCache == null) throw new ArgumentNullException("stateCache");
            if (checkpointManager == null) throw new ArgumentNullException("checkpointManager");
            if (emittedEventWriter == null) throw new ArgumentNullException("emittedEventWriter");
            if (emittedStreamsTracker == null) throw new ArgumentNullException("emittedStreamsTracker");
            if (string.IsNullOrEmpty(resultStream)) throw new ArgumentException("resultStream");

            _publisher = publisher;
            _phase = phase;
            _resultStream = resultStream;
            _coreProjection = coreProjection;
            _stateCache = stateCache;
            _checkpointManager = checkpointManager;
            _emittedEventWriter = emittedEventWriter;
            _emittedStreamsTracker = emittedStreamsTracker;
        }
Example #19
0
        public Subscriber(IPublisher publisher, TextWriter textWriter)
        {
            _textWriter = textWriter;

            if (publisher != null)
                publisher.WriteEvent += HandleWriteEvent;
        }
        public EventStoreEmbeddedNodeConnection(ConnectionSettings settings, string connectionName, IPublisher publisher, ISubscriber bus, IAuthenticationProvider authenticationProvider)
        {
            Ensure.NotNull(publisher, "publisher");
            Ensure.NotNull(settings, "settings");

            Guid connectionId = Guid.NewGuid();

            _settings = settings;
            _connectionName = connectionName;
            _publisher = publisher;
            _authenticationProvider = authenticationProvider;
            _subscriptionBus = new InMemoryBus("Embedded Client Subscriptions");
            _subscriptions = new EmbeddedSubscriber(_subscriptionBus, _authenticationProvider, _settings.Log, connectionId);
            
            _subscriptionBus.Subscribe<ClientMessage.SubscriptionConfirmation>(_subscriptions);
            _subscriptionBus.Subscribe<ClientMessage.SubscriptionDropped>(_subscriptions);
            _subscriptionBus.Subscribe<ClientMessage.StreamEventAppeared>(_subscriptions);
            _subscriptionBus.Subscribe<ClientMessage.PersistentSubscriptionConfirmation>(_subscriptions);
            _subscriptionBus.Subscribe<ClientMessage.PersistentSubscriptionStreamEventAppeared>(_subscriptions);
            _subscriptionBus.Subscribe(new AdHocHandler<ClientMessage.SubscribeToStream>(_publisher.Publish));
            _subscriptionBus.Subscribe(new AdHocHandler<ClientMessage.UnsubscribeFromStream>(_publisher.Publish));
            _subscriptionBus.Subscribe(new AdHocHandler<ClientMessage.ConnectToPersistentSubscription>(_publisher.Publish));

            bus.Subscribe(new AdHocHandler<SystemMessage.BecomeShutdown>(_ => Disconnected(this, new ClientConnectionEventArgs(this, new IPEndPoint(IPAddress.None, 0)))));
        }
 private ProjectionManagerNode(IPublisher inputQueue, IPublisher[] queues, RunProjections runProjections)
 {
     _runProjections = runProjections;
     _output = new InMemoryBus("ProjectionManagerOutput");
     _projectionManager = new ProjectionManager(
         inputQueue, _output, queues, new RealTimeProvider(), runProjections);
 }
 public static void DispatchCommit(IPublisher bus, ICommit commit)
 {
     foreach (var @event in commit.Events)
     {
         bus.Publish(@event.Body);
     }
 }
Example #23
0
        public FakeMailWindow(IPublisher<MailMessage> messageChannel)
        {
            InitializeComponent();

            this.messageChannel = messageChannel;
            ResetMail();
        }
Example #24
0
 public void Invoke(IPublisher publisher)
 {
     var result = findEntryPoint();
       // Just for reference, considering we call the method a single time
       //var @delegate = (Action<IPublisher>)Delegate.CreateDelegate(typeof(Action<IPublisher>), result, true);
       result.Invoke(null, new object[] { publisher });
 }
 public void SetUp()
 {
     channelMock = MockRepository.GenerateStub<IModel>();
     eventBus = MockRepository.GenerateStub<IEventBus>();
     
     publisher = new PublisherBasic(eventBus);
 }
 public ElectionsInstance(Guid instanceId, IPEndPoint endPoint, IPublisher inputBus, IPublisher outputBus)
 {
     InstanceId = instanceId;
     EndPoint = endPoint;
     InputBus = inputBus;
     OutputBus = outputBus;
 }
Example #27
0
 public static void Bin4Net(IPublisher publisher)
 {
     publisher
     .SetupMetadata(m => m
                       .FromAssemblyAttributes()
                       .AssociateWithTags("tool", "acme"));
 }
        public override sealed IProjectionProcessingPhase[] CreateProcessingPhases(
            IPublisher publisher, Guid projectionCorrelationId, PartitionStateCache partitionStateCache,
            Action updateStatistics, CoreProjection coreProjection, ProjectionNamesBuilder namingBuilder,
            ITimeProvider timeProvider, IODispatcher ioDispatcher,
            CoreProjectionCheckpointWriter coreProjectionCheckpointWriter)
        {
            var definesFold = _sourceDefinition.DefinesFold;

            var readerStrategy = CreateReaderStrategy(timeProvider);

            var zeroCheckpointTag = readerStrategy.PositionTagger.MakeZeroCheckpointTag();

            var checkpointManager = CreateCheckpointManager(
                projectionCorrelationId, publisher, ioDispatcher, namingBuilder, coreProjectionCheckpointWriter,
                definesFold, readerStrategy);


            var resultWriter = CreateFirstPhaseResultWriter(
                checkpointManager as IEmittedEventWriter, zeroCheckpointTag, namingBuilder);

            var firstPhase = CreateFirstProcessingPhase(
                publisher, projectionCorrelationId, partitionStateCache, updateStatistics, coreProjection,
                _subscriptionDispatcher, zeroCheckpointTag, checkpointManager, readerStrategy, resultWriter);

            return CreateProjectionProcessingPhases(
                publisher, projectionCorrelationId, namingBuilder, partitionStateCache, coreProjection, ioDispatcher,
                firstPhase);
        }
Example #29
0
 public SubscriberCreator(IPublisher publisher)
 {
     if (publisher==null)
     {
         throw new NullReferenceException("Publisher should not be null");
     }
 }
        protected ReaderSubscriptionBase(
            IPublisher publisher,
            Guid subscriptionId,
            CheckpointTag @from,
            IReaderStrategy readerStrategy,
            ITimeProvider timeProvider,
            long? checkpointUnhandledBytesThreshold,
            int? checkpointProcessedEventsThreshold,
            bool stopOnEof,
            int? stopAfterNEvents)
        {
            if (publisher == null) throw new ArgumentNullException("publisher");
            if (readerStrategy == null) throw new ArgumentNullException("readerStrategy");
            if (timeProvider == null) throw new ArgumentNullException("timeProvider");
            if (checkpointProcessedEventsThreshold > 0 && stopAfterNEvents > 0)
                throw new ArgumentException("checkpointProcessedEventsThreshold > 0 && stopAfterNEvents > 0");

            _publisher = publisher;
            _readerStrategy = readerStrategy;
            _timeProvider = timeProvider;
            _checkpointUnhandledBytesThreshold = checkpointUnhandledBytesThreshold;
            _checkpointProcessedEventsThreshold = checkpointProcessedEventsThreshold;
            _stopOnEof = stopOnEof;
            _stopAfterNEvents = stopAfterNEvents;
            _subscriptionId = subscriptionId;
            _lastPassedOrCheckpointedEventPosition = null;

            _eventFilter = readerStrategy.EventFilter;

            _positionTagger = readerStrategy.PositionTagger;
            _positionTracker = new PositionTracker(_positionTagger);
            _positionTracker.UpdateByCheckpointTagInitial(@from);
        }
Example #31
0
 public DomainEventService(ILogger <DomainEventService> logger, IPublisher mediator)
 {
     _logger   = logger;
     _mediator = mediator;
 }
 public AdminController(IPublisher publisher, IPublisher networkSendQueue) : base(publisher)
 {
     _networkSendQueue = networkSendQueue;
 }
Example #33
0
 public GenerateController(IPublisher publisher)
 {
     _publisher = publisher;
 }
Example #34
0
 public EventStorage(IEventStoreConnection connection, IPublisher publisher)
 {
     connection_ = connection;
     publisher_  = publisher;
 }
Example #35
0
        private void SetUpCoreServices(
            Guid workerId,
            IBus bus,
            IPublisher inputQueue,
            InMemoryBus output_,
            ISingletonTimeoutScheduler timeoutScheduler)
        {
            var         output           = (output_ ?? inputQueue);
            ICheckpoint writerCheckpoint = new InMemoryCheckpoint(1000);
            var         readerService    = new EventReaderCoreService(
                output,
                _ioDispatcher,
                10,
                writerCheckpoint,
                runHeadingReader: true);

            _subscriptionDispatcher = new ReaderSubscriptionDispatcher(inputQueue);
            var spoolProcessingResponseDispatcher = new SpooledStreamReadingDispatcher(GetInputQueue());

            bus.Subscribe(
                _subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.CheckpointSuggested>());
            bus.Subscribe(
                _subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.CommittedEventReceived>());
            bus.Subscribe(_subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.EofReached>());
            bus.Subscribe(
                _subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.PartitionEofReached>());
            bus.Subscribe(_subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.PartitionMeasured>());
            bus.Subscribe(_subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.PartitionDeleted>());
            bus.Subscribe(_subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.ProgressChanged>());
            bus.Subscribe(
                _subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.SubscriptionStarted>());
            bus.Subscribe(_subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.NotAuthorized>());
            bus.Subscribe(
                _subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.ReaderAssignedReader>());
            bus.Subscribe(spoolProcessingResponseDispatcher.CreateSubscriber <PartitionProcessingResult>());

            var ioDispatcher = new IODispatcher(output, new PublishEnvelope(inputQueue));
//            var coreServiceCommandReader = new ProjectionCoreServiceCommandReader(
//                output,
//                ioDispatcher,
//                workerId.ToString("N"));

            var coreService = new ProjectionCoreService(
                workerId,
                inputQueue,
                output,
                _subscriptionDispatcher,
                _timeProvider,
                ioDispatcher,
                spoolProcessingResponseDispatcher,
                timeoutScheduler);

            bus.Subscribe <CoreProjectionManagementMessage.CreateAndPrepare>(coreService);
            bus.Subscribe <CoreProjectionManagementMessage.CreatePrepared>(coreService);
            bus.Subscribe <CoreProjectionManagementMessage.CreateAndPrepareSlave>(coreService);
            bus.Subscribe <CoreProjectionManagementMessage.Dispose>(coreService);
            bus.Subscribe <CoreProjectionManagementMessage.Start>(coreService);
            bus.Subscribe <CoreProjectionManagementMessage.LoadStopped>(coreService);
            bus.Subscribe <CoreProjectionManagementMessage.Stop>(coreService);
            bus.Subscribe <CoreProjectionManagementMessage.Kill>(coreService);
            bus.Subscribe <CoreProjectionManagementMessage.GetState>(coreService);
            bus.Subscribe <CoreProjectionManagementMessage.GetResult>(coreService);
            bus.Subscribe <CoreProjectionProcessingMessage.CheckpointCompleted>(coreService);
            bus.Subscribe <CoreProjectionProcessingMessage.CheckpointLoaded>(coreService);
            bus.Subscribe <CoreProjectionProcessingMessage.PrerecordedEventsLoaded>(coreService);
            bus.Subscribe <CoreProjectionProcessingMessage.RestartRequested>(coreService);
            bus.Subscribe <CoreProjectionProcessingMessage.Failed>(coreService);
            bus.Subscribe <ClientMessage.ReadStreamEventsForwardCompleted>(ioDispatcher.ForwardReader);
            bus.Subscribe <ClientMessage.ReadStreamEventsBackwardCompleted>(ioDispatcher.BackwardReader);
            bus.Subscribe <ClientMessage.WriteEventsCompleted>(ioDispatcher.Writer);
            bus.Subscribe <ClientMessage.DeleteStreamCompleted>(ioDispatcher.StreamDeleter);
            bus.Subscribe <IODispatcherDelayedMessage>(ioDispatcher.Awaker);
            bus.Subscribe <IODispatcherDelayedMessage>(ioDispatcher);
            bus.Subscribe <ProjectionCoreServiceMessage.StartCore>(coreService);
            bus.Subscribe <ProjectionCoreServiceMessage.StopCore>(coreService);
//            bus.Subscribe<ProjectionCoreServiceMessage.StartCore>(coreServiceCommandReader);
//            bus.Subscribe<ProjectionCoreServiceMessage.StopCore>(coreServiceCommandReader);
            bus.Subscribe <ReaderCoreServiceMessage.StartReader>(readerService);
            bus.Subscribe <ReaderCoreServiceMessage.StopReader>(readerService);
            bus.Subscribe <ProjectionCoreServiceMessage.CoreTick>(coreService);
            bus.Subscribe <ProjectionManagementMessage.SlaveProjectionsStarted>(coreService);
            bus.Subscribe <ReaderCoreServiceMessage.ReaderTick>(readerService);
            bus.Subscribe <ReaderSubscriptionMessage.CommittedEventDistributed>(readerService);
            bus.Subscribe <ReaderSubscriptionMessage.EventReaderEof>(readerService);
            bus.Subscribe <ReaderSubscriptionMessage.EventReaderPartitionEof>(readerService);
            bus.Subscribe <ReaderSubscriptionMessage.EventReaderPartitionDeleted>(readerService);
            bus.Subscribe <ReaderSubscriptionMessage.EventReaderPartitionMeasured>(readerService);
            bus.Subscribe <ReaderSubscriptionMessage.EventReaderNotAuthorized>(readerService);
            bus.Subscribe <ReaderSubscriptionMessage.EventReaderIdle>(readerService);
            bus.Subscribe <ReaderSubscriptionMessage.EventReaderStarting>(readerService);
            bus.Subscribe <ReaderSubscriptionManagement.Pause>(readerService);
            bus.Subscribe <ReaderSubscriptionManagement.Resume>(readerService);
            bus.Subscribe <ReaderSubscriptionManagement.Subscribe>(readerService);
            bus.Subscribe <ReaderSubscriptionManagement.Unsubscribe>(readerService);
            bus.Subscribe <ReaderSubscriptionManagement.SpoolStreamReadingCore>(readerService);
            bus.Subscribe <ReaderSubscriptionManagement.CompleteSpooledStreamReading>(readerService);

            if (output_ != null)
            {
                bus.Subscribe(new UnwrapEnvelopeHandler());
                output_.Subscribe(Forwarder.Create <CoreProjectionStatusMessage.StateReport>(GetInputQueue()));
                output_.Subscribe(Forwarder.Create <CoreProjectionStatusMessage.ResultReport>(GetInputQueue()));
                output_.Subscribe(Forwarder.Create <CoreProjectionStatusMessage.StatisticsReport>(GetInputQueue()));
                output_.Subscribe(Forwarder.Create <CoreProjectionStatusMessage.Started>(GetInputQueue()));
                output_.Subscribe(Forwarder.Create <CoreProjectionStatusMessage.Stopped>(GetInputQueue()));
                output_.Subscribe(Forwarder.Create <CoreProjectionStatusMessage.Faulted>(GetInputQueue()));
                output_.Subscribe(Forwarder.Create <CoreProjectionStatusMessage.Prepared>(GetInputQueue()));
                output_.Subscribe(
                    Forwarder.Create <CoreProjectionManagementMessage.SlaveProjectionReaderAssigned>(GetInputQueue()));
                output_.Subscribe(Forwarder.Create <CoreProjectionStatusMessage.ProjectionWorkerStarted>(GetInputQueue()));
                output_.Subscribe(Forwarder.Create <ProjectionManagementMessage.Command.ControlMessage>(GetInputQueue()));
                output_.Subscribe(Forwarder.Create <AwakeServiceMessage.SubscribeAwake>(GetInputQueue()));
                output_.Subscribe(Forwarder.Create <AwakeServiceMessage.UnsubscribeAwake>(GetInputQueue()));
                output_.Subscribe(Forwarder.Create <PartitionProcessingResultBase>(GetInputQueue()));
                output_.Subscribe(Forwarder.Create <ReaderSubscriptionManagement.SpoolStreamReading>(GetInputQueue()));
                output_.Subscribe(Forwarder.Create <PartitionProcessingResultOutputBase>(GetInputQueue()));
                output_.Subscribe(Forwarder.Create <Message>(inputQueue)); // forward all

                var forwarder = new RequestResponseQueueForwarder(
                    inputQueue: inputQueue,
                    externalRequestQueue: GetInputQueue());
                // forwarded messages
                output_.Subscribe <ClientMessage.ReadEvent>(forwarder);
                output_.Subscribe <ClientMessage.ReadStreamEventsBackward>(forwarder);
                output_.Subscribe <ClientMessage.ReadStreamEventsForward>(forwarder);
                output_.Subscribe <ClientMessage.ReadAllEventsForward>(forwarder);
                output_.Subscribe <ClientMessage.WriteEvents>(forwarder);
            }
        }
Example #36
0
 public LogLogic(IPublisher publisher)
 {
     _publisher = publisher;
 }
 public IEventReader CreatePausedEventReader(
     IPublisher publisher, IODispatcher ioDispatcher, Guid forkedEventReaderId)
 {
     throw new NotImplementedException();
 }
Example #38
0
 public StatisticalDisplay(IPublisher publisher)
 {
     this.publisher = publisher;
     publisher.Register(this);
 }
Example #39
0
 public Elections(IPublisher bus, IAuthorizationProvider authorizationProvider)
 {
     _bus = bus;
     _authorizationProvider = authorizationProvider ?? throw new ArgumentNullException(nameof(authorizationProvider));
 }
Example #40
0
 public void SetDependecies(ISaveManager saveManager, IAnimaManager animaManager, IPublisher publisher)
 {
     _saveManager  = saveManager;
     _animaManager = animaManager;
     _publisher    = publisher;
 }
Example #41
0
 public BusinessRulesBL(IPublisher <BusinessRulesDTO> notificationHub)
 {
     _notificationHub = notificationHub;
 }
Example #42
0
        public ClusterVNodeStartup(
            ISubsystem[] subsystems,
            IPublisher mainQueue,
            ISubscriber mainBus,
            MultiQueuedHandler httpMessageHandler,
            IAuthenticationProvider authenticationProvider,
            IReadOnlyList <IHttpAuthenticationProvider> httpAuthenticationProviders,
            IAuthorizationProvider authorizationProvider,
            IReadIndex readIndex,
            int maxAppendSize,
            KestrelHttpService httpService)
        {
            if (subsystems == null)
            {
                throw new ArgumentNullException(nameof(subsystems));
            }

            if (mainQueue == null)
            {
                throw new ArgumentNullException(nameof(mainQueue));
            }

            if (httpAuthenticationProviders == null)
            {
                throw new ArgumentNullException(nameof(httpAuthenticationProviders));
            }

            if (authorizationProvider == null)
            {
                throw new ArgumentNullException(nameof(authorizationProvider));
            }

            if (readIndex == null)
            {
                throw new ArgumentNullException(nameof(readIndex));
            }

            Ensure.Positive(maxAppendSize, nameof(maxAppendSize));

            if (httpService == null)
            {
                throw new ArgumentNullException(nameof(httpService));
            }

            if (mainBus == null)
            {
                throw new ArgumentNullException(nameof(mainBus));
            }
            _subsystems                  = subsystems;
            _mainQueue                   = mainQueue;
            _mainBus                     = mainBus;
            _httpMessageHandler          = httpMessageHandler;
            _authenticationProvider      = authenticationProvider;
            _httpAuthenticationProviders = httpAuthenticationProviders;
            _authorizationProvider       = authorizationProvider;
            _readIndex                   = readIndex;
            _maxAppendSize               = maxAppendSize;
            _httpService                 = httpService;

            _statusCheck = new StatusCheck(this);
        }
Example #43
0
 public EventBus(IPublisher publisher, ISubscriber subscriber)
 {
     Publisher  = publisher;
     Subscriber = subscriber;
 }
Example #44
0
 public StreamPuppet(IPublisher <int> p, TestKitBase kit)
 {
     _probe = kit.CreateManualSubscriberProbe <int>();
     p.Subscribe(_probe);
     _subscription = _probe.ExpectSubscription();
 }
Example #45
0
 public void SetPublisher(IPublisher publisher)
 {
     SetPublisher(publisher, null);
 }
 public AzureStorageService(AzureStoreConfiguration config, IPublisher publisher)
 {
     _publisher = publisher;
     _config    = config;
 }
Example #47
0
 public PayFirstProcessManager(IPublisher publisher)
 {
     _publisher = publisher;
 }
 public LegacyAuthorizationProviderFactory(IPublisher mainQueue)
 {
     _mainQueue = mainQueue;
 }
 public MarketMonitor(ILogger <TwitterBotCommand> log, IIndex <string, ISentimentTracking> twitterAnalysis, Func <IAnalysisManager> instance, IPublisher publisher)
 {
     this.log             = log ?? throw new ArgumentNullException(nameof(log));
     this.twitterAnalysis = twitterAnalysis?["Twitter"] ?? throw new ArgumentNullException(nameof(twitterAnalysis));
     this.instance        = instance ?? throw new ArgumentNullException(nameof(instance));
     this.publisher       = publisher;
 }
Example #50
0
        public void RegisterHttpControllers(HttpService externalHttpService, HttpService internalHttpService,
                                            HttpSendService httpSendService, IPublisher mainQueue, IPublisher networkSendQueue)
        {
            var usersController = new UsersController(httpSendService, mainQueue, networkSendQueue);

            externalHttpService.SetupController(usersController);
            if (internalHttpService != null)
            {
                internalHttpService.SetupController(usersController);
            }
        }
Example #51
0
 public FibonacciController(IPublisher publisher)
 {
     _publisher = publisher;
 }
Example #52
0
 public void SetPublisher(IPublisher publisher)
 {
     _publisher = publisher;
 }
 public MonsterB(IPublisher publisher, string name, int health = 50) : base(publisher, name, health)
 {
 }
Example #54
0
 public PublishEnvelope(IPublisher publisher)
 {
     _publisher = publisher;
 }
Example #55
0
 /// <summary>
 /// Constructor que al ser indicado el publicador se registra al mismo
 /// </summary>
 /// <param name="publisher"></param>
 public ForecastDisplay(IPublisher publisher)
 {
     _publisher = publisher;
     _publisher.RegisterSubscriber(this);
 }
Example #56
0
        public EventStoreEmbeddedNodeConnection(ConnectionSettings settings, string connectionName, IPublisher publisher, ISubscriber bus, IAuthenticationProvider authenticationProvider)
        {
            Ensure.NotNull(publisher, "publisher");
            Ensure.NotNull(settings, "settings");

            Guid connectionId = Guid.NewGuid();

            _settings               = settings;
            _connectionName         = connectionName;
            _publisher              = publisher;
            _authenticationProvider = authenticationProvider;
            _subscriptionBus        = new InMemoryBus("Embedded Client Subscriptions");
            _subscriptions          = new EmbeddedSubscriber(_subscriptionBus, _authenticationProvider, _settings.Log, connectionId);

            _subscriptionBus.Subscribe <ClientMessage.SubscriptionConfirmation>(_subscriptions);
            _subscriptionBus.Subscribe <ClientMessage.SubscriptionDropped>(_subscriptions);
            _subscriptionBus.Subscribe <ClientMessage.StreamEventAppeared>(_subscriptions);
            _subscriptionBus.Subscribe <ClientMessage.PersistentSubscriptionConfirmation>(_subscriptions);
            _subscriptionBus.Subscribe <ClientMessage.PersistentSubscriptionStreamEventAppeared>(_subscriptions);
            _subscriptionBus.Subscribe(new AdHocHandler <ClientMessage.SubscribeToStream>(_publisher.Publish));
            _subscriptionBus.Subscribe(new AdHocHandler <ClientMessage.UnsubscribeFromStream>(_publisher.Publish));
            _subscriptionBus.Subscribe(new AdHocHandler <ClientMessage.ConnectToPersistentSubscription>(_publisher.Publish));

            bus.Subscribe(new AdHocHandler <SystemMessage.BecomeShutdown>(_ => Disconnected(this, new ClientConnectionEventArgs(this, new IPEndPoint(IPAddress.None, 0)))));
        }
 public PublisherDelaySubscription(ISubscriber <T> actual, IPublisher <T> source)
 {
     this.actual = actual;
     this.source = source;
 }
Example #58
0
 public GossipController(IPublisher publisher, IPublisher networkSendQueue, TimeSpan gossipTimeout)
     : base(publisher)
 {
     _networkSendQueue = networkSendQueue;
     _gossipTimeout    = gossipTimeout;
 }
 public ManagedProjection(
     Guid workerId,
     Guid id,
     long projectionId,
     string name,
     bool enabledToRun,
     ILogger logger,
     RequestResponseDispatcher <ClientMessage.DeleteStream, ClientMessage.DeleteStreamCompleted> streamDispatcher,
     RequestResponseDispatcher <ClientMessage.WriteEvents, ClientMessage.WriteEventsCompleted> writeDispatcher,
     RequestResponseDispatcher
     <ClientMessage.ReadStreamEventsBackward, ClientMessage.ReadStreamEventsBackwardCompleted> readDispatcher,
     IPublisher output,
     ITimeProvider timeProvider,
     RequestResponseDispatcher <CoreProjectionManagementMessage.GetState, CoreProjectionStatusMessage.StateReport>
     getStateDispatcher,
     RequestResponseDispatcher
     <CoreProjectionManagementMessage.GetResult, CoreProjectionStatusMessage.ResultReport>
     getResultDispatcher,
     IODispatcher ioDispatcher,
     bool isSlave                  = false,
     Guid slaveMasterWorkerId      = default(Guid),
     Guid slaveMasterCorrelationId = default(Guid))
 {
     if (id == Guid.Empty)
     {
         throw new ArgumentException("id");
     }
     if (name == null)
     {
         throw new ArgumentNullException("name");
     }
     if (output == null)
     {
         throw new ArgumentNullException("output");
     }
     if (getStateDispatcher == null)
     {
         throw new ArgumentNullException("getStateDispatcher");
     }
     if (getResultDispatcher == null)
     {
         throw new ArgumentNullException("getResultDispatcher");
     }
     if (name == "")
     {
         throw new ArgumentException("name");
     }
     _workerId                 = workerId;
     _id                       = id;
     _projectionId             = projectionId;
     _name                     = name;
     _enabledToRun             = enabledToRun;
     _logger                   = logger ?? LogManager.GetLoggerFor <ManagedProjection>();
     _streamDispatcher         = streamDispatcher;
     _writeDispatcher          = writeDispatcher;
     _readDispatcher           = readDispatcher;
     _output                   = output;
     _timeProvider             = timeProvider;
     _isSlave                  = isSlave;
     _slaveMasterWorkerId      = slaveMasterWorkerId;
     _slaveMasterCorrelationId = slaveMasterCorrelationId;
     _getStateDispatcher       = getStateDispatcher;
     _getResultDispatcher      = getResultDispatcher;
     _lastAccessed             = _timeProvider.Now;
     _ioDispatcher             = ioDispatcher;
 }
Example #60
0
 public UsersController(IHttpForwarder httpForwarder, IPublisher publisher, IPublisher networkSendQueue)
     : base(publisher)
 {
     _httpForwarder    = httpForwarder;
     _networkSendQueue = networkSendQueue;
 }