Another tool for the dispatcher.
authorEric S. Raymond <esr@thyrsus.com>
Thu, 30 Aug 2012 14:04:40 +0000 (10:04 -0400)
committerEric S. Raymond <esr@thyrsus.com>
Thu, 30 Aug 2012 14:04:40 +0000 (10:04 -0400)
irker.py

index a1c8e69580bc1285cfd52e3ef0df19f611b3e376..ec82e78b59d4375c34a0460d2597437e70bc11ef 100755 (executable)
--- a/irker.py
+++ b/irker.py
@@ -184,7 +184,7 @@ class Irker:
         thread = threading.Thread(target=self.irc.process_forever)
         self.irc._thread = thread
         thread.start()
-        self.ircds = {}
+        self.servers = {}
     def logerr(self, errmsg):
         "Log a processing error."
         sys.stderr.write("irker: " + errmsg + "\n")
@@ -204,6 +204,9 @@ class Irker:
         "Nick not accepted for this connection."
         if connection.context:
             connection.context.handle_badnick()
+    def drop_server(servername, port):
+        "Drop a server out of the server map."
+        del self.servers[(servername, port)]
     def handle(self, line):
         "Perform a JSON relay request."
         try:
@@ -224,9 +227,9 @@ class Irker:
                             self.logerr("malformed request - unexpected type: %s" % repr(request))
                         else:
                             target = Target(url)
-                            if target.server() not in self.ircds:
-                                self.ircds[target.server()] = Dispatcher(self, target.servername, target.port)
-                            self.ircds[target.server()].dispatch(target.channel, message)
+                            if target.server() not in self.servers:
+                                self.servers[target.server()] = Dispatcher(self, target.servername, target.port)
+                            self.servers[target.server()].dispatch(target.channel, message)
         except ValueError:
             self.logerr("can't recognize JSON on input: %s" % repr(line))