// // Launch a process that adds the int sent in a message to its state // Then calls itself after a second to do the same again. The state value gradually // increases. // // If you stop the sample and restart you'll notice the state has been persisted // static void Main(string[] args) { // Log what's going on ProcessSystemLog.Subscribe(Console.WriteLine); // Let Language Ext know that Redis exists RedisCluster.register(); // Connect to the Redis cluster ProcessConfig.initialise("sys", "global", "redis-test", "localhost", "0"); // Spawn the process var pid = spawn <string>("redis-inbox-sample", Inbox, ProcessFlags.PersistInbox); Console.WriteLine("Press a key to add 100 messages to the process queue"); Console.WriteLine(" - The process queue has a Thread.Sleep(200) in it"); Console.WriteLine(" - So it takes 20 seconds to get through all of the messages"); Console.WriteLine(" - If you quit the sample and restart, you should see the "); Console.WriteLine(" - inbox has persisted."); Console.WriteLine(""); Console.WriteLine("Press a key"); Console.ReadKey(); var rnd = new Random(); for (var i = 0; i < 100; i++) { tell(pid, "Message sent: " + DateTime.Now + " " + DateTime.Now.Ticks + " " + rnd.Next()); } Console.ReadKey(); }
static void Main(string[] args) { // Remove this to get on-screen logging ProcessSystemLog.Subscribe(Console.WriteLine); var ping = ProcessId.None; var pong = ProcessId.None; // Start a process which simply writes the messages it receives to std-out var logger = spawn <string>("logger", Console.WriteLine); // Ping process ping = spawn <string>("ping", msg => { tell(logger, msg); tell(pong, "ping", TimeSpan.FromMilliseconds(100)); }); // Pong process pong = spawn <string>("pong", msg => { tell(logger, msg); tell(ping, "pong", TimeSpan.FromMilliseconds(100)); }); // Trigger tell(pong, "start"); Console.ReadKey(); }
static void Main(string[] args) { //Tests.QueueCollectionFunctions(); //Tests.StackCollectionFunctions(); //Tests.WrappedListOfOptionsTest1(); //Tests.WrappedListOfOptionsTest2(); //Tests.Lists(); ProcessSystemLog.Subscribe(Console.WriteLine); Tests.KillChildTest(); Tests.ProcessStartupError(); //Tests.LocalRegisterTest(); Tests.AskReply(); Tests.MassiveSpawnAndKillHierarchy(); Tests.AskReplyError(); //Tests.RegisterTest(); Tests.ProcessStartupError(); //Tests.RegisteredAskReply(); Tests.ClassBasedProcess(); Tests.AsyncOption(); Tests.MapOptionTest(); Tests.MassAddRemoveTest(); Tests.SpawnProcess(); Tests.SpawnProcess(); Tests.SpawnProcess(); Tests.PubSubTest(); Tests.SpawnErrorSurviveProcess(); Tests.SpawnErrorSurviveProcess(); Tests.SpawnErrorSurviveProcess(); Tests.SpawnAndKillHierarchy(); Tests.SpawnAndKillHierarchy(); Tests.SpawnAndKillHierarchy(); Tests.SpawnAndKillProcess(); Tests.SpawnAndKillProcess(); Tests.SpawnAndKillProcess(); Tests.MassiveSpawnAndKillHierarchy(); Tests.MassiveSpawnAndKillHierarchy2(); Tests.ReaderAskTest(); Tests.LiftTest(); Tests.BindingTest(); Tests.WrappedOptionOptionLinqTest(); Tests.WrappedListLinqTest(); Tests.WrappedListTest(); Tests.LinqTest(); Tests.ExTest4(); Tests.MemoTest(); Tests.UnsafeOptionTest(); }
static void Main(string[] args) { // Remove this to get on-screen logging ProcessSystemLog.Subscribe(Console.WriteLine); // Let Language Ext know that Redis exists RedisCluster.register(); // Connect to the Redis cluster ProcessConfig.initialiseFileSystem("session-test-1"); var ping = ProcessId.None; var pong = ProcessId.None; // Start a process which simply writes the messages it receives to std-out var logger = spawn <string>("logger", x => Console.WriteLine(x)); sessionStart("xyz", 20 * seconds, "live"); // Ping process ping = spawn <string>("ping", msg => { tell(logger, msg); var txt = hasSession() ? sessionId().ToString() : "expired"; var val = sessionGetData <int>("test"); sessionSetData("test", val.FirstOrDefault() + 1); tell(pong, $"ping-{txt}-{val.FirstOrDefault()}", TimeSpan.FromMilliseconds(1000)); }); // Pong process pong = spawn <string>("pong", msg => { tell(logger, msg); var txt = hasSession() ? sessionId().ToString() : "expired"; var val = sessionGetData <int>("test"); sessionSetData("test", val.FirstOrDefault() + 1); tell(ping, $"pong-{txt}-{val.FirstOrDefault()}", TimeSpan.FromMilliseconds(1000)); }); // Trigger tell(pong, "start"); Console.ReadKey(); }
public static void Main(string[] args) { // Remove this to get on-screen logging ProcessSystemLog.Subscribe(Console.WriteLine); RedisCluster.register(); ProcessConfig.initialiseFileSystem("ping-pong-1"); var ping = ProcessId.None; var pong = ProcessId.None; Process.PreShutdown.Subscribe(_ => { kill(ping); kill(pong); }); // Start a process which simply writes the messages it receives to std-out var logger = spawn <string>("logger", x => Console.WriteLine(x)); // Ping process ping = spawn <string>("ping", msg => { tell(logger, msg); var res = readList <int>("arr"); var name = read("name", ""); var ind = read("count", 0); write("count", ind + 1); tell(pong, $"ping {name}-{ind}", TimeSpan.FromMilliseconds(100)); }); // Pong process pong = spawn <string>("pong", msg => { tell(logger, msg); var map = readMap <string>("map"); var name = read("name", ""); var ind = read("count", 0); write("count", ind + 1); tell(ping, $"pong {name}-{ind}", TimeSpan.FromMilliseconds(100)); }); // Trigger tell(ping, "start"); Console.ReadKey(); Process.shutdownAll(); }
static void Main(string[] args) { // Remove this to get on-screen logging ProcessSystemLog.Subscribe(Console.WriteLine); // Let Language Ext know that Redis exists RedisCluster.register(); // Connect to the Redis cluster Cluster.connect("redis", "redis-session-test", "localhost:6379", "0", "global"); var ping = ProcessId.None; var pong = ProcessId.None; // Start a process which simply writes the messages it receives to std-out var logger = spawn <string>("logger", Console.WriteLine); sessionStart("xyz", 20 * seconds); // Ping process ping = spawn <string>("ping", msg => { tell(logger, msg); var txt = hasSession() ? sessionId().ToString() : "expired"; tell(pong, "ping-" + txt, TimeSpan.FromMilliseconds(1000)); }); // Pong process pong = spawn <string>("pong", msg => { tell(logger, msg); var txt = hasSession() ? sessionId().ToString() : "expired"; tell(ping, "pong-" + txt, TimeSpan.FromMilliseconds(1000)); }); // Trigger tell(pong, "start"); Console.ReadKey(); }
/// <summary> /// Start up the process log /// </summary> /// <param name="processNameOverride">Override the default process name</param> /// <param name="logViewMax">Size of the log 'window'</param> public static Unit startup(Option <ProcessName> processNameOverride, int logViewMax = 200, SystemName system = default(SystemName)) { if (processId.IsValid) { return(unit); } lock (sync) { if (processId.IsValid) { return(unit); } processName = processNameOverride.IfNone("process-log"); processId = spawn <State, ProcessLogItem>(processName, () => setup(logViewMax), inbox); deadLetterSub = subscribe <DeadLetter>(DeadLetters(system), msg => tellWarning(msg.ToString())); errorSub = subscribe <Exception>(Errors(system), e => tellError(e)); ProcessSystemLog.Subscribe(tell); } return(unit); }
static void Main(string[] args) { var someValue = FSharpOption <string> .Some("Hello"); var noneValue = FSharpOption <string> .None; Console.WriteLine(someValue.Value); Console.WriteLine(noneValue.Value); Tests.PStringCasting(); return; Tests.VersionTest(); Tests.SerialiseDeserialiseCoreTypes(); //Tests.StopStart(); //Tests.QueueCollectionFunctions(); //Tests.StackCollectionFunctions(); //Tests.WrappedListOfOptionsTest1(); //Tests.WrappedListOfOptionsTest2(); //Tests.Lists(); ProcessSystemLog.Subscribe(Console.WriteLine); Tests.KillChildTest(); Tests.ProcessStartupError(); //Tests.LocalRegisterTest(); Tests.AskReply(); Tests.MassiveSpawnAndKillHierarchy(); Tests.AskReplyError(); //Tests.RegisterTest(); Tests.ProcessStartupError(); //Tests.RegisteredAskReply(); Tests.ClassBasedProcess(); Tests.AsyncOption(); Tests.MapOptionTest(); Tests.MassAddRemoveTest(); Tests.SpawnProcess(); Tests.SpawnProcess(); Tests.SpawnProcess(); Tests.PubSubTest(); Tests.SpawnErrorSurviveProcess(); Tests.SpawnErrorSurviveProcess(); Tests.SpawnErrorSurviveProcess(); Tests.SpawnAndKillHierarchy(); Tests.SpawnAndKillHierarchy(); Tests.SpawnAndKillHierarchy(); Tests.SpawnAndKillProcess(); Tests.SpawnAndKillProcess(); Tests.SpawnAndKillProcess(); Tests.MassiveSpawnAndKillHierarchy(); Tests.MassiveSpawnAndKillHierarchy2(); Tests.ReaderAskTest(); Tests.LiftTest(); Tests.BindingTest(); Tests.WrappedOptionOptionLinqTest(); Tests.WrappedListLinqTest(); Tests.WrappedListTest(); Tests.ExTest4(); Tests.MemoTest(); Tests.UnsafeOptionTest(); }