1
0
mirror of https://github.com/codership/wsrep-lib.git synced 2025-07-27 09:01:50 +03:00

Pass callback to get provider options to provider_v26 constructor

Passing a callback allows constructing the options string using
config service after loading the provider but before initializing
the provider. This way it is possible get options which are given
at DBMS startup, in command line or config file.
This commit is contained in:
Daniele Sciascia
2025-02-19 13:31:52 +02:00
parent 2dc8339ff1
commit 3965d83968
12 changed files with 195 additions and 56 deletions

View File

@ -117,6 +117,7 @@ namespace wsrep
class server_service;
class client_service;
class encryption_service;
class provider_options;
/** @class Server Context
*
@ -287,17 +288,47 @@ namespace wsrep
* Load WSRep provider.
*
* @param provider WSRep provider library to be loaded.
* @param provider_options Provider specific options string
* to be passed for provider during initialization.
* @param provider_options_cb Callback to get provider options.
* The function to be called must be
* idempotent.
* @param services Application defined services passed to
* the provider.
*
* @return Zero on success, non-zero on error.
*/
int load_provider(
const std::string& provider,
const std::function<int(const provider_options&, std::string&)>&
provider_options_cb,
const wsrep::provider::services& services
= wsrep::provider::services());
/**
* Load WSRep provider.
*
* @param provider WSRep provider library to be loaded.
* @param options Provider specific options string
* to be passed for provider during initialization.
* @param services Application defined services passed to
* the provider.
*
* @return Zero on success, non-zero on error.
*
* @note Provided for backward compatibility.
*/
int load_provider(const std::string& provider,
const std::string& provider_options,
const std::string& options,
const wsrep::provider::services& services
= wsrep::provider::services());
= wsrep::provider::services())
{
return load_provider(
provider,
[options](const provider_options&, std::string& option_string) {
option_string.append(options);
return 0;
},
services);
}
using provider_factory_func =
std::function<decltype(wsrep::provider::make_provider)>;