MXS-1929: Remove string parsing from Service
As the filters are only passed as a pipe separated list when the configuration is being processed, there's no need to have the interface conform to that. Passing a list of filter names makes it more flexible and will make it's use in the runtime configuration easier.
This commit is contained in:
parent
3a185902b7
commit
56ede5bbf4
@ -3404,7 +3404,9 @@ int create_new_service(CONFIG_CONTEXT *obj)
|
||||
|
||||
if (char* filters = config_get_value(obj->parameters, CN_FILTERS))
|
||||
{
|
||||
if (!service_set_filters(service, filters))
|
||||
auto flist = mxs::strtok(filters, "|");
|
||||
|
||||
if (!service->set_filters(flist))
|
||||
{
|
||||
error_count++;
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ public:
|
||||
*
|
||||
* @return True if filters were all found and were valid
|
||||
*/
|
||||
bool set_filters(const std::string& filters);
|
||||
bool set_filters(const std::vector<std::string>& filters);
|
||||
|
||||
/**
|
||||
* Get the list of filters this service uses
|
||||
@ -311,9 +311,6 @@ void service_replace_parameter(Service *service, const char* key, const char* va
|
||||
// Internal search function
|
||||
Service* service_internal_find(const char *name);
|
||||
|
||||
// Assign filters to service
|
||||
bool service_set_filters(Service *service, const char* filters);
|
||||
|
||||
/**
|
||||
* @brief Check if a service uses a server
|
||||
* @param service Service to check
|
||||
|
@ -1060,13 +1060,13 @@ int service_enable_root(Service *svc, int action)
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool Service::set_filters(const std::string& filters)
|
||||
bool Service::set_filters(const std::vector<std::string>& filters)
|
||||
{
|
||||
bool rval = true;
|
||||
std::vector<SFilterDef> flist;
|
||||
uint64_t my_capabilities = 0;
|
||||
|
||||
for (auto& f : mxs::strtok(filters, "|"))
|
||||
for (auto f : filters)
|
||||
{
|
||||
fix_object_name(f);
|
||||
|
||||
@ -1137,20 +1137,6 @@ const Service::FilterList& Service::get_filters() const
|
||||
return *get_local_filters();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the filters used by the service
|
||||
*
|
||||
* @param service The service itself
|
||||
* @param filters The filters to use separated by the pipe character |
|
||||
*
|
||||
* @return True if loading and creating all filters was successful. False if a
|
||||
* filter module was not found or the instance creation failed.
|
||||
*/
|
||||
bool service_set_filters(Service* service, const char* filters)
|
||||
{
|
||||
return service->set_filters(filters);
|
||||
}
|
||||
|
||||
Service* service_internal_find(const char *name)
|
||||
{
|
||||
LockGuard guard(this_unit.lock);
|
||||
@ -2454,10 +2440,6 @@ bool Service::update_basic_parameter(const std::string& key, const std::string&
|
||||
retry_start = config_truth_value(value.c_str());
|
||||
valid = true;
|
||||
}
|
||||
else if (key == CN_FILTERS)
|
||||
{
|
||||
valid = set_filters(value);
|
||||
}
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user