1%% This Source Code Form is subject to the terms of the Mozilla Public 2%% License, v. 2.0. If a copy of the MPL was not distributed with this 3%% file, You can obtain one at https://mozilla.org/MPL/2.0/. 4%% 5%% Copyright (c) 2007-2021 VMware, Inc. or its affiliates. All rights reserved. 6%% 7 8-module(rabbit_restartable_sup). 9 10-behaviour(supervisor2). 11 12-export([start_link/3]). 13 14-export([init/1]). 15 16-include_lib("rabbit_common/include/rabbit.hrl"). 17 18-define(DELAY, 2). 19 20%%---------------------------------------------------------------------------- 21 22-spec start_link(atom(), rabbit_types:mfargs(), boolean()) -> 23 rabbit_types:ok_pid_or_error(). 24 25start_link(Name, {_M, _F, _A} = Fun, Delay) -> 26 supervisor2:start_link({local, Name}, ?MODULE, [Fun, Delay]). 27 28init([{Mod, _F, _A} = Fun, Delay]) -> 29 {ok, {{one_for_one, 10, 10}, 30 [{Mod, Fun, case Delay of 31 true -> {transient, 1}; 32 false -> transient 33 end, ?WORKER_WAIT, worker, [Mod]}]}}. 34