MXS-2313: Expose only two rank values
The rank can now only be used to define two groups of servers: primary and secondary servers. This limits the exposure and reduces the number of possibilities that can arise from the use of this parameter thus making it more predictable.
This commit is contained in:
parent
6f8bfd7d11
commit
3eef2648e1
@ -19,6 +19,7 @@
|
||||
#include <unordered_map>
|
||||
#include <maxbase/average.hh>
|
||||
#include <maxscale/ssl.hh>
|
||||
#include <maxscale/modinfo.h>
|
||||
|
||||
/**
|
||||
* Server configuration parameters names
|
||||
@ -30,6 +31,12 @@ extern const char CN_PERSISTPOOLMAX[];
|
||||
extern const char CN_PROXY_PROTOCOL[];
|
||||
extern const char CN_RANK[];
|
||||
|
||||
// The enum values for `rank`
|
||||
extern const MXS_ENUM_VALUE rank_values[];
|
||||
|
||||
// Default value for `rank`
|
||||
extern const char* DEFAULT_RANK;
|
||||
|
||||
/**
|
||||
* Status bits in the SERVER->status member, which describes the general state of a server. Although the
|
||||
* individual bits are independent, not all combinations make sense or are used. The bitfield is 64bits wide.
|
||||
|
@ -425,7 +425,8 @@ const MXS_MODULE_PARAM config_server_params[] =
|
||||
{CN_SSL_CERT_VERIFY_DEPTH, MXS_MODULE_PARAM_COUNT, "9"},
|
||||
{CN_SSL_VERIFY_PEER_CERTIFICATE, MXS_MODULE_PARAM_BOOL, "true"},
|
||||
{CN_DISK_SPACE_THRESHOLD, MXS_MODULE_PARAM_STRING},
|
||||
{CN_RANK, MXS_MODULE_PARAM_COUNT, "2147483647"},
|
||||
{CN_RANK, MXS_MODULE_PARAM_ENUM, DEFAULT_RANK,
|
||||
MXS_MODULE_OPT_ENUM_UNIQUE, rank_values},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
|
@ -621,9 +621,11 @@ bool runtime_alter_server(Server* server, const char* key, const char* value)
|
||||
}
|
||||
if (strcmp(key, CN_RANK) == 0)
|
||||
{
|
||||
if (auto i = get_positive_int(value))
|
||||
auto v = config_enum_to_value(value, rank_values);
|
||||
|
||||
if (v != MXS_UNKNOWN_ENUM_VALUE)
|
||||
{
|
||||
server->set_rank(i);
|
||||
server->set_rank(v);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -65,6 +65,15 @@ const char CN_PERSISTPOOLMAX[] = "persistpoolmax";
|
||||
const char CN_PROXY_PROTOCOL[] = "proxy_protocol";
|
||||
const char CN_RANK[] = "rank";
|
||||
|
||||
const MXS_ENUM_VALUE rank_values[] =
|
||||
{
|
||||
{"primary", 1},
|
||||
{"secondary", 2},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
const char* DEFAULT_RANK = "primary";
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
@ -252,7 +261,7 @@ Server* Server::server_alloc(const char* name, MXS_CONFIG_PARAMETER* params)
|
||||
server->persistent = persistent;
|
||||
server->last_event = SERVER_UP_EVENT;
|
||||
server->status = SERVER_RUNNING;
|
||||
server->m_settings.rank = params->get_integer(CN_RANK);
|
||||
server->m_settings.rank = params->get_enum(CN_RANK, rank_values);
|
||||
mxb_assert(server->m_settings.rank > 0);
|
||||
|
||||
if (!monuser.empty())
|
||||
|
Loading…
x
Reference in New Issue
Block a user