1
0
mirror of https://github.com/codership/wsrep-lib.git synced 2025-07-02 05:22:26 +03:00

Introduce set_provider_factory() method for server_state

This allows injecting an application allocated provider into
server_state.

After this virtual provider getter is unnecessary. Made the getter
normal method and fixed unit tests accordingly.
This commit is contained in:
Denis Protivensky
2021-12-14 20:28:56 +03:00
committed by Teemu Ollakka
parent 940ba9bd0e
commit 6df17812d9
11 changed files with 302 additions and 308 deletions

View File

@ -92,7 +92,9 @@
#include "compiler.hpp"
#include "xid.hpp"
#include <memory>
#include <deque>
#include <functional>
#include <vector>
#include <string>
#include <map>
@ -188,8 +190,6 @@ namespace wsrep
rm_sync
};
virtual ~server_state();
wsrep::encryption_service* encryption_service()
{ return encryption_service_; }
@ -299,6 +299,17 @@ namespace wsrep
const wsrep::provider::services& services
= wsrep::provider::services());
using provider_factory_func =
std::function<decltype(wsrep::provider::make_provider)>;
/**
* Set provider factory method.
*
* @param Factory method to create a provider.
*/
void set_provider_factory(const provider_factory_func&);
/** Unload/unset provider. */
void unload_provider();
bool is_provider_loaded() const { return provider_ != 0; }
@ -310,12 +321,8 @@ namespace wsrep
*
* @throw wsrep::runtime_error if provider has not been loaded
*
* @todo This should not be virtual. However, currently there
* is no mechanism for tests and integrations to provide
* their own provider implementations, so this is kept virtual
* for time being.
*/
virtual wsrep::provider& provider() const
wsrep::provider& provider() const
{
if (provider_ == 0)
{
@ -623,6 +630,7 @@ namespace wsrep
, streaming_appliers_()
, streaming_appliers_recovered_()
, provider_()
, provider_factory_(wsrep::provider::make_provider)
, name_(name)
, id_(wsrep::id::undefined())
, incoming_address_(incoming_address)
@ -704,7 +712,8 @@ namespace wsrep
wsrep::high_priority_service*> streaming_appliers_map;
streaming_appliers_map streaming_appliers_;
bool streaming_appliers_recovered_;
wsrep::provider* provider_;
std::unique_ptr<wsrep::provider> provider_;
provider_factory_func provider_factory_;
std::string name_;
wsrep::id id_;
std::string incoming_address_;