Kea: reconnect_ctl.cc Source File

| Kea 3.2.0-git

reconnect_ctl.cc
Go to the documentation of this file.
1// Copyright (C) 2022 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#include <config.h>
8#include <util/reconnect_ctl.h>
9#include <exceptions/exceptions.h>
10
11namespace isc {
12namespace util {
13
14std::string
15ReconnectCtl::onFailActionToText(OnFailAction action) {
16 switch (action) {
17 case OnFailAction::STOP_RETRY_EXIT:
18 return ("stop-retry-exit");
19 case OnFailAction::SERVE_RETRY_EXIT:
20 return ("serve-retry-exit");
21 case OnFailAction::SERVE_RETRY_CONTINUE:
22 return ("serve-retry-continue");
23 }
24 return ("invalid-action-type");
25}
26
27 OnFailAction
28ReconnectCtl::onFailActionFromText(const std::string& text) {
29 if (text == "stop-retry-exit") {
30 return (OnFailAction::STOP_RETRY_EXIT);
31 } else if (text == "serve-retry-exit") {
32 return (OnFailAction::SERVE_RETRY_EXIT);
33 } else if (text == "serve-retry-continue") {
34 return (OnFailAction::SERVE_RETRY_CONTINUE);
35 } else {
36 isc_throw(BadValue, "Invalid action on connection loss: " << text);
37 }
38}
39
40}
41}
isc::BadValue
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
Definition exceptions/exceptions.h:132
isc::util::ReconnectCtl::onFailActionToText
static std::string onFailActionToText(OnFailAction action)
Convert action to string.
Definition reconnect_ctl.cc:15
isc::util::ReconnectCtl::onFailActionFromText
static OnFailAction onFailActionFromText(const std::string &text)
Convert string to action.
Definition reconnect_ctl.cc:28
exceptions.h
isc_throw
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
Definition exceptions/exceptions.h:210
isc::util
Definition time_utils.cc:43
isc::util::OnFailAction
OnFailAction
Type of action to take on connection loss.
Definition reconnect_ctl.h:17
isc::util::OnFailAction::SERVE_RETRY_EXIT
@ SERVE_RETRY_EXIT
Definition reconnect_ctl.h:19
isc::util::OnFailAction::SERVE_RETRY_CONTINUE
@ SERVE_RETRY_CONTINUE
Definition reconnect_ctl.h:20
isc::util::OnFailAction::STOP_RETRY_EXIT
@ STOP_RETRY_EXIT
Definition reconnect_ctl.h:18
isc
Defines the logger used by the top-level component of kea-lfc.
Definition check_exists_add.cc:18
reconnect_ctl.h