%% This Source Code Form is subject to the terms of the Mozilla Public
%% License, v. 2.0. If a copy of the MPL was not distributed with this
%% file, You can obtain one at https://mozilla.org/MPL/2.0/.
%%
%% Copyright (c) 2007-2026 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. All rights reserved.
%%

{mapping, "federation.queues.connection_close_timeout", "rabbitmq_queue_federation.connection_close_timeout", [
    {datatype, integer},
    {validators, ["non_negative_integer", "connection_close_timeout"]}
]}.

{validator, "connection_close_timeout", "timeout must not exceed 5000ms",
fun(Timeout) when is_integer(Timeout) ->
    Timeout =< 5000
end}.

%% Shutdown pacing configuration

{mapping, "federation.queues.shutdown.link_batch_size", "rabbitmq_queue_federation.shutdown_link_batch_size", [
    {datatype, integer},
    {validators, ["non_zero_positive_integer"]}
]}.

{translation, "rabbitmq_queue_federation.shutdown_link_batch_size",
fun(Conf) ->
    case cuttlefish:conf_get("federation.queues.shutdown.link_batch_size", Conf, undefined) of
        undefined -> cuttlefish:unset();
        Value     -> Value
    end
end}.

{mapping, "federation.queues.shutdown.timeout", "rabbitmq_queue_federation.shutdown_timeout", [
    {datatype, integer},
    {validators, ["non_zero_positive_integer"]}
]}.

{translation, "rabbitmq_queue_federation.shutdown_timeout",
fun(Conf) ->
    case cuttlefish:conf_get("federation.queues.shutdown.timeout", Conf, undefined) of
        undefined -> cuttlefish:unset();
        Value     -> Value
    end
end}.

{mapping, "federation.queues.shutdown.throttle_delay", "rabbitmq_queue_federation.shutdown_throttle_delay", [
    {datatype, integer},
    {validators, ["non_negative_integer"]}
]}.

{translation, "rabbitmq_queue_federation.shutdown_throttle_delay",
fun(Conf) ->
    case cuttlefish:conf_get("federation.queues.shutdown.throttle_delay", Conf, undefined) of
        undefined -> cuttlefish:unset();
        Value     -> Value
    end
end}.
