示例#1
0
        def decorator(func):
            logger.info(
                "Registering handler and broadcast '{}' for channel: {} and {} and on queue ({}, {}) "
                .format(func.__name__, in_channel, out_channel, in_queue,
                        ','.join(out_queues)))
            assert in_channel in self.channel_configurations
            host, port, username, password = self.channel_configurations[
                in_channel]
            config = {
                'max_workers': max_workers,
                'middlewares': {
                    in_channel: {
                        'host': host,
                        'port': port,
                        'username': username,
                        'password': password
                    }
                }
            }
            flow = Flow(config, loop=self.loop)
            flow.add_listener(in_channel, in_queue)
            flow.add_worker(func)
            flow.add_broadcast_publisher(out_channel, *out_queues)
            self.flows.append(flow)
            logger.info(
                'flow [handler and broadcast: {}] {} {} {} {} {}'.format(
                    flow.id, in_channel, in_queue, out_channel,
                    ','.join(out_queues), 'ready'))

            return func
示例#2
0
        def decorator(func):
            logger.info(
                "Registering collector {} for channel: {} on queue ({}) with callback {}"
                .format(func.__name__, in_channel, in_queue, callback))
            assert in_channel in self.channel_configurations
            host, port, username, password = self.channel_configurations[
                in_channel]
            config = {
                'max_workers': max_workers,
                'middlewares': {
                    in_channel: {
                        'host': host,
                        'port': port,
                        'username': username,
                        'password': password
                    }
                }
            }
            flow = Flow(config, loop=self.loop)
            flow.add_listener(in_channel, in_queue)
            flow.add_worker(func)
            flow.add_sink(reducer, callback=callback, count=count)
            self.flows.append(flow)
            logger.info('flow [handle and collect: {}] {} {} {}'.format(
                flow.id, in_channel, in_channel, 'ready'))

            return func
示例#3
0
        def decorator(func):
            logger.info(
                "Registering handler {} for channel: {} on queues ({}, {})".
                format(func.__name__, channel, queue_request, queue_response))
            assert channel in self.channel_configurations
            host, port, username, password = self.channel_configurations[
                channel]
            config = {
                'max_workers': max_workers,
                'middlewares': {
                    channel: {
                        'host': host,
                        'port': port,
                        'username': username,
                        'password': password
                    }
                }
            }
            flow = Flow(config, loop=self.loop)
            flow.add_listener(channel, queue_request)
            if queue_response is None:
                flow.add_sink(func)
            else:
                flow.add_worker(func).add_publisher(channel, queue_response)
            self.flows.append(flow)
            logger.info('flow [handler: {}] {} {} {} {}'.format(
                flow.id, channel, queue_request, queue_response, 'ready'))

            return func
示例#4
0
        def decorator(func):
            logger.info(
                "Registering handler {} for channel: {} on queues ({})".format(
                    func.__name__, in_channel, in_queue))
            assert in_channel in self.channel_configurations
            host, port, username, password = self.channel_configurations[
                in_channel]
            config = {
                'max_workers': max_workers,
                'middlewares': {
                    in_channel: {
                        'host': host,
                        'port': port,
                        'username': username,
                        'password': password
                    }
                }
            }
            flow = Flow(config, loop=self.loop)\
                .add_listener(in_channel, in_queue)\
                .add_sink(func)
            self.flows.append(flow)
            logger.info('flow [subscriber: {}] {} {} {}'.format(
                flow.id, in_channel, in_queue, 'ready'))

            return func
示例#5
0
        def decorator(func):
            logger.info(
                "Registering handler {} for channel: {} on queues ({})".format(
                    func.__name__, out_channel, out_queue))
            assert out_channel in self.channel_configurations
            host, port, username, password = self.channel_configurations[
                out_channel]
            config = {
                'max_workers': None,
                'middlewares': {
                    out_channel: {
                        'host': host,
                        'port': port,
                        'username': username,
                        'password': password
                    }
                }
            }
            flow = Flow(config, loop=self.loop) \
                .add_generator(func) \
                .add_publisher(out_channel, out_queue)
            self.flows.append(flow)
            logger.info('flow [publisher: {}] {} {} {}'.format(
                flow.id, out_channel, out_queue, 'ready'))

            return func
示例#6
0
        def decorator(func):
            logger.info(
                    "Registering handler {} for channel: {} on queues ({"
                    "})".format(
                            func.__name__, in_channel, in_queue))
            assert in_channel in self.channel_configurations
            config = self._get_config(in_channel, max_workers)
            flow = Flow(config, loop=self.loop) \
                .add_listener(in_channel, in_queue) \
                .add_sink(func)
            self.flows.append(flow)
            logger.info(
                'flow [subscriber: {}] {} {} {}'.format(flow.id, in_channel,
                                                        in_queue, 'ready'))

            return func
示例#7
0
        def decorator(func):
            logger.info(
                    "Registering handler {} for channel: {} on queues ({"
                    "})".format(
                            func.__name__, out_channel, out_queue))
            assert out_channel in self.channel_configurations
            config = self._get_config(out_channel, None)
            flow = Flow(config, loop=self.loop) \
                .add_generator(func) \
                .add_publisher(out_channel, out_queue)
            self.flows.append(flow)
            logger.info(
                'flow [publisher: {}] {} {} {}'.format(flow.id, out_channel,
                                                       out_queue, 'ready'))

            return func
示例#8
0
        def decorator(func):
            logger.info(
                    "Registering collector {} for channel: {} on queue ({}) "
                    "with callback {}".format(
                            func.__name__, in_channel, in_queue, callback
                    ))
            assert in_channel in self.channel_configurations
            config = self._get_config(in_channel, max_workers)
            flow = Flow(config, loop=self.loop)
            flow.add_listener(in_channel, in_queue)
            flow.add_worker(func)
            flow.add_sink(reducer, callback=callback, count=count)
            self.flows.append(flow)
            logger.info('flow [handle and collect: {}] {} {} {}'.format(flow.id,
                                                                        in_channel,
                                                                        in_channel,
                                                                        'ready'))

            return func
示例#9
0
        def decorator(func):
            logger.info(
                    "Registering handler and broadcast '{}' for channel: {} "
                    "and {} and on queue ({}, {}) ".format(
                            func.__name__, in_channel, out_channel, in_queue,
                            ','.join(out_queues)
                    ))
            assert in_channel in self.channel_configurations
            config = self._get_config(in_channel, max_workers)
            flow = Flow(config, loop=self.loop)
            flow.add_listener(in_channel, in_queue)
            flow.add_worker(func)
            flow.add_broadcast_publisher(out_channel, *out_queues)
            self.flows.append(flow)
            logger.info(
                'flow [handler and broadcast: {}] {} {} {} {} {}'.format(
                    flow.id, in_channel, in_queue, out_channel,
                    ','.join(out_queues), 'ready'))

            return func
示例#10
0
        def decorator(func):
            logger.info(
                    "Registering handler {} for channel: {} on queues ({}, "
                    "{})".format(
                            func.__name__, channel, queue_request,
                            queue_response
                    ))
            assert channel in self.channel_configurations
            config = self._get_config(channel, max_workers)
            flow = Flow(config, loop=self.loop)
            flow.add_listener(channel, queue_request)
            if queue_response is None:
                flow.add_sink(func)
            else:
                flow.add_worker(func).add_publisher(channel, queue_response)
            self.flows.append(flow)
            logger.info(
                'flow [handler: {}] {} {} {} {}'.format(flow.id, channel,
                                                        queue_request,
                                                        queue_response,
                                                        'ready'))

            return func