public RFEngineDefinition BuildEngine(string database, string environment = "") { // define a key root for all objects var keyDomain = new RFSimpleKeyDomain("empty"); // create the engine var engineConfig = RFEngineDefinition.Create("emptyengine", keyDomain); var graph = engineConfig.CreateGraph("emptygraph"); graph.AddProcess("emptyprocess", "Dummy process.", () => new RFNullProcessor()); return(engineConfig); }
public RFEngineDefinition BuildEngine(string database, string environment) { var keyDomain = new RFSimpleKeyDomain("TEST"); var engineConfig = RFEngineDefinition.Create( "TestEngine", keyDomain, intervalSeconds: 1, maxRuntime: TimeSpan.FromMinutes(20)); // interval and direct dependency engineConfig.AddIntervalTrigger( engineConfig.AddProcess("Interval test", "Checks for internal", () => new ActionProcessor((c) => c.SaveDocument(RFGenericCatalogKey.Create(keyDomain, "IntervalTest", TestKeys.Key1, null), "Complete") ))); engineConfig.AddProcessWithCatalogTrigger <RFEngineProcessorKeyParam>("Interval sink", "Step 2", () => new ActionProcessor((c) => c.SaveDocument(RFGenericCatalogKey.Create(keyDomain, "IntervalTest", TestKeys.Key2, null), "Complete")), RFGenericCatalogKey.Create(keyDomain, "IntervalTest", TestKeys.Key1, null)); // direct and indirect dependency test (A -> B -> C) with reverse var graph = engineConfig.CreateGraph("TestGraph"); graph.AddProcess("A1", "A1", () => new AppendProcessor(new AppendProcessor.Config { Append = "A" })) .Map(d => d.Input1, RFGenericCatalogKey.Create(keyDomain, "S", TestKeys.Key1, null), RFDateBehaviour.Exact) .Map(d => d.Output, RFGenericCatalogKey.Create(keyDomain, "Y", TestKeys.Key1, null), RFDateBehaviour.Exact) .Map(d => d.Counter, RFGenericCatalogKey.Create(keyDomain, "A_Counter", TestKeys.Key1, null), RFDateBehaviour.Exact); graph.AddProcess("B1", "B1", () => new AppendProcessor(new AppendProcessor.Config { Append = "B" })) .Map(d => d.Input1, RFGenericCatalogKey.Create(keyDomain, "Y", TestKeys.Key1, null), RFDateBehaviour.Exact) .Map(d => d.Output, RFGenericCatalogKey.Create(keyDomain, "Z", TestKeys.Key1, null), RFDateBehaviour.Exact) .Map(d => d.Counter, RFGenericCatalogKey.Create(keyDomain, "B_Counter", TestKeys.Key1, null), RFDateBehaviour.Exact); graph.AddProcess("C1", "C1", () => new AppendProcessor(new AppendProcessor.Config { Append = "C" })) .Map(d => d.Input1, RFGenericCatalogKey.Create(keyDomain, "Y", TestKeys.Key1, null), RFDateBehaviour.Exact) .Map(d => d.Input2, RFGenericCatalogKey.Create(keyDomain, "Z", TestKeys.Key1, null), RFDateBehaviour.Exact) .Map(d => d.Output, RFGenericCatalogKey.Create(keyDomain, "E", TestKeys.Key1, null), RFDateBehaviour.Exact) .Map(d => d.Counter, RFGenericCatalogKey.Create(keyDomain, "C_Counter", TestKeys.Key1, null), RFDateBehaviour.Exact); // reverse graph.AddProcess("A2", "A2", () => new AppendProcessor(new AppendProcessor.Config { Append = "C" })) .Map(d => d.Input1, RFGenericCatalogKey.Create(keyDomain, "Y", TestKeys.Key2, null), RFDateBehaviour.Exact) .Map(d => d.Input2, RFGenericCatalogKey.Create(keyDomain, "Z", TestKeys.Key2, null), RFDateBehaviour.Exact) .Map(d => d.Output, RFGenericCatalogKey.Create(keyDomain, "E", TestKeys.Key2, null), RFDateBehaviour.Exact) .Map(d => d.Counter, RFGenericCatalogKey.Create(keyDomain, "C_Counter", TestKeys.Key2, null), RFDateBehaviour.Exact); graph.AddProcess("B2", "B2", () => new AppendProcessor(new AppendProcessor.Config { Append = "B" })) .Map(d => d.Input1, RFGenericCatalogKey.Create(keyDomain, "Y", TestKeys.Key2, null), RFDateBehaviour.Exact) .Map(d => d.Output, RFGenericCatalogKey.Create(keyDomain, "Z", TestKeys.Key2, null), RFDateBehaviour.Exact) .Map(d => d.Counter, RFGenericCatalogKey.Create(keyDomain, "B_Counter", TestKeys.Key2, null), RFDateBehaviour.Exact); graph.AddProcess("C2", "C2", () => new AppendProcessor(new AppendProcessor.Config { Append = "A" })) .Map(d => d.Input1, RFGenericCatalogKey.Create(keyDomain, "S", TestKeys.Key2, null), RFDateBehaviour.Exact) .Map(d => d.Output, RFGenericCatalogKey.Create(keyDomain, "Y", TestKeys.Key2, null), RFDateBehaviour.Exact) .Map(d => d.Counter, RFGenericCatalogKey.Create(keyDomain, "A_Counter", TestKeys.Key2, null), RFDateBehaviour.Exact); // tasks var task1 = engineConfig.AddProcess("Task 1 Process", "Task 1", () => new ActionProcessor((c) => c.SaveDocument(RFGenericCatalogKey.Create(keyDomain, "Task 1 Result", TestKeys.Key1, null), "Complete"))); var task2 = engineConfig.AddProcess("Task 2 Process", "Task 2", () => new ActionProcessor((c) => c.SaveDocument(RFGenericCatalogKey.Create(keyDomain, "Task 2 Result", TestKeys.Key1, null), "Complete"))); var task3 = engineConfig.AddProcess("Task 3 Process", "Task 3", () => new ActionProcessor((c) => c.SaveDocument(RFGenericCatalogKey.Create(keyDomain, "Task 3 Result", TestKeys.Key1, null), "Complete"))); engineConfig.AddScheduledTask("Task 1", new RFIntervalSchedule(new TimeSpan(0, 0, 1)).Single(), RFWeeklyWindow.AllWeek(), task1, false); engineConfig.AddChainedTask("Task 2", task1, task2, false); engineConfig.AddTriggeredTask("Task 3", RFGenericCatalogKey.Create(keyDomain, "Task 2 Result", TestKeys.Key1, null), task3); // queued trigger test var queuedTrigger = engineConfig.AddProcess("Queued Trigger Process", "Queued Trigger Process", () => new ActionProcessor((c) => { var _in = c.LoadDocumentContent <string>(RFGenericCatalogKey.Create(keyDomain, "Queued Trigger", TestKeys.Key1, null)) ?? String.Empty; _in += "Start"; Thread.Sleep(TimeSpan.FromSeconds(3)); _in += "Stop"; c.SaveDocument(RFGenericCatalogKey.Create(keyDomain, "Queued Trigger", TestKeys.Key1, null), _in); })); engineConfig.AddTriggeredTask("Queued Scheduler", RFGenericCatalogKey.Create(keyDomain, "Trigger Key", TestEngine.TestKeys.Key1, null), queuedTrigger); // transaction engineConfig.AddProcess("Transaction Tester", "Tests SQL+MSMQ Transaction", () => new TransactionProcessor( RFGenericCatalogKey.Create(keyDomain, "Transaction", "Test1", null), RFGenericCatalogKey.Create(keyDomain, "Transaction", "Test2", null))); return(engineConfig); }