1
0
mirror of https://github.com/codership/wsrep-lib.git synced 2025-07-21 12:22:06 +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

@ -19,6 +19,7 @@
#include "config_service_v1.hpp"
#include "service_helpers.hpp"
#include "v26/wsrep_api.h"
#include "v26/wsrep_config_service.h"
#include "wsrep/logger.hpp"
#include "wsrep/provider_options.hpp"
@ -150,7 +151,7 @@ static void config_service_v1_deinit(void* dlh)
int wsrep::config_service_v1_fetch(wsrep::provider& provider,
wsrep::provider_options* options)
{
struct wsrep_st* wsrep = (struct wsrep_st*)provider.native();
struct wsrep_st* wsrep = static_cast<struct wsrep_st*>(provider.native());
if (wsrep == nullptr)
{
// Not a provider which was loaded via wsrep-API
@ -179,3 +180,70 @@ int wsrep::config_service_v1_fetch(wsrep::provider& provider,
return 0;
}
namespace wsrep_config_service_v2
{
wsrep_config_service_v2_t service{ 0 };
wsrep_status_t service_callback(const wsrep_parameter* p, void* context)
{
return wsrep_config_service_v1::service_callback(p, context);
}
} // namespace wsrep_config_service_v2
static int config_service_v2_probe(void* dlh)
{
typedef int (*init_fn)(wsrep_config_service_v2_t*);
typedef void (*deinit_fn)();
return wsrep_impl::service_probe<init_fn>(
dlh, WSREP_CONFIG_SERVICE_INIT_FUNC_V2, "config service v2")
|| wsrep_impl::service_probe<deinit_fn>(
dlh, WSREP_CONFIG_SERVICE_DEINIT_FUNC_V2, "config service v2");
}
static int config_service_v2_init(void* dlh)
{
typedef int (*init_fn)(wsrep_config_service_v2_t*);
return wsrep_impl::service_init<init_fn>(
dlh, WSREP_CONFIG_SERVICE_INIT_FUNC_V2,
&wsrep_config_service_v2::service, "config service v2");
}
static void config_service_v2_deinit(void* dlh)
{
typedef int (*deinit_fn)();
wsrep_impl::service_deinit<deinit_fn>(
dlh, WSREP_CONFIG_SERVICE_DEINIT_FUNC_V2, "config service v2");
}
int wsrep::config_service_v2_fetch(struct wsrep_st* wsrep,
wsrep::provider_options* options)
{
if (wsrep == nullptr)
{
// Not a provider which was loaded via wsrep-API
return 0;
}
if (config_service_v2_probe(wsrep->dlh))
{
wsrep::log_info() << "Provider does not support config service v2";
return 1;
}
if (config_service_v2_init(wsrep->dlh))
{
wsrep::log_warning() << "Failed to initialize config service v2";
return 1;
}
wsrep_status_t ret = wsrep_config_service_v2::service.get_parameters(
wsrep, &wsrep_config_service_v2::service_callback, options);
config_service_v2_deinit(wsrep->dlh);
if (ret != WSREP_OK)
{
return 1;
}
return 0;
}