From 8b787076675a14fb27e9c238d3308b4eec51be2e Mon Sep 17 00:00:00 2001 From: Adam R Grey Date: Wed, 30 Nov 2022 17:43:43 -0500 Subject: [PATCH] meddlists are dead; messages are gray now --- franz.tests/Program.cs | 8 ++++---- franz/Telefranz.cs | 16 ++++++++-------- .../directorial/command_ended.cs | 6 +++--- .../directorial/command_error.cs | 6 +++--- .../directorial/command_output.cs | 6 +++--- .../directorial/execute_command.cs | 6 +++--- .../global/report.cs | 4 ++-- .../global/restart.cs | 6 +++--- franz/gray_messages/global/sound_off.cs | 10 ++++++++++ .../global/stop.cs | 6 +++--- .../message.cs | 2 +- franz/silver_messages/global/sound_off.cs | 10 ---------- 12 files changed, 43 insertions(+), 43 deletions(-) rename franz/{silver_messages => gray_messages}/directorial/command_ended.cs (78%) rename franz/{silver_messages => gray_messages}/directorial/command_error.cs (69%) rename franz/{silver_messages => gray_messages}/directorial/command_output.cs (69%) rename franz/{silver_messages => gray_messages}/directorial/execute_command.cs (85%) rename franz/{silver_messages => gray_messages}/global/report.cs (93%) rename franz/{silver_messages => gray_messages}/global/restart.cs (65%) create mode 100644 franz/gray_messages/global/sound_off.cs rename franz/{silver_messages => gray_messages}/global/stop.cs (66%) rename franz/{silver_messages => gray_messages}/message.cs (96%) delete mode 100644 franz/silver_messages/global/sound_off.cs diff --git a/franz.tests/Program.cs b/franz.tests/Program.cs index fe94c29..fed7b27 100644 --- a/franz.tests/Program.cs +++ b/franz.tests/Program.cs @@ -11,17 +11,17 @@ namespace franz.tests Console.WriteLine("Hello World, Im' " + Dns.GetHostName()); Telefranz.Configure("tester", "alloces:9092", new System.Collections.Generic.List(){"a!"}); - Telefranz.Instance.addHandler(r => { + Telefranz.Instance.addHandler(r => { Console.WriteLine(r); }); - Telefranz.Instance.addHandler((ec) => { + Telefranz.Instance.addHandler((ec) => { if(ec.command == "a!"){ Console.WriteLine($"a! command executing! {string.Join("; ", ec.args)}"); } }); - Telefranz.Instance.ProduceMessage(new silver_messages.global.sound_off()); + Telefranz.Instance.ProduceMessage(new gray_messages.global.sound_off()); System.Threading.Thread.Sleep(15000); - Telefranz.Instance.ProduceMessage(new silver_messages.directorial.execute_command(){ + Telefranz.Instance.ProduceMessage(new gray_messages.directorial.execute_command(){ command= "a!", args= new List(){"param 1", "param 2"} }); diff --git a/franz/Telefranz.cs b/franz/Telefranz.cs index 57cf34a..4ce7f5a 100644 --- a/franz/Telefranz.cs +++ b/franz/Telefranz.cs @@ -16,13 +16,13 @@ namespace franz private static Telefranz instance = null; private static readonly object createLock = new object(); - static class _TelefranzConsumers where T : silver_messages.message + static class _TelefranzConsumers where T : gray_messages.message { internal static readonly Dictionary, Action>> wrappings = new Dictionary, Action>>(); } private string handling_group { get; set; } = "Liszt"; - private silver_messages.global.report howToReport { get; set; } + private gray_messages.global.report howToReport { get; set; } private ClusterClient clusterClient; private Dictionary> topicConsumers { get; set; } = new Dictionary>(); @@ -47,7 +47,7 @@ namespace franz this.clusterClient = new ClusterClient(clusterClientConfig, consoleLogger); handling_group = name; - this.howToReport = new silver_messages.global.report() + this.howToReport = new gray_messages.global.report() { name = name, host = Dns.GetHostName(), @@ -63,11 +63,11 @@ namespace franz howToReport.capabilites.checks = checks; } - addHandler((m) => + addHandler((m) => { ProduceMessage(this.howToReport); }); - addHandler((m) => + addHandler((m) => { if (m.name == handling_group) { @@ -103,7 +103,7 @@ namespace franz return instance; } } - public void addHandler(Action theAction) where T : silver_messages.message + public void addHandler(Action theAction) where T : gray_messages.message { var topic = typeof(T).ToString(); @@ -133,7 +133,7 @@ namespace franz _TelefranzConsumers.wrappings[theAction] = wrapped; topicSubscribers[topic]++; } - public bool removeHandler(Action theAction) where T : silver_messages.message + public bool removeHandler(Action theAction) where T : gray_messages.message { topicConsumers[typeof(T).ToString()].MessageReceived -= _TelefranzConsumers.wrappings[theAction]; if (_TelefranzConsumers.wrappings.ContainsKey(theAction)) @@ -152,7 +152,7 @@ namespace franz } } - public void ProduceMessage(T message) where T : silver_messages.message + public void ProduceMessage(T message) where T : gray_messages.message { Console.WriteLine(message.ToString()); clusterClient.Produce(typeof(T).ToString(), message.ToString()); diff --git a/franz/silver_messages/directorial/command_ended.cs b/franz/gray_messages/directorial/command_ended.cs similarity index 78% rename from franz/silver_messages/directorial/command_ended.cs rename to franz/gray_messages/directorial/command_ended.cs index a57518e..2207418 100644 --- a/franz/silver_messages/directorial/command_ended.cs +++ b/franz/gray_messages/directorial/command_ended.cs @@ -1,10 +1,10 @@ using System; using System.Collections.Generic; -using silver_messages; +using gray_messages; -namespace silver_messages.directorial +namespace gray_messages.directorial { - public abstract class command_ended : silver_messages.message + public abstract class command_ended : gray_messages.message { //name of the command that was called public string command { get; set; } diff --git a/franz/silver_messages/directorial/command_error.cs b/franz/gray_messages/directorial/command_error.cs similarity index 69% rename from franz/silver_messages/directorial/command_error.cs rename to franz/gray_messages/directorial/command_error.cs index 888d0e8..b04c844 100644 --- a/franz/silver_messages/directorial/command_error.cs +++ b/franz/gray_messages/directorial/command_error.cs @@ -1,9 +1,9 @@ using System; using System.Collections.Generic; -using silver_messages; -namespace silver_messages.directorial +using gray_messages; +namespace gray_messages.directorial { - public class command_error : silver_messages.message + public class command_error : gray_messages.message { //name of the command that was called public string command { get; set; } diff --git a/franz/silver_messages/directorial/command_output.cs b/franz/gray_messages/directorial/command_output.cs similarity index 69% rename from franz/silver_messages/directorial/command_output.cs rename to franz/gray_messages/directorial/command_output.cs index b54124a..4ada662 100644 --- a/franz/silver_messages/directorial/command_output.cs +++ b/franz/gray_messages/directorial/command_output.cs @@ -1,9 +1,9 @@ using System; using System.Collections.Generic; -using silver_messages; -namespace silver_messages.directorial +using gray_messages; +namespace gray_messages.directorial { - public class command_output : silver_messages.message + public class command_output : gray_messages.message { //name of the command that was called public string command { get; set; } diff --git a/franz/silver_messages/directorial/execute_command.cs b/franz/gray_messages/directorial/execute_command.cs similarity index 85% rename from franz/silver_messages/directorial/execute_command.cs rename to franz/gray_messages/directorial/execute_command.cs index 88d28a0..dc22133 100644 --- a/franz/silver_messages/directorial/execute_command.cs +++ b/franz/gray_messages/directorial/execute_command.cs @@ -1,8 +1,8 @@ using System; using System.Collections.Generic; -using silver_messages; +using gray_messages; -namespace silver_messages.directorial +namespace gray_messages.directorial { /* * if this is the name of one of your capabilities, pass args to it and execute it. @@ -12,7 +12,7 @@ namespace silver_messages.directorial * command_error as you get them, and if it ends some other way, send command_completed * with empty stdout and stderr. */ - public class execute_command : silver_messages.message + public class execute_command : gray_messages.message { public string command { get; set; } public List args { get; set; } = new List(); diff --git a/franz/silver_messages/global/report.cs b/franz/gray_messages/global/report.cs similarity index 93% rename from franz/silver_messages/global/report.cs rename to franz/gray_messages/global/report.cs index cc4b34b..43f34b2 100644 --- a/franz/silver_messages/global/report.cs +++ b/franz/gray_messages/global/report.cs @@ -1,8 +1,8 @@ using System; using System.Collections.Generic; -namespace silver_messages.global +namespace gray_messages.global { - public class report : silver_messages.message + public class report : gray_messages.message { //your name public string name { get; set; } diff --git a/franz/silver_messages/global/restart.cs b/franz/gray_messages/global/restart.cs similarity index 65% rename from franz/silver_messages/global/restart.cs rename to franz/gray_messages/global/restart.cs index 57248a1..3b2f5be 100644 --- a/franz/silver_messages/global/restart.cs +++ b/franz/gray_messages/global/restart.cs @@ -1,10 +1,10 @@ using System; using System.Collections.Generic; -using silver_messages; +using gray_messages; -namespace silver_messages.global +namespace gray_messages.global { - public class restart : silver_messages.message + public class restart : gray_messages.message { //check if this is you (i.e., your handling group). If so, restart. Yourself, not the hardware. public string name { get; set; } diff --git a/franz/gray_messages/global/sound_off.cs b/franz/gray_messages/global/sound_off.cs new file mode 100644 index 0000000..96ed340 --- /dev/null +++ b/franz/gray_messages/global/sound_off.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using gray_messages; + +namespace gray_messages.global +{ + //if you receive this, respond with a report + public class sound_off : gray_messages.message { } +} + diff --git a/franz/silver_messages/global/stop.cs b/franz/gray_messages/global/stop.cs similarity index 66% rename from franz/silver_messages/global/stop.cs rename to franz/gray_messages/global/stop.cs index c438479..fe362c9 100644 --- a/franz/silver_messages/global/stop.cs +++ b/franz/gray_messages/global/stop.cs @@ -1,10 +1,10 @@ using System; using System.Collections.Generic; -using silver_messages; +using gray_messages; -namespace silver_messages.global +namespace gray_messages.global { - public class stop : silver_messages.message + public class stop : gray_messages.message { //check if this is you (i.e., your handling group). If so, stop. Yourself, not the hardware. public string name { get; set; } diff --git a/franz/silver_messages/message.cs b/franz/gray_messages/message.cs similarity index 96% rename from franz/silver_messages/message.cs rename to franz/gray_messages/message.cs index 6b64ceb..a1b982b 100644 --- a/franz/silver_messages/message.cs +++ b/franz/gray_messages/message.cs @@ -4,7 +4,7 @@ using System.IO; using Kafka.Public; using Newtonsoft.Json; -namespace silver_messages +namespace gray_messages { //protip: you can derive from message and I'll dispatch it back to you just as you would expect public abstract class message : IMemorySerializable diff --git a/franz/silver_messages/global/sound_off.cs b/franz/silver_messages/global/sound_off.cs deleted file mode 100644 index b908a0a..0000000 --- a/franz/silver_messages/global/sound_off.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System; -using System.Collections.Generic; -using silver_messages; - -namespace silver_messages.global -{ - //if you receive this, respond with a report - public class sound_off : silver_messages.message { } -} -