///// <summary> ///// Create a new, ephermal metric to watch ///// </summary> ///// <param name="pipeline"></param> ///// <param name="jsAggregator"></param> ///// <param name="name"></param> ///// <param name="connection"></param> ///// <param name="connectionId"></param> //public JavascriptMetricConnection(EventPipeline pipeline, string jsAggregator, string name, IConnection connection, string connectionId, string javascriptId) { // _connection = connection; // _javascriptId = javascriptId; // _connectionId = connectionId; // var jsMetric = new JavascriptMetric(name, jsAggregator); // jsMetric.Updated(connectionId, Updated); // pipeline.AddProcessor(jsMetric); // SendUpdates(); //} /// <summary> /// Bind to an existing metric given by "name" /// </summary> /// <param name="pipeline"></param> /// <param name="name"></param> /// <param name="connection"></param> /// <param name="connectionId"></param> public JavascriptMetricConnection(EventPipeline pipeline, string name, IConnection connection, string connectionId, string javascriptId, string keyFilter, TimePeriod period) { _connection = connection; _connectionId = connectionId; _javascriptId = javascriptId; _timePeriod = period; _keyFilter = PeriodMetric.BaseKey(name, _timePeriod, keyFilter); if (string.IsNullOrEmpty(_keyFilter)) { _keyFilter = "*"; } // Try to find the metric, and add a watcher var processor = pipeline.GetProcessor(name); if (processor == null) { throw new Exception(string.Format("Unable to find metric with name {0}", name)); } var jsMetric = processor as JavascriptMetric; if (jsMetric == null) { throw new Exception(string.Format("Found metric with name {0}, but its not a JavascriptMetric", name)); } jsMetric.Updated(_connectionId, Updated); SendUpdates(); }
public void StaticServer_SetupPipeline_SimpleServer() { var pipelineId = new Guid("42C75D31-8679-49B4-B0EE-2B90D4C6B893").ToString(); var server = new ProcessingServer(); server.SetupPipeline(pipelineId, s => { s.Register(() => { var pipeline = new EventPipeline(); pipeline.AddHandler(new ConsoleOutputHandler()); return(pipeline); }); s.Register(new LogInputHandler()); }); var client = new EventDispatcher(server); client.Process(pipelineId, new LogMessage { Message = "SetupPipeline_SimpleServer" }); }
public void Server_CustomEventBus() { var pipelineId = Guid.NewGuid().ToString(); var cnt = 0; ProcessingServer.Server.SetupPipeline(pipelineId, s => { s.Register(() => { var pipeline = new EventPipeline(); pipeline.AddHandler(new ConsoleOutputHandler()); cnt = cnt + 1; return(pipeline); }); s.Register(new CustomEventBus(pipelineId)); s.Register(new CustomInputHandler()); }); var client = new EventDispatcher(); client.Process(pipelineId, new LogMessage { Message = "StaticServer_NewPipelinePerEvent1" }); client.Process(pipelineId, new LogMessage { Message = "StaticServer_NewPipelinePerEvent2" }); Assert.That(cnt == 1); }
public void EventDataInputHandler_EventDataFactoryExtension() { var pipelineId = Guid.NewGuid().ToString(); var logHandler = new LogQueueHandler(); ProcessingServer.Server.SetupPipeline(pipelineId, s => { s.Register(() => { var pipeline = new EventPipeline(); pipeline.AddHandler(new ConsoleOutputHandler()); pipeline.AddHandler(logHandler); return(pipeline); }); s.Register(new EventDataInputHandler()); }); var portalId = "portal"; var message = new LogMessage { Message = "StaticServer_NewPipelinePerEvent2" }; var client = new EventDispatcher(); client.Process(pipelineId, f => f.BuildFrom(message) .Add(() => portalId)); ProcessingServer.Server.WaitAll(pipelineId); Assert.AreEqual(logHandler.Log.First(), "[Title -> ] [Message -> StaticServer_NewPipelinePerEvent2] [Level -> ] [portalId -> portal] "); }
/// <summary> /// Bind to an existing metric given by "name" /// </summary> /// <param name="pipeline"></param> /// <param name="name"></param> /// <param name="connection"></param> /// <param name="connectionId"></param> public MetricConnection(EventPipeline pipeline, IConnection connection, string connectionId, string jsonMetric, string clientId) { _connection = connection; _connectionId = connectionId; _clientId = clientId; _jsonMetric = JsonConvert.DeserializeObject <JsonMetric>(jsonMetric); // Try to find the metric, and add a watcher var metric = pipeline.GetProcessor(_jsonMetric.Name) as MetricProcessor; if (metric == null) { // Its new so we need to create a new one... var filePath = Path.Combine(PathManager.BasePath, "user", "metric", _jsonMetric.Name + ".json"); //if (!File.Exists(filePath)) { var formattedJson = JsonConvert.SerializeObject(_jsonMetric, Formatting.Indented); File.WriteAllText(filePath, formattedJson); //} metric = new MetricProcessor(_jsonMetric.Name, _jsonMetric); pipeline.AddProcessor(metric); } metric.Updated(_connectionId, WriteValueUpdate); metric.Error(_connectionId, WriteErrorUpdate); SendUpdates(metric); }
public void InstanceServer_FactorySetEventBus() { var pipelineId = Guid.NewGuid().ToString(); var factory = new EventBusFactory(); factory.Register(pipelineId, () => { var pipeline = new EventPipeline(); pipeline.AddHandler(new ConsoleOutputHandler()); return(pipeline); }); factory.Register(pipelineId, new EventBus(() => null, pipelineId)); var server = new ProcessingServer(factory); server.Register(pipelineId, new LogInputHandler()); var client = new EventDispatcher(server); client.Process(pipelineId, new LogMessage { Message = "InstanceServer" }); }
public ProcessEventPostsJob(IQueue<EventPost> queue, EventParserPluginManager eventParserPluginManager, EventPipeline eventPipeline, IAppStatsClient statsClient, IOrganizationRepository organizationRepository, IProjectRepository projectRepository) { _queue = queue; _eventParserPluginManager = eventParserPluginManager; _eventPipeline = eventPipeline; _statsClient = statsClient; _organizationRepository = organizationRepository; _projectRepository = projectRepository; }
public void EventPipeline_AddHandler() { var handler = new Mock <IOutputHandler>(); var pipeline = new EventPipeline(); pipeline.AddHandler(handler.Object); Assert.That(pipeline.Handlers.Any()); }
public Task Deposit(decimal amount) { var ev = new DepositMadeEvent(Id) { Amount = amount }; return(EventPipeline.AddEvent <CheckingAccount>(ev)); }
public ProcessEventPostsJob(IQueue <EventPost> queue, EventParserPluginManager eventParserPluginManager, EventPipeline eventPipeline, IAppStatsClient statsClient, IOrganizationRepository organizationRepository, IProjectRepository projectRepository) { _queue = queue; _eventParserPluginManager = eventParserPluginManager; _eventPipeline = eventPipeline; _statsClient = statsClient; _organizationRepository = organizationRepository; _projectRepository = projectRepository; }
public EventPostsJob(IQueue<EventPost> queue, EventParserPluginManager eventParserPluginManager, EventPipeline eventPipeline, IMetricsClient metricsClient, IOrganizationRepository organizationRepository, IProjectRepository projectRepository, IFileStorage storage) { _queue = queue; _eventParserPluginManager = eventParserPluginManager; _eventPipeline = eventPipeline; _metricsClient = metricsClient; _organizationRepository = organizationRepository; _projectRepository = projectRepository; _storage = storage; }
public EventPostsJob(IQueue <EventPostFileInfo> queue, EventParserPluginManager eventParserPluginManager, EventPipeline eventPipeline, IAppStatsClient statsClient, IOrganizationRepository organizationRepository, IProjectRepository projectRepository, IFileStorage storage) { _queue = queue; _eventParserPluginManager = eventParserPluginManager; _eventPipeline = eventPipeline; _statsClient = statsClient; _organizationRepository = organizationRepository; _projectRepository = projectRepository; _storage = storage; }
public void EventPipeline_Run() { var handler = new Mock <IOutputHandler>(); var pipeline = new EventPipeline(); pipeline.AddHandler(handler.Object); pipeline.Run(new Event("id", "value")); handler.Verify(exp => exp.Handle(It.Is <Event>(e => e.PipelineId == "id")), Times.Once); }
public Task CreateAccount(string name, decimal openingBalance) { var ev = new AccountCreatedEvent { AccountHolderName = name, EmployeeOpening = "Bruce Springsteen", OpeningBalance = openingBalance }; return(EventPipeline.AddEvent <CheckingAccount>(ev)); }
public EventPipelineTests(ITestOutputHelper output) : base(output) { _eventRepository = GetService <IEventRepository>(); _stackRepository = GetService <IStackRepository>(); _organizationRepository = GetService <IOrganizationRepository>(); _projectRepository = GetService <IProjectRepository>(); _userRepository = GetService <IUserRepository>(); _pipeline = GetService <EventPipeline>(); CreateProjectDataAsync().GetAwaiter().GetResult(); }
public StatsTests(ITestOutputHelper output) : base(output) { _stats = GetService <EventStats>(); _pipeline = GetService <EventPipeline>(); _eventRepository = GetService <IEventRepository>(); _stackRepository = GetService <IStackRepository>(); _organizationRepository = GetService <IOrganizationRepository>(); _projectRepository = GetService <IProjectRepository>(); Log.SetLogLevel <EventStats>(LogLevel.Trace); }
public void LoadTest_HeavyWork() { // start with the warmup... var cnt = 0; var proc = 0; var pipelineId = Guid.NewGuid().ToString(); var server = new ProcessingServer(); server.Register(pipelineId, () => { var pipeline = new EventPipeline(); pipeline.AddHandler(new LoadTestOuptuHandler(e => { proc += 1; // do some heavy work Thread.Sleep(100); })); return(pipeline); }); server.Register(pipelineId, new InputHandler <InputItem>()); var client = new EventDispatcher(server); var profiler = ProfilerSession.StartSession() .SetIterations(1000) .SetThreads(5) .Task(() => { lock (pipelineId) { cnt += 1; } client.Process(pipelineId, new InputItem { Value = "StaticServer", Name = "test", Number = cnt }); }).RunSession(); server.WaitAll(pipelineId); profiler.Trace(); var monitor = new StatisticsApi(pipelineId); var processed = monitor.GetMetricValue <long>(MetricType.ProcessedEvents); Assert.AreEqual(processed, cnt, "Processed events are not equal to sent events {0} to {1}", processed, cnt); }
public Task WriteCheck(string recipient, decimal amount, string memo) { return(EventPipeline.AddEvent <CheckingAccount>( new CheckCashedEvent(Id) { Amount = amount, Recepient = recipient, Date = DateTime.Now, Memo = memo } )); }
public EventPostsJob(IQueue <EventPost> queue, EventParserPluginManager eventParserPluginManager, EventPipeline eventPipeline, IMetricsClient metricsClient, UsageService usageService, IProjectRepository projectRepository, IFileStorage storage, JsonSerializerSettings jsonSerializerSettings, ILoggerFactory loggerFactory = null) : base(queue, loggerFactory) { _eventParserPluginManager = eventParserPluginManager; _eventPipeline = eventPipeline; _metricsClient = metricsClient; _usageService = usageService; _projectRepository = projectRepository; _storage = storage; _jsonSerializerSettings = jsonSerializerSettings; AutoComplete = false; }
public void PerformanceMeasures_FullProcess() { GlobalConfiguration.Setup(s => s.UseOptions(new Options { MaxItemsInQueue = 10, MaxProcessors = 30 })); // start with the warmup... var cnt = 0; var pipelineId = Guid.NewGuid().ToString(); var server = new ProcessingServer(); server.Register(pipelineId, () => { var pipeline = new EventPipeline(); pipeline.AddHandler(new LoadTestOuptuHandler(e => { })); return(pipeline); }); server.Register(pipelineId, new InputHandler <InputItem>()); var client = new EventDispatcher(server); var sw = new Stopwatch(); sw.Start(); for (var i = 0; i < 10; i++) { client.Process(pipelineId, new InputItem { Value = "StaticServer", Name = "test", Number = i }); } //sw.Stop(); var time1 = sw.Elapsed; server.WaitAll(pipelineId); sw.Stop(); var time2 = sw.Elapsed; Assert.Less(time1, TimeSpan.FromMilliseconds(30)); Assert.Less(time2, TimeSpan.FromMilliseconds(600)); }
public void PluginManagerTests_BuildConfig() { var ctx = new ActivationContext(); ctx.Register <IEventDataConverter, EventDataConverter>(); var inputPlugin = _pluginMgr.GetPlugin(typeof(IInputHandler), "CustomInput"); var input = ctx.Resolve <IInputHandler>(inputPlugin.Type); var outputPlugin = _pluginMgr.GetPlugin(typeof(IOutputHandler), "ConsoleOutput"); var output = ctx.Resolve <IOutputHandler>(outputPlugin.Type); var pipelineId = Guid.NewGuid().ToString(); var loghandler = new LogQueueHandler(); var cnt = 0; var server = new ProcessingServer(); server.SetupPipeline(pipelineId, s => { s.Register(() => { var pipeline = new EventPipeline(); pipeline.AddHandler(output); pipeline.AddHandler(loghandler); cnt = cnt + 1; return(pipeline); }); s.Register(input); }); var client = new EventDispatcher(server); client.Process(pipelineId, new LogMessage { Message = "Event1" }); client.Process(pipelineId, new LogMessage { Message = "Event2" }); server.WaitAll(pipelineId); //Assert.That(cnt == 1, () => $"Count is {cnt} but is expected to be 1"); Assert.That(loghandler.Log.Count() == 2, () => $"Logcount is {loghandler.Log.Count()} but is expected to be 2"); }
public ExceptionlessMqServer(IRedisClientsManager clientsManager, IProjectRepository projectRepository, IUserRepository userRepository, IStackRepository stackRepository, IOrganizationRepository organizationRepository, EventPipeline eventPipeline, EventStatsHelper eventStatsHelper, IProjectHookRepository projectHookRepository, ICacheClient cacheClient, IMailer mailer, IAppStatsClient stats) : base(clientsManager) { _projectRepository = projectRepository; _projectHookRepository = projectHookRepository; _userRepository = userRepository; _stackRepository = stackRepository; _organizationRepository = organizationRepository; _eventPipeline = eventPipeline; _eventStatsHelper = eventStatsHelper; _cacheClient = cacheClient; _mailer = mailer; _stats = stats; RegisterHandler<SummaryNotification>(ProcessSummaryNotification, ProcessSummaryNotificationException); RegisterHandler<EventNotification>(ProcessNotification, ProcessNotificationException); RegisterHandler<PersistentEvent>(ProcessEvent, ProcessEventException); RegisterHandler<WebHookNotification>(ProcessWebHookNotification, ProcessWebHookNotificationException); }