diff options
Diffstat (limited to 'src/lib/util/reconnect_ctl.cc')
-rw-r--r-- | src/lib/util/reconnect_ctl.cc | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/lib/util/reconnect_ctl.cc b/src/lib/util/reconnect_ctl.cc new file mode 100644 index 0000000..265ff2f --- /dev/null +++ b/src/lib/util/reconnect_ctl.cc @@ -0,0 +1,41 @@ +// Copyright (C) 2022 Internet Systems Consortium, Inc. ("ISC") +// +// 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 http://mozilla.org/MPL/2.0/. + +#include <config.h> +#include <util/reconnect_ctl.h> +#include <exceptions/exceptions.h> + +namespace isc { +namespace util { + +std::string +ReconnectCtl::onFailActionToText(OnFailAction action) { + switch (action) { + case OnFailAction::STOP_RETRY_EXIT: + return ("stop-retry-exit"); + case OnFailAction::SERVE_RETRY_EXIT: + return ("serve-retry-exit"); + case OnFailAction::SERVE_RETRY_CONTINUE: + return ("serve-retry-continue"); + } + return ("invalid-action-type"); +} + +OnFailAction +ReconnectCtl::onFailActionFromText(const std::string& text) { + if (text == "stop-retry-exit") { + return (OnFailAction::STOP_RETRY_EXIT); + } else if (text == "serve-retry-exit") { + return (OnFailAction::SERVE_RETRY_EXIT); + } else if (text == "serve-retry-continue") { + return (OnFailAction::SERVE_RETRY_CONTINUE); + } else { + isc_throw(BadValue, "Invalid action on connection loss: " << text); + } +} + +} +} |