# Path: duct/protocol/riemann.py
# class RiemannProtobufMixin(object):
# class RiemannProtocol(Int32StringReceiver, RiemannProtobufMixin):
# class RiemannClientFactory(protocol.ReconnectingClientFactory):
# class RiemannUDP(DatagramProtocol, RiemannProtobufMixin):
#     def __init__(self):
#     def encodeEvent(self, event):
#     def encodeMessage(self, events):
#     def decodeMessage(self, data):
#     def sendEvents(self, events):
#     def stringReceived(self, string):
#     def __init__(self, hosts, failover=False):
#     def buildProtocol(self, addr):
#     def _do_failover(self, connector):
#     def clientConnectionLost(self, connector, reason):
#     def clientConnectionFailed(self, connector, reason):
#     def __init__(self, host, port):
#     def sendString(self, string):
# 
# Path: duct/objects.py
# class Output(object):
#     """Output parent class
# 
#     Outputs can inherit this object which provides a construct
#     for a working output
# 
#     :param config: Dictionary config for this queue (usually read from the
#              yaml configuration)
#     :param duct: A DuctService object for interacting with the queue manager
#     """
#     def __init__(self, config, duct):
#         self.config = config
#         self.duct = duct
#         self.events = []
#         self.maxsize = 0
# 
#     def createClient(self):
#         """Deferred which sets up the output
#         """
#         pass
# 
#     def eventsReceived(self, events):
#         """Receives a list of events and queues them
# 
#         Arguments:
#         events -- list of `duct.objects.Event`
#         """
#         # Make sure queue isn't oversized
#         if self.maxsize > 0:
#             if (self.maxsize < 1) or (len(self.events) < self.maxsize):
#                 self.events.extend(events)
#         else:
#             self.events.extend(events)
# 
#     def stop(self):
#         """Called when the service shuts down
#         """
#         pass


import time
import random
from twisted.internet import reactor, defer, task
from twisted.python import log
    from OpenSSL import SSL
    from twisted.internet import ssl
from duct.protocol import riemann
from duct.objects import Output
                self.factory.proto.sendEvents(events)
            else:
                self.factory.proto.sendEvents([ev for ev in events
                                               if ev.metric is not None])


class RiemannUDP(Output):
    """Riemann UDP output (spray-and-pray mode)

    **Configuration arguments:**

    :param server: Riemann server IP address (default: 127.0.0.1)
    :type server: str.
    :param port: Riemann server port (default: 5555)
    :type port: int.
    """

    def __init__(self, *a):
        Output.__init__(self, *a)
        self.protocol = None
        self.endpoint = None

    def createClient(self):
        """Create a UDP connection to Riemann"""
        server = self.config.get('server', '127.0.0.1')
        port = self.config.get('port', 5555)

        def connect(ip):
            """Connect to the IP address
            """

# Path: duct/protocol/riemann.py
# class RiemannProtobufMixin(object):
# class RiemannProtocol(Int32StringReceiver, RiemannProtobufMixin):
# class RiemannClientFactory(protocol.ReconnectingClientFactory):
# class RiemannUDP(DatagramProtocol, RiemannProtobufMixin):
#     def __init__(self):
#     def encodeEvent(self, event):
#     def encodeMessage(self, events):
#     def decodeMessage(self, data):
#     def sendEvents(self, events):
#     def stringReceived(self, string):
#     def __init__(self, hosts, failover=False):
#     def buildProtocol(self, addr):
#     def _do_failover(self, connector):
#     def clientConnectionLost(self, connector, reason):
#     def clientConnectionFailed(self, connector, reason):
#     def __init__(self, host, port):
#     def sendString(self, string):
# 
# Path: duct/objects.py
# class Output(object):
#     """Output parent class
# 
#     Outputs can inherit this object which provides a construct
#     for a working output
# 
#     :param config: Dictionary config for this queue (usually read from the
#              yaml configuration)
#     :param duct: A DuctService object for interacting with the queue manager
#     """
#     def __init__(self, config, duct):
#         self.config = config
#         self.duct = duct
#         self.events = []
#         self.maxsize = 0
# 
#     def createClient(self):
#         """Deferred which sets up the output
#         """
#         pass
# 
#     def eventsReceived(self, events):
#         """Receives a list of events and queues them
# 
#         Arguments:
#         events -- list of `duct.objects.Event`
#         """
#         # Make sure queue isn't oversized
#         if self.maxsize > 0:
#             if (self.maxsize < 1) or (len(self.events) < self.maxsize):
#                 self.events.extend(events)
#         else:
#             self.events.extend(events)
# 
#     def stop(self):
#         """Called when the service shuts down
#         """
#         pass


# Path: duct/outputs/riemann.py
import time
import random
from twisted.internet import reactor, defer, task
from twisted.python import log
    from OpenSSL import SSL
    from twisted.internet import ssl
from duct.protocol import riemann
from duct.objects import Output

                self.factory.proto.sendEvents(events)
            else:
                self.factory.proto.sendEvents([ev for ev in events
                                               if ev.metric is not None])


class RiemannUDP(Output):
    """Riemann UDP output (spray-and-pray mode)

    **Configuration arguments:**

    :param server: Riemann server IP address (default: 127.0.0.1)
    :type server: str.
    :param port: Riemann server port (default: 5555)
    :type port: int.
    """

    def __init__(self, *a):
        Output.__init__(self, *a)
        self.protocol = None
        self.endpoint = None

    def createClient(self):
        """Create a UDP connection to Riemann"""
        server = self.config.get('server', '127.0.0.1')
        port = self.config.get('port', 5555)

        def connect(ip):
            """Connect to the IP address
            """

            self.protocol = riemann.RiemannUDP(ip, port)