# Path: duct/interfaces.py
# class IDuctProtocol(Interface):
#     """Interface for Duct client protocols"""
# 
#     def sendEvent(self, event):
#         """Sends an event to this client"""
#         pass


from duct.ihateprotobuf import proto_pb2
from duct.interfaces import IDuctProtocol
from zope.interface import implementer
from twisted.protocols.basic import Int32StringReceiver
from twisted.internet.protocol import DatagramProtocol
from twisted.internet import protocol
from twisted.python import log
                pbevent.metric_d = float(event.metric)
                pbevent.metric_f = float(event.metric)

        if event.attributes is not None:
            for key, value in event.attributes.items():
                attribute = pbevent.attributes.add()
                attribute.key, attribute.value = key, value

        return pbevent

    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()

    def decodeMessage(self, data):
        """Decode a protobuf message into a list of Duct events"""
        message = proto_pb2.Msg()
        message.ParseFromString(data)

        return message

    def sendEvents(self, events):
        """Send a Duct Event to Riemann"""
        self.pressure += 1
        self.sendString(self.encodeMessage(events))


# Path: duct/interfaces.py
# class IDuctProtocol(Interface):
#     """Interface for Duct client protocols"""
# 
#     def sendEvent(self, event):
#         """Sends an event to this client"""
#         pass


# Path: duct/protocol/riemann.py
from duct.ihateprotobuf import proto_pb2
from duct.interfaces import IDuctProtocol
from zope.interface import implementer
from twisted.protocols.basic import Int32StringReceiver
from twisted.internet.protocol import DatagramProtocol
from twisted.internet import protocol
from twisted.python import log

                pbevent.metric_d = float(event.metric)
                pbevent.metric_f = float(event.metric)

        if event.attributes is not None:
            for key, value in event.attributes.items():
                attribute = pbevent.attributes.add()
                attribute.key, attribute.value = key, value

        return pbevent

    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()

    def decodeMessage(self, data):
        """Decode a protobuf message into a list of Duct events"""
        message = proto_pb2.Msg()
        message.ParseFromString(data)

        return message

    def sendEvents(self, events):
        """Send a Duct Event to Riemann"""
        self.pressure += 1
        self.sendString(self.encodeMessage(events))


@implementer(IDuctProtocol)