Exemple #1
0
def _parse_pool_options(options):
    """Parse connection pool options."""
    max_pool_size = options.get('maxpoolsize', common.MAX_POOL_SIZE)
    min_pool_size = options.get('minpoolsize', common.MIN_POOL_SIZE)
    max_idle_time_seconds = options.get('maxidletimems',
                                        common.MAX_IDLE_TIME_SEC)
    if max_pool_size is not None and min_pool_size > max_pool_size:
        raise ValueError("minPoolSize must be smaller or equal to maxPoolSize")
    connect_timeout = options.get('connecttimeoutms', common.CONNECT_TIMEOUT)
    socket_keepalive = options.get('socketkeepalive', True)
    socket_timeout = options.get('sockettimeoutms')
    wait_queue_timeout = options.get('waitqueuetimeoutms',
                                     common.WAIT_QUEUE_TIMEOUT)
    wait_queue_multiple = options.get('waitqueuemultiple')
    event_listeners = options.get('event_listeners')
    appname = options.get('appname')
    driver = options.get('driver')
    compression_settings = CompressionSettings(
        options.get('compressors', []), options.get('zlibcompressionlevel',
                                                    -1))
    ssl_context, ssl_match_hostname = _parse_ssl_options(options)
    return PoolOptions(max_pool_size, min_pool_size, max_idle_time_seconds,
                       connect_timeout, socket_timeout, wait_queue_timeout,
                       wait_queue_multiple, ssl_context,
                       ssl_match_hostname, socket_keepalive,
                       _EventListeners(event_listeners), appname, driver,
                       compression_settings)
def _parse_pool_options(options):
    """Parse connection pool options."""
    max_pool_size = options.get('maxpoolsize', common.MAX_POOL_SIZE)
    min_pool_size = options.get('minpoolsize', common.MIN_POOL_SIZE)
    max_idle_time_seconds = options.get('maxidletimems',
                                        common.MAX_IDLE_TIME_SEC)
    if max_pool_size is not None and min_pool_size > max_pool_size:
        raise ValueError("minPoolSize must be smaller or equal to maxPoolSize")
    connect_timeout = options.get('connecttimeoutms', common.CONNECT_TIMEOUT)
    socket_timeout = options.get('sockettimeoutms')
    wait_queue_timeout = options.get('waitqueuetimeoutms',
                                     common.WAIT_QUEUE_TIMEOUT)
    event_listeners = options.get('event_listeners')
    appname = options.get('appname')
    driver = options.get('driver')
    server_api = options.get('server_api')
    compression_settings = CompressionSettings(
        options.get('compressors', []), options.get('zlibcompressionlevel',
                                                    -1))
    ssl_context, tls_allow_invalid_hostnames = _parse_ssl_options(options)
    load_balanced = options.get('loadbalanced')
    return PoolOptions(max_pool_size,
                       min_pool_size,
                       max_idle_time_seconds,
                       connect_timeout,
                       socket_timeout,
                       wait_queue_timeout,
                       ssl_context,
                       tls_allow_invalid_hostnames,
                       _EventListeners(event_listeners),
                       appname,
                       driver,
                       compression_settings,
                       server_api=server_api,
                       load_balanced=load_balanced)
Exemple #3
0
def _parse_pool_options(username, password, database, options):
    """Parse connection pool options."""
    credentials = _parse_credentials(username, password, database, options)
    max_pool_size = options.get("maxpoolsize", common.MAX_POOL_SIZE)
    min_pool_size = options.get("minpoolsize", common.MIN_POOL_SIZE)
    max_idle_time_seconds = options.get("maxidletimems",
                                        common.MAX_IDLE_TIME_SEC)
    if max_pool_size is not None and min_pool_size > max_pool_size:
        raise ValueError("minPoolSize must be smaller or equal to maxPoolSize")
    connect_timeout = options.get("connecttimeoutms", common.CONNECT_TIMEOUT)
    socket_timeout = options.get("sockettimeoutms")
    wait_queue_timeout = options.get("waitqueuetimeoutms",
                                     common.WAIT_QUEUE_TIMEOUT)
    event_listeners = options.get("event_listeners")
    appname = options.get("appname")
    driver = options.get("driver")
    server_api = options.get("server_api")
    compression_settings = CompressionSettings(
        options.get("compressors", []), options.get("zlibcompressionlevel",
                                                    -1))
    ssl_context, tls_allow_invalid_hostnames = _parse_ssl_options(options)
    load_balanced = options.get("loadbalanced")
    max_connecting = options.get("maxconnecting", common.MAX_CONNECTING)
    return PoolOptions(
        max_pool_size,
        min_pool_size,
        max_idle_time_seconds,
        connect_timeout,
        socket_timeout,
        wait_queue_timeout,
        ssl_context,
        tls_allow_invalid_hostnames,
        _EventListeners(event_listeners),
        appname,
        driver,
        compression_settings,
        max_connecting=max_connecting,
        server_api=server_api,
        load_balanced=load_balanced,
        credentials=credentials,
    )