615#ifndef MYSQL_HARNESS_LOADER_INCLUDED
616#define MYSQL_HARNESS_LOADER_INCLUDED
622#include "mysql/harness/plugin.h"
625#include "harness_export.h"
687 bool running =
false);
696 void set_running()
noexcept;
704 bool exit_ok()
const noexcept;
705 MY_ATTRIBUTE((
format(printf, 3, 0)))
707 std::tuple<std::string, std::exception_ptr> pop_error()
noexcept;
714 ErrorType error_type_ = kNoError;
716 mutable std::condition_variable
cond_;
722 void push_back(std::thread &&thr);
726 void try_stopped(std::exception_ptr &first_exc);
729 plugin_stopped_events_.push(std::move(eptr));
734 void wait_all_stopped(std::exception_ptr &first_exc);
770 std::list<Config::SectionKey> available()
const;
806 return waitable_services_;
815 after_all_started_ = std::move(func);
824 after_first_finished_ = std::move(func);
835 const std::array<std::string_view, N> &
options) {
836 supported_app_options_.clear();
837 for (
const auto &option :
options) {
838 supported_app_options_.emplace_back(std::string(option));
854 std::function<
void(
const bool,
const ConfigSection &)> clb) {
855 expose_app_config_clb_ = clb;
870 void expose_config_all(
const bool initial);
873 enum class Status { UNVISITED, ONGOING, VISITED };
902 const std::string &library_name);
930 std::exception_ptr init_all();
939 std::exception_ptr stop_and_wait_all();
941 std::exception_ptr stop_all();
947 size_t external_plugins_to_load_count();
956 bool visit(
const std::string &name, std::map<std::string, Status> *seen,
957 std::list<std::string> *order);
966 PluginInfo(
const std::string &folder,
const std::string &libname);
969 void load_plugin_descriptor(
const std::string &name);
1003 std::map<const ConfigSection *, std::shared_ptr<PluginFuncEnv>>
1028 bool signal_thread_ready_{
false};
1039 void check_config_options_supported();
1048 void check_default_config_options_supported();
1067 friend class ::TestLoader;
Kerberos Client Authentication Plugin
Definition: auth_kerberos_client_plugin.cc:246
A helper class for handling file paths.
Definition: path.h:38
Configuration section.
Definition: config_parser.h:141
A DynamicLibrary.
Definition: dynamic_loader.h:73
Configuration file handler for the loader.
Definition: loader_config.h:46
Holds plugin's API call information.
Definition: loader.h:964
const Plugin * plugin() const
Definition: loader.h:971
DynamicLibrary module_
Definition: loader.h:976
const DynamicLibrary & library() const
Definition: loader.h:973
PluginInfo(const Plugin *const plugin)
Definition: loader.h:967
std::list< std::string > order_
Initialization order.
Definition: loader.h:1014
Stage
Flags progress of Loader.
Definition: loader.h:879
std::string logging_folder_
Definition: loader.h:1016
const std::vector< std::string > & waitable_services() const
service names to wait on.
Definition: loader.h:805
std::vector< std::string > waitable_services_
Definition: loader.h:1055
std::string data_folder_
Definition: loader.h:1020
std::thread signal_thread_
Definition: loader.h:1029
LoaderConfig & config_
Configuration sections for all plugins.
Definition: loader.h:987
LoaderConfig & get_config()
Get reference to configuration object.
Definition: loader.h:789
void after_all_started(std::function< void()> &&func)
set a function that's called after all plugins have been started.
Definition: loader.h:814
std::function< void(const bool, const ConfigSection &)> expose_app_config_clb_
Definition: loader.h:1064
std::function< void()> after_all_started_
Definition: loader.h:1058
std::mutex signal_thread_ready_m_
Definition: loader.h:1026
void register_supported_app_options(const std::array< std::string_view, N > &options)
Register global configuration options supported by the application.
Definition: loader.h:834
std::function< void()> after_first_finished_
Definition: loader.h:1061
Loader & operator=(const Loader &)=delete
std::string config_folder_
Definition: loader.h:1019
std::condition_variable signal_thread_ready_cond_
Definition: loader.h:1027
void register_expose_app_config_callback(std::function< void(const bool, const ConfigSection &)> clb)
Register a callback that the Loader will call when exposing of the whole configuration is requested.
Definition: loader.h:853
Loader(const Loader &)=delete
std::vector< std::string > & waitable_services()
service names to wait on.
Definition: loader.h:798
std::map< std::string, PluginInfo > PluginMap
Definition: loader.h:980
std::string program_
Definition: loader.h:1021
void after_first_finished(std::function< void()> &&func)
set a function that's called after the first plugin exited.
Definition: loader.h:823
std::string plugin_folder_
Definition: loader.h:1017
AppInfo appinfo_
Definition: loader.h:1022
std::vector< std::string > supported_app_options_
Definition: loader.h:1031
std::vector< std::shared_ptr< PluginStateObserver > > default_observers_
Definition: loader.h:1050
Status
Definition: loader.h:873
void spawn_signal_handler_thread()
PluginThreads plugin_threads_
active plugin threads.
Definition: loader.h:1009
std::map< const ConfigSection *, std::shared_ptr< PluginFuncEnv > > plugin_start_env_
Map of all {plugin instance -> plugin start() PluginFuncEnv} objects.
Definition: loader.h:1004
PluginMap plugins_
Map of all successfully-loaded plugins (without key name).
Definition: loader.h:992
std::string runtime_folder_
Definition: loader.h:1018
PluginFuncEnv object.
Definition: loader.h:675
std::mutex mutex_
Definition: loader.h:717
const AppInfo * app_info_
Definition: loader.h:710
bool running_
Definition: loader.h:712
const ConfigSection * config_section_
Definition: loader.h:711
std::string error_message_
Definition: loader.h:713
std::condition_variable cond_
Definition: loader.h:716
size_t running() const
Definition: loader.h:732
WaitingMPSCQueue< std::exception_ptr > plugin_stopped_events_
queue of events after plugin's start() function exited.
Definition: loader.h:747
void push_exit_status(std::exception_ptr &&eptr)
Definition: loader.h:728
std::vector< std::thread > threads_
Definition: loader.h:739
provide waiting pop and push operator to thread-safe queues.
Definition: waiting_queue_adaptor.h:40
error_type
Definition: error.h:36
static void start(mysql_harness::PluginFuncEnv *env)
Definition: http_auth_backend_plugin.cc:180
static void run(mysql_harness::PluginFuncEnv *)
Definition: io_plugin.cc:199
Header for compiler-dependent features.
bool load(THD *, const dd::String_type &fname, dd::String_type *buf)
Read an sdi file from disk and store in a buffer.
Definition: sdi_file.cc:308
std::chrono::milliseconds milliseconds
Definition: authorize_manager.cc:68
const ConfigSection * get_config_section(const PluginFuncEnv *env) noexcept
Definition: loader.cc:237
std::string join(const detail::range auto &rng, std::string_view delim)
join elements of a range into a string separated by a delimiter.
Definition: string.h:74
const AppInfo * get_app_info(const PluginFuncEnv *env) noexcept
Definition: loader.cc:233
void set_error(PluginFuncEnv *env, ErrorType error_type, const char *fmt,...) noexcept
Definition: loader.cc:253
bool is_running(const PluginFuncEnv *env) noexcept
Definition: loader.cc:243
bool wait_for_stop(const PluginFuncEnv *env, uint32_t milliseconds) noexcept
Definition: loader.cc:245
void clear_running(PluginFuncEnv *env) noexcept
Definition: loader.cc:249
Definition: options.cc:57
required string key
Definition: replication_asynchronous_connection_failover.proto:60
LEX_CSTRING * plugin_name(st_plugin_int **ref)
Definition: sql_plugin_ref.h:95