Exemple #1
0
        // Called by derived classes to set up event pipeline subscriptions
        protected bool Start(
            IObservable <IDictionary <string, object> > eventStream,
            string eventStreamName,
            bool realTimeMode,
            ISubject <IDictionary <string, object> > subject = null)
        {
            _eventStream = eventStream;

            // Sending event stream to next stage in event pipeline
            if (subject != null)
            {
                // Input stream goes to custom actions
                _intermediateSubscription = _eventStream.Subscribe(subject.OnNext, subject.OnError, subject.OnCompleted);

                // Custom actions go to output
                _outputSubscription = subject.Subscribe(_output.OutputAction, _output.OutputError, Stop);
            }
            else if (_queries == null || _queries.Length == 0 || string.IsNullOrEmpty(_queries[0]))
            {
                // Input stream goes straight to output
                _outputSubscription = _eventStream.Subscribe(_output.OutputAction, _output.OutputError, Stop);
            }
            else
            {
                // Input stream goes through Rx.Kql before hitting output
                _eventProcessor = new EventProcessor(
                    _eventStream, eventStreamName,
                    _output,
                    realTimeMode,
                    _queries);
                return(_eventProcessor.ApplyRxKql());
            }

            return(true);
        }
Exemple #2
0
        protected EventComponent(IOutput output, params string[] queries)
        {
            _running = true;
            _output  = output;
            _queries = queries;

            _eventStream              = null;
            _eventProcessor           = null;
            _outputSubscription       = null;
            _intermediateSubscription = null;

            // Setting up clean-up code for exit
            _cancelEventHandler = delegate(object sender, ConsoleCancelEventArgs eventArgs) {
                if (_running)
                {
                    Stop();
                }
                else
                {
                    Console.CancelKeyPress -= _cancelEventHandler;
                }
            };
            Console.CancelKeyPress += _cancelEventHandler;
        }