def apply_keepalive_limit(option: str, value: int) -> int:
    """
    Ensures provided *value* for keepalive *option* does not exceed the maximum allowed value for the current platform.

    :param option: The TCP keepalive option name. Possible values are:

            * ``TCP_USER_TIMEOUT``;
            * ``TCP_KEEPIDLE``;
            * ``TCP_KEEPINTVL``;
            * ``TCP_KEEPCNT``.

    :param value: The desired value for the keepalive option.

    :returns: maybe adjusted value.
    """
    max_of_options = {
        'linux': {'TCP_USER_TIMEOUT': 2147483647, 'TCP_KEEPIDLE': 32767, 'TCP_KEEPINTVL': 32767, 'TCP_KEEPCNT': 127},
        'darwin': {'TCP_KEEPIDLE': 4294967, 'TCP_KEEPINTVL': 4294967, 'TCP_KEEPCNT': 2147483647},
    }
    platform = 'linux' if sys.platform.startswith('linux') else sys.platform
    max_possible_value = max_of_options.get(platform, {}).get(option)
    if max_possible_value is not None and value > max_possible_value:
        logger.debug('%s changed from %d to %d.', option, value, max_possible_value)
        value = max_possible_value
    return value

    Ensures provided *value* for keepalive *option* does not exceed the maximum allowed value for the current platform.

    :param option: The TCP keepalive option name. Possible values are:

            * ``TCP_USER_TIMEOUT``;
            * ``TCP_KEEPIDLE``;
            * ``TCP_KEEPINTVL``;
            * ``TCP_KEEPCNT``.

    :param value: The desired value for the keepalive option.

    :returns: maybe adjusted value.
    
patroni/utils.py