summaryrefslogtreecommitdiffstats
path: root/src/lib/util/reconnect_ctl.cc
blob: 265ff2f9fc8eba24a3e275787b9a571f08351159 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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);
    }
}

}
}