(primary_config: PlProxyConfig)
return PlProxyConfig.from_dict(standby_db_config)
Create plproxy config for querying standbys. This assumes that the main plproxy DB
    will be the same as the primary DB.

    This does not support multiple standby databases per primary.

    :returns: PlProxyConfig object with details of all the standby databases
              or None if no standby databases are configured

    :raises: PartitionValidationError if a partial set of standby databases could be found.
Create plproxy config for querying standbys. This assumes that the main plproxy DB
    will be the same as the primary DB.
Create plproxy config for querying standbys . This assumes that the main plproxy DB will be the same as the primary DB .
def _get_standby_plproxy_config(primary_config: PlProxyConfig) -> Optional[PlProxyConfig]:
    """
    Create plproxy config for querying standbys. This assumes that the main plproxy DB
    will be the same as the primary DB.

    This does not support multiple standby databases per primary.

    :returns: PlProxyConfig object with details of all the standby databases
              or None if no standby databases are configured

    :raises: PartitionValidationError if a partial set of standby databases could be found.
    """

    proxy_for_standbys = None
    for db_alias, config in settings.DATABASES.items():
        if config.get('PLPROXY', {}).get('PROXY_FOR_STANDBYS'):
            proxy_for_standbys = db_alias
            break

    if not proxy_for_standbys:
        return

    standbys_by_primary = {
        config['STANDBY']['MASTER']: db
        for db, config in settings.DATABASES.items()
        if config.get('STANDBY', {}).get('MASTER')
    }

    proxy_config = copy.deepcopy(settings.DATABASES[proxy_for_standbys])
    proxy_config['PLPROXY']['PROXY'] = True
    standby_db_config = {
        proxy_for_standbys: proxy_config
    }

    def _convert_primary_config(primary_db):
        standby = standbys_by_primary.get(primary_db)
        if standby:
            config = copy.deepcopy(settings.DATABASES[standby])
            if 'PLPROXY' in config:
                raise PartitionValidationError('Standby databases should not have PLPROXY configuration')
            config['PLPROXY'] = {
                'SHARDS': primary_config.shard_map[primary_db]
            }

            standby_db_config[standby] = config
            return True

    standbys_found = [
        _convert_primary_config(db)
        for db in primary_config.form_processing_dbs
    ]

    if not all(standbys_found):
        missing = [db for found, db in zip(standbys_found, primary_config.form_processing_dbs) if not found]
        raise PartitionValidationError(f'Not all shard DBs have standbys configured {missing}')

    return PlProxyConfig.from_dict(standby_db_config)
def _get_standby_plproxy_config ( primary_config : PlProxyConfig ) -> Optional [ PlProxyConfig ] : proxy_for_standbys = None for db_alias , config in settings . DATABASES . items ( ) : if config . get ( 'PLPROXY' , { } ) . get ( 'PROXY_FOR_STANDBYS' ) : proxy_for_standbys = db_alias break if not proxy_for_standbys : return standbys_by_primary = { config [ 'STANDBY' ] [ 'MASTER' ] : db for db , config in settings . DATABASES . items ( ) if config . get ( 'STANDBY' , { } ) . get ( 'MASTER' ) } proxy_config = copy . deepcopy ( settings . DATABASES [ proxy_for_standbys ] ) proxy_config [ 'PLPROXY' ] [ 'PROXY' ] = True standby_db_config = { proxy_for_standbys : proxy_config } def _convert_primary_config ( primary_db ) : standby = standbys_by_primary . get ( primary_db ) if standby : config = copy . deepcopy ( settings . DATABASES [ standby ] ) if 'PLPROXY' in config : raise PartitionValidationError ( 'Standby databases should not have PLPROXY configuration' ) config [ 'PLPROXY' ] = { 'SHARDS' : primary_config . shard_map [ primary_db ] } standby_db_config [ standby ] = config return True standbys_found = [ _convert_primary_config ( db ) for db in primary_config . form_processing_dbs ] if not all ( standbys_found ) : missing = [ db for found , db in zip ( standbys_found , primary_config . form_processing_dbs ) if not found ] raise PartitionValidationError ( f'Not all shard DBs have standbys configured {missing}' ) return PlProxyConfig . from_dict ( standby_db_config )