meshtastic-metrics-exporter/exporter/processors.py

17 lines
507 B
Python
Raw Normal View History

2024-06-23 12:15:31 -07:00
from meshtastic.mesh_pb2 import MeshPacket
from prometheus_client import CollectorRegistry
from exporter.registry import ProcessorRegistry
class MessageProcessor:
def __init__(self, registry: CollectorRegistry):
self.registry = registry
def process(self, mesh_packet: MeshPacket):
port_num = mesh_packet.decoded.portnum
payload = mesh_packet.decoded.payload
processor = ProcessorRegistry.get_processor(port_num)(self.registry)
processor.process(payload)