public void Run() { var config = new FlowRuntimeConfiguration() .AddStreamsFrom(@" / .in, rechenwerk.teilen rechenwerk.resultat, .result rechenwerk.divisionDurchNull, .fehler ") .AddEventBasedComponent("rechenwerk", new Rechenwerk()); using (var fr = new FlowRuntime(config)) { fr.Message += Console.WriteLine; fr.UnhandledException += Console.WriteLine; fr.Process(".in", new Tuple <int, int>(42, 7)); IMessage result = null; Assert.IsTrue(fr.WaitForResult(1000, _ => result = _)); Assert.AreEqual(".result", result.Port.Fullname); Assert.AreEqual(6, (int)result.Data); fr.Process(".in", new Tuple <int, int>(42, 0)); Assert.IsTrue(fr.WaitForResult(2000, _ => result = _)); Assert.AreEqual(".fehler", result.Port.Fullname); Assert.AreEqual(new Tuple <int, int>(42, 0), result.Data); } }
public void Run() { var config = new FlowRuntimeConfiguration() .AddStreamsFrom(@" / .in, rechenwerk.teilen rechenwerk.resultat, .result rechenwerk.divisionDurchNull, .fehler ") .AddEventBasedComponent("rechenwerk", new Rechenwerk()); using(var fr = new FlowRuntime(config)) { fr.Process(".in", new Tuple<int,int>(42,7)); IMessage result = null; fr.WaitForResult(_ => result = _); Assert.AreEqual(".result", result.Port.Fullname); Assert.AreEqual(6, (int)result.Data); fr.Process(".in", new Tuple<int, int>(42, 0)); fr.WaitForResult(_ => result = _); Assert.AreEqual(".fehler", result.Port.Fullname); Assert.AreEqual(new Tuple<int,int>(42,0), result.Data); } }
public void Two_input_join() { var frc = new FlowRuntimeConfiguration() .AddStream(new Stream(".inString", "mrj.in0")) .AddStream(new Stream(".inInt", "mrj.in1")) .AddStream(new Stream(".inReset", "mrj.reset")) .AddStream(new Stream("mrj", ".out")) .AddManualResetJoin <string, int>("mrj"); using (var fr = new FlowRuntime(frc)) { fr.UnhandledException += Console.WriteLine; fr.Process(new Message(".inString", "x")); fr.Process(new Message(".inInt", 42)); IMessage result = null; Assert.IsTrue(fr.WaitForResult(500, _ => result = _)); var tresult = (Tuple <string, int>)result.Data; Assert.AreEqual("x", tresult.Item1); Assert.AreEqual(42, tresult.Item2); fr.Process(new Message(".inReset", null)); fr.Process(new Message(".inString", "y")); fr.Process(new Message(".inInt", 43)); Assert.IsTrue(fr.WaitForResult(500, _ => result = _)); tresult = (Tuple <string, int>)result.Data; Assert.AreEqual("y", tresult.Item1); Assert.AreEqual(43, tresult.Item2); } }
public void Run() { var awsSecrets = SecretsRepository.LoadFrom("mailfollowup.reminder.app.awssecrets.txt", Assembly.GetExecutingAssembly()); var smtpSecrets = MailAccessRepository.LoadFrom("mailfollowup.reminder.app.mail.smtp.txt", Assembly.GetExecutingAssembly()); var frc = new FlowRuntimeConfiguration(); frc.AddStreamsFrom("mailfollowup.reminder.app.root.flow", Assembly.GetExecutingAssembly()); var store = new MailStore(awsSecrets); var smtp = new Smtp(smtpSecrets); frc.AddFunc("aktuelle_zeit_ermitteln", Now); frc.AddAction<DateTime, Erinnerungsauftrag>("erinnerungsauftrag_holen", store.Load); frc.AddFunc<Erinnerungsauftrag, Erinnerungsauftrag>("erinnerung_versenden", smtp.Send); frc.AddAction<Erinnerungsauftrag>("erinnerungsauftrag_loeschen", store.Delete); using (var fr = new FlowRuntime(frc)) { fr.Message += Console.WriteLine; fr.UnhandledException += e => { Console.WriteLine(e); Environment.Exit(1); }; fr.Process(".start"); fr.WaitForResult(); } }
public void High_prio_exception_message_terminates_runtime() { var config = new FlowRuntimeConfiguration() .AddStreamsFrom(@" / .in, doit .stop, .error doit, .result " ) .AddAction <int, string>("doit", (int d, Action <string> continueWith) => { continueWith(d + "x"); continueWith(d + "y"); throw new ApplicationException("arrrghhh!"); }); using (var fr = new FlowRuntime(config, new Schedule_for_async_breadthfirst_processing())) { IMessage result = null; fr.UnhandledException += ex => { fr.Process(new Message(".stop", ex) { Priority = 99 }); }; fr.Process(".in", 42); Assert.IsTrue(fr.WaitForResult(500, _ => { if (result == null) { result = _; } })); Assert.AreEqual("error", result.Port.Name); } }
public void Nested_flows() { var frc = new FlowRuntimeConfiguration() .AddStreamsFrom(@" .in, f.in // flow with explicit ports f.out, .out f .in, g // flow without explicit ports g, .out g ., a // port without a name a, . " ) .AddOperation(new Operation("a", (input, outputCont, _) => outputCont(new Message("a", input.Data.ToString() + "x")))); _sut.Configure(frc); _sut.Message += Console.WriteLine; _sut.Process(new Message(".in", "hello")); IMessage result = null; Assert.IsTrue(_sut.WaitForResult(500, _ => result = _)); Assert.AreEqual("hellox", (string)result.Data); }
public void Run() { var cre = PubnubCredentials.LoadFrom("pubnub credentials.txt"); var configServer = new FlowRuntimeConfiguration() .AddFunc <string, string>("hello", s => "hello, " + s) .AddStream(".@hello", "hello") .AddStream("hello", ".@hello"); using (var server = new FlowRuntime(configServer)) using (new PubnubOperationHost(server, cre, "host")) { server.Message += Console.WriteLine; var configClient = new FlowRuntimeConfiguration() .AddOperation(new PubnubStandInOperation("standin", cre, "host")) .AddStream(".in", "standin#hello") .AddStream("standin#hello", ".out"); using (var client = new FlowRuntime(configClient)) { client.Message += Console.WriteLine; client.Process(".in", "peter"); var result = ""; Assert.IsTrue(client.WaitForResult(5000, _ => result = (string)_.Data)); Assert.AreEqual("hello, peter", result); } } }
public void Scatter_gather() { var frc = new FlowRuntimeConfiguration(); frc.AddStream(new Stream(".in", "scatter")); frc.AddStream(new Stream("scatter.stream", "sleep")); frc.AddStream(new Stream("scatter.count", "gather.count")); frc.AddStream(new Stream("sleep", "gather.stream")); frc.AddStream(new Stream("gather", ".out")); frc.AddFunc <int, int>("sleep", _ => { Console.WriteLine("sleep {0} on {1}", _, Thread.CurrentThread.GetHashCode()); Thread.Sleep(_); return(_); }).MakeParallel(); frc.AddOperation(new Scatter <int>("scatter")); frc.AddOperation(new Gather <int>("gather")); using (var fr = new FlowRuntime(frc)) { var list = new[] { 10, 200, 100, 30, 200, 70 }; fr.Process(new Message(".in", list)); IMessage result = null; Assert.IsTrue(fr.WaitForResult(1000, _ => result = _)); Assert.That(list, Is.EquivalentTo(((int[])result.Data))); } }
private static void Main(string[] args) { using (var repo = new az.tweetstore.ftp.Repository()) { var frc = new FlowRuntimeConfiguration() .AddStreamsFrom("az.receiver.application.root.flow", Assembly.GetExecutingAssembly()) .AddAction<string>("dequeue", new IronMQOperations("AppZwitschern", TokenRepository.LoadFrom("ironmq.credentials.txt")).Dequeue) .AddFunc<string, Versandauftrag>("deserialize", new Serialization<Versandauftrag>().Deserialize) .AddAction<Versandauftrag>("speichern", repo.Store); using (var fr = new FlowRuntime(frc)) { fr.Message += Console.WriteLine; fr.UnhandledException += e => { Console.WriteLine(e.InnerException); fr.Process(new Message(".stop") { Priority = 99 }); }; fr.Process(".start"); fr.WaitForResult(); } } }
static void Main2(string[] args) { using (var fr = new FlowRuntime()) { var frc = new FlowRuntimeConfiguration(); frc.AddStream(".in", "Find_files"); frc.AddStream("Find_files", "scatter"); frc.AddStream("scatter.stream", "Count_words"); frc.AddStream("scatter.count", "gather.count"); frc.AddStream("Count_words", "gather.stream"); frc.AddStream("gather", "Total"); frc.AddStream("Total", ".out"); frc.AddFunc <string, IEnumerable <String> >("Find_files", Find_files).MakeAsync() .AddFunc <string, int>("Count_words", Count_words).MakeParallel() .AddFunc <IEnumerable <int>, Tuple <int, int> >("Total", Total) .AddOperation(new Scatter <string>("scatter")) .AddOperation(new Gather <int>("gather")); fr.Configure(frc); var start = DateTime.Now; fr.Process(new Message(".in", "x")); Tuple <int, int> result = null; fr.WaitForResult(5000, _ => result = (Tuple <int, int>)_.Data); var delta = DateTime.Now.Subtract(start); Console.WriteLine("{0} words in {1} files, {2}msec", result.Item2, result.Item1, delta); } }
static void Main(string[] args) { using (var fr = new FlowRuntime()) { var frc = new FlowRuntimeConfiguration(); frc.AddStream(".in", "A"); frc.AddStream("A", "B"); frc.AddStream("B", "C"); frc.AddFunc <int, int>("A", i => i + 1) .AddFunc <int, int>("B", i => i * 2) .AddAction <int>("C", (int i) => Console.WriteLine("={0}", i)); fr.Configure(frc); // Trace messages selectively using Rx var tracer = new Subject <IMessage>(); tracer.Where(msg => msg.Port.OperationName == "B") // message filter .Select(msg => (int)msg.Data) .Subscribe(i => Console.WriteLine("{0} -> B", i), // message handler _ => { }); fr.Message += tracer.OnNext; fr.Process(new Message(".in", 1)); fr.Process(new Message(".in", 2)); fr.Process(new Message(".in", 3)); fr.WaitForResult(500); } }
private static void Main(string[] args) { _email = ConfigurationManager.AppSettings["GoogleAccount"]; _baseDirPath = String.IsNullOrEmpty(ConfigurationManager.AppSettings["BasePath"]) ? @"c:\temp\" : ConfigurationManager.AppSettings["BasePath"]; _deleteOlderFiles = bool.Parse(String.IsNullOrEmpty(ConfigurationManager.AppSettings["DeleteOlderFiles"]) ? "false" : ConfigurationManager.AppSettings["DeleteOlderFiles"]); _label = "Listen Subscriptions"; _dateFormat = "yyyyMMddTHHmmss"; _getFilesFromTheLastXDays = int.Parse(String.IsNullOrEmpty(ConfigurationManager.AppSettings["GetFilesFromTheLastXDays"]) ? "3" : ConfigurationManager.AppSettings["GetFilesFromTheLastXDays"]); _reader = null; //Console.WriteLine("Enter password"); var password = "******";// Console.ReadLine(); _reader = Reader.CreateReader(_email, password, "scroll") as Reader; using (var fr = new FlowRuntime()) { var frc = new FlowRuntimeConfiguration(); frc.AddStream(".in", "Get_Feeds"); frc.AddStream("Get_Feeds", ".out"); frc.AddFunc<Reader, IEnumerable<UrlAndFeed>>("Get_Feeds", getFeedsWithGivenLabel); fr.Configure(frc); fr.Process(new Message(".in", _reader)); fr.WaitForResult(5000, _ => Console.WriteLine(_.Data)); Console.ReadLine(); } }
public void test_cyclic_flow_with_async_EBC() { Console.WriteLine("test started for {0} flow cycles...", maxCycles); var config = new FlowRuntimeConfiguration() .AddStreamsFrom(@" / .in, cyclic.run cyclic.continue, cyclic.run cyclic.stopOn, .out ") .AddEventBasedComponent("cyclic", new CyclicFlow()); using(var fr = new FlowRuntime(config)) { fr.UnhandledException += Console.WriteLine; fr.Process(".in", 1); IMessage result = null; Assert.IsTrue(fr.WaitForResult(5000, _ => result = _), "result not received within 5 seconds"); Assert.AreEqual(".out", result.Port.Fullname); Assert.AreEqual(maxCycles, (int)result.Data); } }
static void Main(string[] args) { var textfileadapter = new TextfileAdapter(); var formatter = new Formatter(); var config = new FlowRuntimeConfiguration() .AddStreamsFrom("TelegramProblem.run.flow", Assembly.GetExecutingAssembly()) .AddAction<string>("read", textfileadapter.Read).MakeAsync() .AddAction<string>("write", textfileadapter.Write, true) .AddAction<string, string>("decompose", formatter.Decompose) .AddAction<string, string>("concatenate", formatter.Concatenate) .AddAction<Tuple<string, string>>("textfileadapter_config", textfileadapter.Config) .AddAction<int>("formatter_config", formatter.Config); using(var fr = new FlowRuntime(config)) { fr.UnhandledException += Console.WriteLine; fr.Process(".configFilenames", new Tuple<string,string>("source.txt", "target.txt")); fr.Process(".configLineWidth", 60); fr.Process(".run"); fr.WaitForResult(); Console.WriteLine(File.ReadAllText("target.txt")); } }
private static void Main(string[] args) { using (var repo = new az.tweetstore.ftp.Repository()) { var frc = new FlowRuntimeConfiguration() .AddStreamsFrom("az.receiver.application.root.flow", Assembly.GetExecutingAssembly()) .AddAction <string>("dequeue", new IronMQOperations("AppZwitschern", TokenRepository.LoadFrom("ironmq.credentials.txt")).Dequeue) .AddFunc <string, Versandauftrag>("deserialize", new Serialization <Versandauftrag>().Deserialize) .AddAction <Versandauftrag>("speichern", repo.Store); using (var fr = new FlowRuntime(frc)) { fr.Message += Console.WriteLine; fr.UnhandledException += e => { Console.WriteLine(e.InnerException); fr.Process(new Message(".stop") { Priority = 99 }); }; fr.Process(".start"); fr.WaitForResult(); } } }
static void Main(string[] args) { using (var fr = new FlowRuntime()) { var frc = new FlowRuntimeConfiguration(); frc.AddStream(".in", "Pushc"); frc.AddStream("Pushc", "Find Files"); frc.AddStream("Pushc.exception", "Handle Exception"); frc.AddStream("Find Files", "Count Words"); frc.AddStream("Count Words", "popc"); frc.AddStream("Popc", "Total"); frc.AddStream("Total", ".out"); frc.AddFunc<IEnumerable<string>, IEnumerable<int>>("Count Words", Count_words3) .AddFunc<string, IEnumerable<String>>("Find Files", Find_files) .AddAction<FlowRuntimeException>("Handle Exception", Handle_exception) .AddPopCausality("Popc") .AddPushCausality("Pushc") .AddFunc<IEnumerable<int>, Tuple<int, int>>("Total", Total); fr.Configure(frc); fr.Process(new Message(".in", "x")); Tuple<int, int> result = null; fr.WaitForResult(5000, _ => result = (Tuple<int, int>)_.Data); if (result != null) Console.WriteLine("{0} words in {1} files", result.Item2, result.Item1); } }
static void Main(string[] args) { using (var fr = new FlowRuntime()) { var frc = new FlowRuntimeConfiguration(); frc.AddStream(".in", "Pushc"); frc.AddStream("Pushc", "Find Files"); frc.AddStream("Pushc.exception", "Handle Exception"); frc.AddStream("Find Files", "Count Words"); frc.AddStream("Count Words", "popc"); frc.AddStream("Popc", "Total"); frc.AddStream("Total", ".out"); frc.AddFunc <IEnumerable <string>, IEnumerable <int> >("Count Words", Count_words3) .AddFunc <string, IEnumerable <String> >("Find Files", Find_files) .AddAction <FlowRuntimeException>("Handle Exception", Handle_exception) .AddPopCausality("Popc") .AddPushCausality("Pushc") .AddFunc <IEnumerable <int>, Tuple <int, int> >("Total", Total); fr.Configure(frc); fr.Process(new Message(".in", "x")); Tuple <int, int> result = null; fr.WaitForResult(5000, _ => result = (Tuple <int, int>)_.Data); if (result != null) { Console.WriteLine("{0} words in {1} files", result.Item2, result.Item1); } } }
static void Main(string[] args) { using(var fr = new FlowRuntime()) { var frc = new FlowRuntimeConfiguration(); var pageBufferContainer = new DataContainer<PageBuffer>(); var frontend = new Frontend(); frc.AddFlow(new Main(new Formatter(), frontend)); frc.AddFlow(new Features(new CommandlineParser(pageBufferContainer), new TextFileAdapter(), new LineBuffer(pageBufferContainer), new Pager(pageBufferContainer))); fr.Configure(frc); frontend.displayFirstPage += fr.CreateEventProcessor(".displayFirstPage"); frontend.displayLastPage += fr.CreateEventProcessor(".displayLastPage"); frontend.displayNextPage += fr.CreateEventProcessor(".displayNextPage"); frontend.displayPrevPage += fr.CreateEventProcessor(".displayPrevPage"); //fr.Message += Console.WriteLine; fr.Process(new Message(".run", new[]{"test1.txt"})); fr.WaitForResult(); } }
public void Active_EBC_fires_in_flow() { var ebc = new ActiveEbc(); var config = new FlowRuntimeConfiguration() .AddStreamsFrom(@" / .in, subflow.in subflow.out, .out subflow .in, ebc.Run ebc.Out, .out ") .AddEventBasedComponent("ebc", ebc); using (var fr = new FlowRuntime(config)) { fr.Process(".in", "hello"); var result = ""; Assert.IsTrue(fr.WaitForResult(2000, _ => result = (string)_.Data)); Assert.AreEqual("hellox", result); } }
public void Run() { var configServer = new FlowRuntimeConfiguration() .AddFunc<string, string>("hello", s => "hello, " + s) .AddStream(".@hello", "hello") .AddStream("hello", ".@hello"); using (var server = new FlowRuntime(configServer)) using (new WcfOperationHost(server, "localhost:8000")) { server.Message += Console.WriteLine; var configClient = new FlowRuntimeConfiguration() .AddOperation(new WcfStandInOperation("standin", "localhost:8100", "localhost:8000")) .AddStream(".in", "standin#hello") .AddStream("standin#hello", ".out"); using (var client = new FlowRuntime(configClient)) { client.Message += Console.WriteLine; client.Process(".in", "peter"); var result = ""; Assert.IsTrue(client.WaitForResult(2000, _ => result = (string)_.Data)); Assert.AreEqual("hello, peter", result); } } }
public void Active_EBC_fires_in_flow() { var ebc = new ActiveEbc(); var config = new FlowRuntimeConfiguration() .AddStreamsFrom(@" / .in, subflow.in subflow.out, .out subflow .in, ebc.Run ebc.Out, .out ") .AddEventBasedComponent("ebc", ebc); using (var fr = new FlowRuntime(config)) { fr.Process(".in", "hello"); var result = ""; Assert.IsTrue(fr.WaitForResult(2000, _ => result = (string)_.Data)); Assert.AreEqual("hellox", result); } }
public void Run() { var configServer = new FlowRuntimeConfiguration() .AddFunc <string, string>("hello", s => "hello, " + s) .AddStream(".@hello", "hello") .AddStream("hello", ".@hello"); using (var server = new FlowRuntime(configServer)) using (new WcfOperationHost(server, "localhost:8000")) { server.Message += Console.WriteLine; var configClient = new FlowRuntimeConfiguration() .AddOperation(new WcfStandInOperation("standin", "localhost:8100", "localhost:8000")) .AddStream(".in", "standin#hello") .AddStream("standin#hello", ".out"); using (var client = new FlowRuntime(configClient)) { client.Message += Console.WriteLine; client.Process(".in", "peter"); var result = ""; Assert.IsTrue(client.WaitForResult(2000, _ => result = (string)_.Data)); Assert.AreEqual("hello, peter", result); } } }
static void Main(string[] args) { using (var fr = new FlowRuntime()) { var frc = new FlowRuntimeConfiguration(); var pageBufferContainer = new DataContainer <PageBuffer>(); var frontend = new Frontend(); frc.AddFlow(new Main(new Formatter(), frontend)); frc.AddFlow(new Features(new CommandlineParser(pageBufferContainer), new TextFileAdapter(), new LineBuffer(pageBufferContainer), new Pager(pageBufferContainer))); fr.Configure(frc); frontend.displayFirstPage += fr.CreateEventProcessor(".displayFirstPage"); frontend.displayLastPage += fr.CreateEventProcessor(".displayLastPage"); frontend.displayNextPage += fr.CreateEventProcessor(".displayNextPage"); frontend.displayPrevPage += fr.CreateEventProcessor(".displayPrevPage"); //fr.Message += Console.WriteLine; fr.Process(new Message(".run", new[] { "test1.txt" })); fr.WaitForResult(); } }
static void Main(string[] args) { using(var fr = new FlowRuntime()) { var frc = new FlowRuntimeConfiguration(); frc.AddStream(".in", "A"); frc.AddStream("A", "B"); frc.AddStream("B", "C"); frc.AddFunc<int, int>("A", i => i + 1) .AddFunc<int, int>("B", i => i * 2) .AddAction<int>("C", (int i) => Console.WriteLine("={0}", i)); fr.Configure(frc); // Trace messages selectively using Rx var tracer = new Subject<IMessage>(); tracer.Where(msg => msg.Port.OperationName == "B") // message filter .Select(msg => (int)msg.Data) .Subscribe(i => Console.WriteLine("{0} -> B", i), // message handler _ => { }); fr.Message += tracer.OnNext; fr.Process(new Message(".in", 1)); fr.Process(new Message(".in", 2)); fr.Process(new Message(".in", 3)); fr.WaitForResult(500); } }
static void Main(string[] args) { var textfileadapter = new TextfileAdapter(); var formatter = new Formatter(); var config = new FlowRuntimeConfiguration() .AddStreamsFrom("TelegramProblem.run.flow", Assembly.GetExecutingAssembly()) .AddAction <string>("read", textfileadapter.Read).MakeAsync() .AddAction <string>("write", textfileadapter.Write, true) .AddAction <string, string>("decompose", formatter.Decompose) .AddAction <string, string>("concatenate", formatter.Concatenate) .AddAction <Tuple <string, string> >("textfileadapter_config", textfileadapter.Config) .AddAction <int>("formatter_config", formatter.Config); using (var fr = new FlowRuntime(config)) { fr.UnhandledException += Console.WriteLine; fr.Process(".configFilenames", new Tuple <string, string>("source.txt", "target.txt")); fr.Process(".configLineWidth", 60); fr.Process(".run"); fr.WaitForResult(); Console.WriteLine(File.ReadAllText("target.txt")); } }
public void Scatter_gather() { var frc = new FlowRuntimeConfiguration(); frc.AddStream(new Stream(".in", "scatter")); frc.AddStream(new Stream("scatter.stream", "sleep")); frc.AddStream(new Stream("scatter.count", "gather.count")); frc.AddStream(new Stream("sleep", "gather.stream")); frc.AddStream(new Stream("gather", ".out")); frc.AddFunc<int, int>("sleep", _ => { Console.WriteLine("sleep {0} on {1}", _, Thread.CurrentThread.GetHashCode()); Thread.Sleep(_); return _; }).MakeParallel(); frc.AddOperation(new Scatter<int>("scatter")); frc.AddOperation(new Gather<int>("gather")); using(var fr = new FlowRuntime(frc)) { var list = new[] {10, 200, 100, 30, 200, 70}; fr.Process(new Message(".in", list)); IMessage result = null; Assert.IsTrue(fr.WaitForResult(1000, _ => result = _)); Assert.That(list, Is.EquivalentTo(((List<int>)result.Data).ToArray())); } }
public void Run() { var mailAccess = MailAccessRepository.LoadFrom("mailfollowup.receiver.application.mail.access.txt", Assembly.GetExecutingAssembly()); var awsSecrets = SecretsRepository.LoadFrom("mailfollowup.receiver.application.awssecrets.txt", Assembly.GetExecutingAssembly()); var frc = new FlowRuntimeConfiguration(); frc.AddStreamsFrom("mailfollowup.receiver.application.root.flow", Assembly.GetExecutingAssembly()); var imap = new Imap(mailAccess); var erinnerungsauftraege = new Erinnerungsauftraege(Now, new FollowupParser()); var store = new MailStore(awsSecrets); frc.AddAction<Mail>("mail_abholen", imap.Mail_holen); frc.AddFunc<Mail, Erinnerungsauftrag>("erinnerungsauftrag_erstellen", erinnerungsauftraege.Erinnerungsauftrag_erstellen); frc.AddFunc<Erinnerungsauftrag, string>("erinnerungsauftrag_speichern", store.Save); frc.AddAction<string>("mail_verschieben", imap.Mail_verschieben); using (var fr = new FlowRuntime(frc)) { fr.Message += Console.WriteLine; fr.UnhandledException += e => { Console.WriteLine(e); Environment.Exit(1); }; fr.Process(".start"); fr.WaitForResult(); } }
public void Connect_transceivers_operationhost() { var cre = PubnubCredentials.LoadFrom("pubnub credentials.txt"); var configServer = new FlowRuntimeConfiguration() .AddFunc <string, string>("greeting", s => s + "x") .AddStream(".@greeting", "greeting") .AddStream("greeting", ".@greeting"); using (var server = new FlowRuntime(configServer)) using (var serverhost = new PubnubOperationHost(server, cre, "thehost")) { server.Message += Console.WriteLine; var config = new FlowRuntimeConfiguration() .AddOperation(new PubnubStandInOperation("op", cre, "thehost")) .AddStream(".in", "op#greeting") .AddStream("op#greeting", ".out"); using (var fr = new FlowRuntime(config)) { fr.Message += Console.WriteLine; fr.Process(".in", "hello"); var result = ""; Assert.IsTrue(fr.WaitForResult(5000, _ => result = _.Data as string)); Assert.AreEqual("hellox", result); } } }
public void Roundrobin() { using(var fr = new FlowRuntime(_config, new Schedule_for_async_roundrobin_processing())) { fr.Process(".in", "x"); fr.WaitForResult(1000); Assert.AreEqual("/a(x)/b(x1)/c(x3)/b(x2)/d(x11)/d(x12)/d(x21)/d(x22)", _payload_flow); } }
public void Parallel_Depthfirst() { using (var fr = new FlowRuntime(_config, new Schedule_for_parallel_depthfirst_processing())) { fr.Process(".in", "x"); fr.WaitForResult(1000); Assert.AreEqual("/a(x)/b(x1)/d(x11)/d(x12)/b(x2)/d(x21)/d(x22)/c(x3)", _payload_flow); } }
public void Depthfirst() { using (var fr = new FlowRuntime(_config, new Schedule_for_async_depthfirst_processing())) { fr.Process(".in", "x"); fr.WaitForResult(1000); Assert.AreEqual("/a(x)/b(x1)/d(x11)/d(x12)/b(x2)/d(x21)/d(x22)/c(x3)", _payload_flow); } }
public static void Main(string[] args) { var config = new FlowRuntimeConfiguration() .AddStreamsFrom("bankueberweisung.console.root.flow", Assembly.GetExecutingAssembly()) .AddOperations(new AssemblyCrawler(Assembly.GetExecutingAssembly())); using (var fr = new FlowRuntime(config)) { //fr.Message += Console.WriteLine; fr.Process(".run"); fr.WaitForResult(); } }
public static void Main(string[] args) { var config = new FlowRuntimeConfiguration() .AddStreamsFrom("bankueberweisung.console.root.flow", Assembly.GetExecutingAssembly()) .AddOperations(new AssemblyCrawler(Assembly.GetExecutingAssembly())); using(var fr = new FlowRuntime(config)) { //fr.Message += Console.WriteLine; fr.Process(".run"); fr.WaitForResult(); } }
public void Run() { using (var fr = new FlowRuntime(_config)) { fr.Message += Console.WriteLine; fr.UnhandledException += e => { Console.WriteLine(e.InnerException); fr.Process(new Message(".stop") {Priority = 99}); }; fr.Process(".start"); fr.WaitForResult(); } }
public void Integrationstest() { using (var fr = new FlowRuntime()) { fr.AddOperation(new Eindeutige_Stichwörter_ermitteln()); fr.AddStream(".in", "ermitteln.in"); fr.AddStream("ermitteln.out", ".out"); fr.Process(new Message(".in", new Tuple<string, string>("testdaten", "*.jpg"))); IEnumerable<string> result = null; Assert.IsTrue(fr.WaitForResult(500, _ => result = (IEnumerable<string>) _.Data)); Assert.That(result.ToArray(), Is.EqualTo(new[] {"A", "B", "C", "D", "E"})); } }
static void Main_use_manual_wrapper(string[] args) { var config = new FlowRuntimeConfiguration() .AddStreamsFrom(@" / .in, toupper toupper, .out ") .AddOperation(new ToUpperOp("toupper")); using (var fr = new FlowRuntime(config)) { fr.Process(".in", "hello"); fr.WaitForResult(_ => Console.WriteLine(_.Data)); } }
static void Main(string[] args) { var config = new FlowRuntimeConfiguration() .AddStreamsFrom(@" / .in, toupper.process toupper.result, .out ") .AddEventBasedComponent("toupper", new ToUpperEBC()); using (var fr = new FlowRuntime(config)) { fr.Process(".in", "hello"); fr.WaitForResult(_ => Console.WriteLine(_.Data)); } }
static void Main(string[] args) { var portnumber = 8100 + DateTime.Now.Second; var config = new FlowRuntimeConfiguration() .AddEventBasedComponent("ui", new UI()) .AddOperation(new WcfStandInOperation("proxy", "localhost:" + portnumber, "localhost:8000")) .AddStreamsFrom("DistributedHelloWorld.Client.root.flow", Assembly.GetExecutingAssembly()); using (var fr = new FlowRuntime(config)) { Console.WriteLine("Enter names: "); fr.Process(".run"); fr.WaitForResult(); } }
static void Main(string[] args) { var config = new FlowRuntimeConfiguration() .AddStreamsFrom(@" / .in, toupper.process toupper.result, .out ") .AddEventBasedComponent("toupper", new ToUpperEBC()); using (var fr = new FlowRuntime(config)) { fr.Process(".in", "hello"); fr.WaitForResult(_ => Console.WriteLine(_.Data)); } }
static void Main_use_manual_wrapper(string[] args) { var config = new FlowRuntimeConfiguration() .AddStreamsFrom(@" / .in, toupper toupper, .out ") .AddOperation(new ToUpperOp("toupper")); using(var fr = new FlowRuntime(config)) { fr.Process(".in", "hello"); fr.WaitForResult(_ => Console.WriteLine(_.Data)); } }
public void Run() { using (var fr = new FlowRuntime(_config)) { fr.Message += Console.WriteLine; fr.UnhandledException += e => { Console.WriteLine(e.InnerException); fr.Process(new Message(".stop") { Priority = 99 }); }; fr.Process(".start"); fr.WaitForResult(); } }
public void Select_operation() { var config = new FlowRuntimeConfiguration() .AddFunc <int>("f", () => Thread.CurrentThread.GetHashCode()) .AddAction("x", () => { }) .AddStream(".in", "f") .AddStream("f", ".out") ["f"].MakeAsync(); using (var fr = new FlowRuntime(config, new Schedule_for_sync_depthfirst_processing())) { fr.Process(".in", "x"); IMessage result = null; fr.WaitForResult(500, _ => result = _); Assert.AreNotEqual(Thread.CurrentThread.GetHashCode(), result.Data); } }
public void Processing_message_with_async_EBC_method() { var config = new FlowRuntimeConfiguration() .AddStreamsFrom(@" / .in, ebc.Run ebc.Out, .out ") .AddEventBasedComponent("ebc", new AsyncEbc()); using (var fr = new FlowRuntime(config)) { var result = ""; fr.Process(".in", "hello"); Assert.IsTrue(fr.WaitForResult(2000, _ => result = (string)_.Data)); Assert.AreEqual("hellox", result); } }
public void An_output_without_an_input_causes_no_exception() { var frc = new FlowRuntimeConfiguration() .AddStreamsFrom(@" / .in, a ") .AddFunc<string, string>("a", _ => _ + "x"); using(var fr = new FlowRuntime(frc)) { Exception ex = null; fr.UnhandledException += _ => ex = _; fr.Process(".in", "hello"); Assert.IsFalse(fr.WaitForResult(500)); Assert.IsNull(ex); } }
public void Schedule_methode_operation_according_to_attribute() { var config = new FlowRuntimeConfiguration() .AddInstanceOperations(new AsyncMethodOperations()) .AddStreamsFrom(@" / .in, GetThreadHashcode GetThreadHashcode, .out " ); using (var fr = new FlowRuntime(config, new Schedule_for_sync_depthfirst_processing())) { IMessage result = null; fr.Process(".in"); fr.WaitForResult(500, _ => result = _); Assert.AreNotEqual(Thread.CurrentThread.GetHashCode(), (int)result.Data); } }
public void Active_EBC_fires_independently() { var ebc = new ActiveEbc(); var config = new FlowRuntimeConfiguration() .AddStreamsFrom(@" / ebc.Out, .out ") .AddEventBasedComponent("ebc", ebc); using (var fr = new FlowRuntime(config)) { ebc.Run("hello"); var result = ""; Assert.IsTrue(fr.WaitForResult(1000, _ => result = (string)_.Data)); Assert.AreEqual("hellox", result); } }
public void Active_EBC_fires_independently() { var ebc = new ActiveEbc(); var config = new FlowRuntimeConfiguration() .AddStreamsFrom(@" / ebc.Out, .out ") .AddEventBasedComponent("ebc", ebc); using(var fr = new FlowRuntime(config)) { ebc.Run("hello"); var result = ""; Assert.IsTrue(fr.WaitForResult(1000, _ => result = (string) _.Data)); Assert.AreEqual("hellox", result); } }
public void An_output_without_an_input_causes_no_exception() { var frc = new FlowRuntimeConfiguration() .AddStreamsFrom(@" / .in, a " ) .AddFunc <string, string>("a", _ => _ + "x"); using (var fr = new FlowRuntime(frc)) { Exception ex = null; fr.UnhandledException += _ => ex = _; fr.Process(".in", "hello"); Assert.IsFalse(fr.WaitForResult(500)); Assert.IsNull(ex); } }
public void CorrelationId_is_retained() { var config = new FlowRuntimeConfiguration() .AddStreamsFrom(@" / .in, ebc.Run ebc.Out, .out ") .AddEventBasedComponent("ebc", new AsyncEbc()); using (var fr = new FlowRuntime(config, new Schedule_for_sync_depthfirst_processing())) { IMessage result = null; var corrId = Guid.NewGuid(); fr.Process(new Message(".in", "hello", corrId)); Assert.IsTrue(fr.WaitForResult(_ => result = _)); Assert.AreEqual(corrId, result.CorrelationId); } }
static void Main(string[] args) { Console.WriteLine("Generator client..."); var portnumber = 8100 + DateTime.Now.Second; var config = new FlowRuntimeConfiguration() .AddOperations(new AssemblyCrawler(Assembly.GetExecutingAssembly())) .AddStreamsFrom("GeneratorClient.root.flow", Assembly.GetExecutingAssembly()) .AddOperation(new WcfStandInOperation("proxy", "localhost:"+portnumber, "localhost:8000")); using(var fr = new FlowRuntime(config)) { Console.WriteLine("[running @ {0}]", portnumber); fr.Message += Console.WriteLine; fr.UnhandledException += Console.WriteLine; fr.Process(".run"); fr.WaitForResult(); } }
public void An_active_ebc_fires_an_event_before_another_ebc_receives() { var ebc1 = new ActiveEbc(); var config = new FlowRuntimeConfiguration() .AddStreamsFrom(@" / ebc1.Out, ebc2.Run ebc2.Out, .out ") .AddEventBasedComponent("ebc1", ebc1) .AddEventBasedComponent("ebc2", new ActiveEbc()); using (var fr = new FlowRuntime(config)) { ebc1.Run("hello"); var result = ""; Assert.IsTrue(fr.WaitForResult(2000, _ => result = (string)_.Data)); Assert.AreEqual("helloxx", result); } }
public static void Main(string[] args) { using(var fr = new FlowRuntime()) { fr.Message += Console.WriteLine; fr.UnhandledException += Console.WriteLine; fr.AddOperation(new Eindeutige_Stichwörter_ermitteln()); fr.AddStream(".in", "ermitteln.in"); fr.AddStream("ermitteln.out", "auf konsole ausgeben"); fr.AddStream("auf konsole ausgeben", ".out"); fr.AddOperations(new FlowOperationContainer() .AddFunc<IEnumerable<string>,int>("auf konsole ausgeben", Auf_Konsole_ausgeben.Process) .Operations); fr.Process(new Message(".in", new Tuple<string, string>(args[0], args[1]))); fr.WaitForResult(-1); } }
public void Connect_transceivers() { var cre = PubnubCredentials.LoadFrom("pubnub credentials.txt"); using(var host = new PubnubHostTransceiver(cre, "thehost")) { var config = new FlowRuntimeConfiguration() .AddOperation(new PubnubStandInOperation("op", cre, "thehost")) .AddStream(".in", "op#greeting") .AddStream("op#greeting", ".out"); using (var fr = new FlowRuntime(config)) { fr.Message += Console.WriteLine; host.ReceivedFromStandIn += rhi => { var data = (string)rhi.Data.Deserialize(); var ho = new HostOutput { CorrelationId=rhi.CorrelationId, Data =(data + "y").Serialize(), Portname = "greeting" }; ThreadPool.QueueUserWorkItem(_ => { host.SendToStandIn(new Tuple<string, HostOutput>(rhi.StandInEndpointAddress, ho)); }); }; fr.Process(".in", "hello"); var result = ""; Assert.IsTrue(fr.WaitForResult(5000, _ => result = _.Data as string)); Assert.AreEqual("helloy", result); } } }
public void test_cyclic_flow_with_async_action() { Console.WriteLine("test started for {0} flow cycles...", maxCycles); var config = new FlowRuntimeConfiguration() .AddStreamsFrom(@" / .in, cyclic.in cyclic.out0, cyclic.in cyclic.out1, .stopped ") .AddAction<int, int, int>("cyclic", (counter, continueCycling, stopOn) => { if (counter < maxCycles) { Console.WriteLine("cycle {0}", counter); continueCycling(counter+1); } else{ stopOn(maxCycles); } } ).MakeAsync(); using(var fr = new FlowRuntime(config)) { fr.UnhandledException += Console.WriteLine; fr.Process(".in", 1); IMessage result = null; Assert.IsTrue(fr.WaitForResult(5000, _ => result = _), "result not received with 5 seconds"); Assert.AreEqual(".stopped", result.Port.Fullname); Assert.AreEqual(maxCycles, (int)result.Data); } }
public void Connect_transceivers() { var cre = PubnubCredentials.LoadFrom("pubnub credentials.txt"); using (var host = new PubnubHostTransceiver(cre, "thehost")) { var config = new FlowRuntimeConfiguration() .AddOperation(new PubnubStandInOperation("op", cre, "thehost")) .AddStream(".in", "op#greeting") .AddStream("op#greeting", ".out"); using (var fr = new FlowRuntime(config)) { fr.Message += Console.WriteLine; host.ReceivedFromStandIn += rhi => { var data = (string)rhi.Data.Deserialize(); var ho = new HostOutput { CorrelationId = rhi.CorrelationId, Data = (data + "y").Serialize(), Portname = "greeting" }; ThreadPool.QueueUserWorkItem(_ => { host.SendToStandIn(new Tuple <string, HostOutput>(rhi.StandInEndpointAddress, ho)); }); }; fr.Process(".in", "hello"); var result = ""; Assert.IsTrue(fr.WaitForResult(5000, _ => result = _.Data as string)); Assert.AreEqual("helloy", result); } } }
public void An_active_ebc_fires_an_event_before_another_ebc_receives() { var ebc1 = new ActiveEbc(); var config = new FlowRuntimeConfiguration() .AddStreamsFrom(@" / ebc1.Out, ebc2.Run ebc2.Out, .out ") .AddEventBasedComponent("ebc1", ebc1) .AddEventBasedComponent("ebc2", new ActiveEbc()); using (var fr = new FlowRuntime(config)) { ebc1.Run("hello"); var result = ""; Assert.IsTrue(fr.WaitForResult(2000, _ => result = (string)_.Data)); Assert.AreEqual("helloxx", result); } }
public void Processing_message_with_async_EBC_method() { var config = new FlowRuntimeConfiguration() .AddStreamsFrom(@" / .in, ebc.Run ebc.Out, .out ") .AddEventBasedComponent("ebc", new AsyncEbc()); using (var fr = new FlowRuntime(config)) { var result = ""; fr.Process(".in", "hello"); Assert.IsTrue(fr.WaitForResult(2000, _ => result = (string)_.Data)); Assert.AreEqual("hellox", result); } }
public void CorrelationId_is_retained() { var config = new FlowRuntimeConfiguration() .AddStreamsFrom(@" / .in, ebc.Run ebc.Out, .out ") .AddEventBasedComponent("ebc", new AsyncEbc()); using (var fr = new FlowRuntime(config, new Schedule_for_sync_depthfirst_processing())) { IMessage result = null; var corrId = Guid.NewGuid(); fr.Process(new Message(".in", "hello", corrId)); Assert.IsTrue(fr.WaitForResult( _ => result = _)); Assert.AreEqual(corrId, result.CorrelationId); } }
public void High_prio_exception_message_terminates_runtime() { var config = new FlowRuntimeConfiguration() .AddStreamsFrom(@" / .in, doit .stop, .error doit, .result ") .AddAction("doit", (int d, Action<string> continueWith) => { continueWith(d + "x"); continueWith(d + "y"); throw new ApplicationException("arrrghhh!"); }); using (var fr = new FlowRuntime(config)) { IMessage result = null; fr.UnhandledException += ex => { fr.Process(new Message(".stop", ex) { Priority = 99 }); }; fr.Process(".in", 42); Assert.IsTrue(fr.WaitForResult(500, _ => { if (result == null) result = _; })); Assert.AreEqual("error", result.Port.Name); } }