Пример #1
0
    def encodeMessage(self, events):
        """Encode a list of Duct events with protobuf"""

        encoded = [self.encodeEvent(ev) for ev in events
                   if ev.evtype == 'metric']

        return proto_pb2.Msg(events=encoded).SerializeToString()
Пример #2
0
 def stringReceived(self, string):
     msg = proto_pb2.Msg.FromString(string)
     self.factory.receive_message(msg)
     self.sendString(proto_pb2.Msg(ok=True).SerializeToString())
Пример #3
0
    def decodeMessage(self, data):
        """Decode a protobuf message into a list of Duct events"""
        message = proto_pb2.Msg()
        message.ParseFromString(data)

        return message