How to use the socketshark.config_defaults function in socketshark

To help you get started, we’ve selected a few socketshark examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github closeio / socketshark / tests / test_basic.py View on Github external
import pytest

from socketshark import (config_defaults, constants as c, setup_logging,
                         SocketShark)
from socketshark.session import Session

LOCAL_REDIS_HOST = os.environ.get('LOCAL_REDIS_HOST')
if not LOCAL_REDIS_HOST:
    LOCAL_REDIS_HOST = '127.0.0.1'

TEST_CONFIG = {
    'BACKEND': 'websockets',
    'WS_HOST': '127.0.0.1',
    'WS_PORT': 9001,
    'WS_PING': {'interval': 0.1, 'timeout': 0.1},
    'LOG': config_defaults.LOG,
    'METRICS': {},
    'REDIS': {
        'host': LOCAL_REDIS_HOST,
        'port': 6379,
        'channel_prefix': '',
        'ping_interval': 0.1,
        'ping_timeout': 0.1,
    },
    'HTTP': {
        'timeout': 1,
        'tries': 1,
        'wait': 1,
        'rate_limit_reset_header_name': 'X-Rate-Limit-Reset',
    },
    'AUTHENTICATION': {
        'ticket': {
github closeio / socketshark / socketshark / __init__.py View on Github external
def load_config(config_name):
    config = {}

    # Get config defaults
    for key in dir(config_defaults):
        if key.isupper():
            config[key] = getattr(config_defaults, key)

    # Merge given config with defaults
    obj = importlib.import_module(config_name)
    for key in dir(obj):
        if key in config:
            value = getattr(obj, key)
            if isinstance(config[key], dict):
                config[key].update(value)
            else:
                config[key] = value

    return config
github closeio / socketshark / socketshark / __init__.py View on Github external
def load_config(config_name):
    config = {}

    # Get config defaults
    for key in dir(config_defaults):
        if key.isupper():
            config[key] = getattr(config_defaults, key)

    # Merge given config with defaults
    obj = importlib.import_module(config_name)
    for key in dir(obj):
        if key in config:
            value = getattr(obj, key)
            if isinstance(config[key], dict):
                config[key].update(value)
            else:
                config[key] = value

    return config