Make the instance name available to filters
The section name of a filter in the MaxScale configuration file is unique for each filter. Hence, by providing that name to the filter instance creation function, it is possible to act differently depending on which particular instance is being created. Case in point. There can be multiple cache filters defined in the MaxScale configuration file, each with a different set of rules, ttl and even backing store. Each cache will be backed by a separate storage that e.g. in the case of RocksDB will correspond to a particular path. In other words, for each cache instance corresponding to a particular cache definition in the MaxScale configuration file, we need to be able to create a unique path. If the filter section name (in the MaxScale configuration file) that anyways needs to be unique, is provided to the filter, then that name can be used when forming the unique path. The alternative is to require the DBA to provide some unique parameter for each cache definition, which adds configuration overhead and is errorprone. Furthermore, by providing the name to filters, also error messages can be customized for a particular section when appropriate.
This commit is contained in:
@ -67,7 +67,9 @@ typedef struct
|
||||
*/
|
||||
typedef struct filter_object
|
||||
{
|
||||
FILTER *(*createInstance)(char **options, FILTER_PARAMETER **);
|
||||
FILTER *(*createInstance)(const char *name,
|
||||
char **options,
|
||||
FILTER_PARAMETER **params);
|
||||
void *(*newSession)(FILTER *instance, SESSION *session);
|
||||
void (*closeSession)(FILTER *instance, void *fsession);
|
||||
void (*freeSession)(FILTER *instance, void *fsession);
|
||||
@ -83,7 +85,7 @@ typedef struct filter_object
|
||||
* is changed these values must be updated in line with the rules in the
|
||||
* file modinfo.h.
|
||||
*/
|
||||
#define FILTER_VERSION {1, 1, 0}
|
||||
#define FILTER_VERSION {2, 1, 0}
|
||||
/**
|
||||
* The definition of a filter from the configuration file.
|
||||
* This is basically the link between a plugin to load and the
|
||||
|
Reference in New Issue
Block a user