]> average.org Git - loctrkd.git/blobdiff - loctrkd/watch.py
protocols: introduce method `rectified()`
[loctrkd.git] / loctrkd / watch.py
index b2b5c063f25ccc6e8eebf0e6c2044afd0f18ed40..6d3dcd9fa8ed7eb1f4eba1cdacd266549e9b2519 100644 (file)
@@ -8,21 +8,12 @@ from typing import Any, cast, List
 import zmq
 
 from . import common
+from .protomodule import ProtoModule
 from .zmsg import Bcast
 
 log = getLogger("loctrkd/watch")
 
 
-class ProtoModule:
-    @staticmethod
-    def proto_handled(proto: str) -> bool:
-        ...
-
-    @staticmethod
-    def parse_message(packet: bytes, is_incoming: bool = True) -> Any:
-        ...
-
-
 pmods: List[ProtoModule] = []
 
 
@@ -30,7 +21,7 @@ def runserver(conf: ConfigParser) -> None:
     global pmods
     pmods = [
         cast(ProtoModule, import_module("." + modnm, __package__))
-        for modnm in conf.get("collector", "protocols").split(",")
+        for modnm in conf.get("common", "protocols").split(",")
     ]
     # Is this https://github.com/zeromq/pyzmq/issues/1627 still not fixed?!
     zctx = zmq.Context()  # type: ignore
@@ -46,6 +37,8 @@ def runserver(conf: ConfigParser) -> None:
                 if pmod.proto_handled(zmsg.proto):
                     msg = pmod.parse_message(zmsg.packet, zmsg.is_incoming)
                     print(msg)
+                    if zmsg.is_incoming and hasattr(msg, "rectified"):
+                        print(msg.rectified())
     except KeyboardInterrupt:
         pass