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:
Markus Mäkelä
2018-08-06 02:30:42 +03:00
parent 3a185902b7
commit 56ede5bbf4
3 changed files with 6 additions and 25 deletions

View File

@ -3404,7 +3404,9 @@ int create_new_service(CONFIG_CONTEXT *obj)
if (char* filters = config_get_value(obj->parameters, CN_FILTERS)) 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++; error_count++;
} }

View File

@ -71,7 +71,7 @@ public:
* *
* @return True if filters were all found and were valid * @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 * 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 // Internal search function
Service* service_internal_find(const char *name); 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 * @brief Check if a service uses a server
* @param service Service to check * @param service Service to check

View File

@ -1060,13 +1060,13 @@ int service_enable_root(Service *svc, int action)
return 1; return 1;
} }
bool Service::set_filters(const std::string& filters) bool Service::set_filters(const std::vector<std::string>& filters)
{ {
bool rval = true; bool rval = true;
std::vector<SFilterDef> flist; std::vector<SFilterDef> flist;
uint64_t my_capabilities = 0; uint64_t my_capabilities = 0;
for (auto& f : mxs::strtok(filters, "|")) for (auto f : filters)
{ {
fix_object_name(f); fix_object_name(f);
@ -1137,20 +1137,6 @@ const Service::FilterList& Service::get_filters() const
return *get_local_filters(); 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) Service* service_internal_find(const char *name)
{ {
LockGuard guard(this_unit.lock); 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()); retry_start = config_truth_value(value.c_str());
valid = true; valid = true;
} }
else if (key == CN_FILTERS)
{
valid = set_filters(value);
}
return valid; return valid;
} }