Beispiel #1
0
    def get_configs(self, path):
        c = Configuration(path=path)
        c.required = {
            'hostname',
            'username',
            'password',
            'vhost',
            'exchange',
            'queue',
        }
        c.accepted = {
            'durable_queue',
            'auto_delete_queue',
            'exchange_type',
            'durable_exchange',
            'auto_delete_exchange',
            'timeout',
        }
        if not c.read():
            raise Exception('Configuration file not set properly.')
        configs = c.result

        if 'durable_queue' in configs:
            configs['durable_queue'] = bool(configs['durable_queue'])
        else:
            configs['durable_queue'] = True

        if 'auto_delete_queue' in configs:
            configs['auto_delete_queue'] = bool(configs['auto_delete_queue'])
        else:
            configs['auto_delete_queue'] = False

        if 'exchange_type' not in configs:
            configs['exchange_type'] = 'fanout'

        if 'durable_exchange' in configs:
            configs['durable_exchange'] = bool(configs['durable_exchange'])
        else:
            configs['durable_exchange'] = True

        if 'auto_delete_exchange' in configs:
            configs['auto_delete_exchange'] = bool(configs['auto_delete_exchange'])
        else:
            configs['auto_delete_exchange'] = False

        if 'timeout' in configs:
            configs['timeout'] = int(configs['timeout'])
        else:
            configs['timeout'] = None

        return configs
Beispiel #2
0
    parser = argparse.ArgumentParser(
        description=('Create a pool of RabbitMQ/Eventlet workers.'),
    )
    parser.add_argument(
        '-c',
        '--configuration',
        help='Specify the path to the worker.conf file.',
        required=True,
    )
    args = vars(parser.parse_args())

    c = Configuration(path=args['configuration'])
    c.required = {
        'hostname',
        'username',
        'password',
        'vhost',
        'queue',
    }
    c.accepted = {
        'num_threads',
        'timeout',
    }
    if not c.read():
        raise Exception('Configuration file not set properly.')
    configs = c.result

    if 'timeout' in configs:
        configs['timeout'] = int(configs['timeout'])
    else:
        configs['timeout'] = None