def parse_conninfo(value: str, fallback: Callable[[str], Optional[Dict[str, str]]]) -> Optional[Dict[str, str]]:
    """Parse connection string.

    :param value: value to parse.
    :param fallback: a function to use if we have only very old ``psycopg2``, which doesn't expose :func:`parse_dsn`.

    :returns: a :class:`dict` object, or ``None`` if failed to parse.
    """
    try:
        ret = _parse_conninfo(value)
    except Exception:
        ret = None
    return ret or fallback(value)
Parse connection string.

    :param value: value to parse.
    :param fallback: a function to use if we have only very old ``psycopg2``, which doesn't expose :func:`parse_dsn`.

    :returns: a :class:`dict` object, or ``None`` if failed to parse.
    
patroni/psycopg.py