615#ifndef MYSQL_HARNESS_LOADER_INCLUDED
616#define MYSQL_HARNESS_LOADER_INCLUDED
622#include "mysql/harness/plugin.h"
624#include "harness_export.h"
685 bool running =
false);
694 void set_running()
noexcept;
698 uint32_t milliseconds)
const noexcept;
702 bool exit_ok()
const noexcept;
703 MY_ATTRIBUTE((format(printf, 3, 0)))
705 std::tuple<std::string, std::exception_ptr> pop_error()
noexcept;
712 ErrorType error_type_ = kNoError;
714 mutable std::condition_variable
cond_;
720 void push_back(std::thread &&thr);
724 void try_stopped(std::exception_ptr &first_exc);
727 plugin_stopped_events_.push(std::move(eptr));
732 void wait_all_stopped(std::exception_ptr &first_exc);
757 : config_(config), program_(
std::move(program)) {}
777 std::list<Config::SectionKey> available()
const;
813 return waitable_services_;
822 after_all_started_ = std::move(func);
831 after_first_finished_ = std::move(func);
842 const std::array<std::string_view, N> &
options) {
843 supported_app_options_.clear();
844 for (
const auto &option :
options) {
845 supported_app_options_.emplace_back(std::string(option));
861 std::function<
void(
const bool,
const ConfigSection &)> clb) {
862 expose_app_config_clb_ = clb;
877 void expose_config_all(
const bool initial);
880 enum class Status { UNVISITED, ONGOING, VISITED };
909 const std::string &library_name);
937 std::exception_ptr init_all();
946 std::exception_ptr stop_and_wait_all();
948 std::exception_ptr stop_all();
954 size_t external_plugins_to_load_count();
963 bool visit(
const std::string &
name, std::map<std::string, Status> *seen,
964 std::list<std::string> *order);
973 PluginInfo(
const std::string &folder,
const std::string &libname);
976 void load_plugin_descriptor(
const std::string &
name);
1010 std::map<const ConfigSection *, std::shared_ptr<PluginFuncEnv>>
1035 bool signal_thread_ready_{
false};
1046 void check_config_options_supported();
1055 void check_default_config_options_supported();
1072 friend class ::TestLoader;
Kerberos Client Authentication Plugin
Definition: auth_kerberos_client_plugin.cc:250
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:971
const Plugin * plugin() const
Definition: loader.h:978
DynamicLibrary module_
Definition: loader.h:983
const DynamicLibrary & library() const
Definition: loader.h:980
PluginInfo(const Plugin *const plugin)
Definition: loader.h:974
std::list< std::string > order_
Initialization order.
Definition: loader.h:1021
Stage
Flags progress of Loader.
Definition: loader.h:886
std::string logging_folder_
Definition: loader.h:1023
const std::vector< std::string > & waitable_services() const
service names to wait on.
Definition: loader.h:812
std::vector< std::string > waitable_services_
Definition: loader.h:1060
std::string data_folder_
Definition: loader.h:1027
std::thread signal_thread_
Definition: loader.h:1036
LoaderConfig & config_
Configuration sections for all plugins.
Definition: loader.h:994
LoaderConfig & get_config()
Get reference to configuration object.
Definition: loader.h:796
void after_all_started(std::function< void()> &&func)
set a function that's called after all plugins have been started.
Definition: loader.h:821
std::function< void(const bool, const ConfigSection &)> expose_app_config_clb_
Definition: loader.h:1069
std::function< void()> after_all_started_
Definition: loader.h:1063
std::mutex signal_thread_ready_m_
Definition: loader.h:1033
void register_supported_app_options(const std::array< std::string_view, N > &options)
Register global configuration options supported by the application.
Definition: loader.h:841
std::function< void()> after_first_finished_
Definition: loader.h:1066
Loader & operator=(const Loader &)=delete
std::string config_folder_
Definition: loader.h:1026
std::condition_variable signal_thread_ready_cond_
Definition: loader.h:1034
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:860
Loader(const Loader &)=delete
std::vector< std::string > & waitable_services()
service names to wait on.
Definition: loader.h:805
Loader(std::string program, LoaderConfig &config)
Constructor for Loader.
Definition: loader.h:756
std::map< std::string, PluginInfo > PluginMap
Definition: loader.h:987
std::string program_
Definition: loader.h:1028
void after_first_finished(std::function< void()> &&func)
set a function that's called after the first plugin exited.
Definition: loader.h:830
std::string plugin_folder_
Definition: loader.h:1024
AppInfo appinfo_
Definition: loader.h:1029
std::vector< std::string > supported_app_options_
Definition: loader.h:1038
Status
Definition: loader.h:880
void spawn_signal_handler_thread()
PluginThreads plugin_threads_
active plugin threads.
Definition: loader.h:1016
std::map< const ConfigSection *, std::shared_ptr< PluginFuncEnv > > plugin_start_env_
Map of all {plugin instance -> plugin start() PluginFuncEnv} objects.
Definition: loader.h:1011
PluginMap plugins_
Map of all successfully-loaded plugins (without key name).
Definition: loader.h:999
std::string runtime_folder_
Definition: loader.h:1025
PluginFuncEnv object.
Definition: loader.h:673
std::mutex mutex_
Definition: loader.h:715
const AppInfo * app_info_
Definition: loader.h:708
bool running_
Definition: loader.h:710
const ConfigSection * config_section_
Definition: loader.h:709
std::string error_message_
Definition: loader.h:711
std::condition_variable cond_
Definition: loader.h:714
size_t running() const
Definition: loader.h:730
WaitingMPSCQueue< std::exception_ptr > plugin_stopped_events_
queue of events after plugin's start() function exited.
Definition: loader.h:745
void push_exit_status(std::exception_ptr &&eptr)
Definition: loader.h:726
std::vector< std::thread > threads_
Definition: loader.h:737
provide waiting pop and push operator to thread-safe queues.
Definition: waiting_queue_adaptor.h:39
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
const ConfigSection * get_config_section(const PluginFuncEnv *env) noexcept
Definition: loader.cc:197
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:193
void set_error(PluginFuncEnv *env, ErrorType error_type, const char *fmt,...) noexcept
Definition: loader.cc:213
bool is_running(const PluginFuncEnv *env) noexcept
Definition: loader.cc:203
bool wait_for_stop(const PluginFuncEnv *env, uint32_t milliseconds) noexcept
Definition: loader.cc:205
void clear_running(PluginFuncEnv *env) noexcept
Definition: loader.cc:209
Definition: options.cc:57
Definition: gcs_xcom_synode.h:64
required string key
Definition: replication_asynchronous_connection_failover.proto:60
LEX_CSTRING * plugin_name(st_plugin_int **ref)
Definition: sql_plugin_ref.h:95
case opt name
Definition: sslopt-case.h:29