614#ifndef MYSQL_HARNESS_LOADER_INCLUDED
615#define MYSQL_HARNESS_LOADER_INCLUDED
621#include "mysql/harness/plugin.h"
623#include "harness_export.h"
684 bool running =
false);
693 void set_running()
noexcept;
697 uint32_t milliseconds)
const noexcept;
701 bool exit_ok()
const noexcept;
702 MY_ATTRIBUTE((format(printf, 3, 0)))
704 std::tuple<std::string, std::exception_ptr> pop_error()
noexcept;
711 ErrorType error_type_ = kNoError;
713 mutable std::condition_variable
cond_;
719 void push_back(std::thread &&thr);
723 void try_stopped(std::exception_ptr &first_exc);
726 plugin_stopped_events_.push(std::move(eptr));
731 void wait_all_stopped(std::exception_ptr &first_exc);
756 : config_(config), program_(
std::move(program)) {}
776 std::list<Config::SectionKey> available()
const;
812 return waitable_services_;
821 after_all_started_ = std::move(func);
830 after_first_finished_ = std::move(func);
841 const std::array<std::string_view, N> &
options) {
842 supported_app_options_.clear();
843 for (
const auto &option :
options) {
844 supported_app_options_.emplace_back(std::string(option));
849 enum class Status { UNVISITED, ONGOING, VISITED };
878 const std::string &library_name);
907 std::exception_ptr init_all();
916 std::exception_ptr stop_and_wait_all();
918 std::exception_ptr stop_all();
924 size_t external_plugins_to_load_count();
933 bool visit(
const std::string &
name, std::map<std::string, Status> *seen,
934 std::list<std::string> *order);
943 PluginInfo(
const std::string &folder,
const std::string &libname);
946 void load_plugin_descriptor(
const std::string &
name);
980 std::map<const ConfigSection *, std::shared_ptr<PluginFuncEnv>>
1005 bool signal_thread_ready_{
false};
1016 void check_config_options_supported();
1025 void check_default_config_options_supported();
1039 friend class ::TestLoader;
Kerberos Client Authentication Plugin
Definition: auth_kerberos_client_plugin.cc:249
A helper class for handling file paths.
Definition: path.h:37
Configuration section.
Definition: config_parser.h:140
A DynamicLibrary.
Definition: dynamic_loader.h:72
Configuration file handler for the loader.
Definition: loader_config.h:45
Holds plugin's API call information.
Definition: loader.h:941
const Plugin * plugin() const
Definition: loader.h:948
DynamicLibrary module_
Definition: loader.h:953
const DynamicLibrary & library() const
Definition: loader.h:950
PluginInfo(const Plugin *const plugin)
Definition: loader.h:944
std::list< std::string > order_
Initialization order.
Definition: loader.h:991
Stage
Flags progress of Loader.
Definition: loader.h:855
std::string logging_folder_
Definition: loader.h:993
const std::vector< std::string > & waitable_services() const
service names to wait on.
Definition: loader.h:811
std::vector< std::string > waitable_services_
Definition: loader.h:1030
std::string data_folder_
Definition: loader.h:997
std::thread signal_thread_
Definition: loader.h:1006
LoaderConfig & config_
Configuration sections for all plugins.
Definition: loader.h:964
LoaderConfig & get_config()
Get reference to configuration object.
Definition: loader.h:795
void after_all_started(std::function< void()> &&func)
set a function that's called after all plugins have been started.
Definition: loader.h:820
std::function< void()> after_all_started_
Definition: loader.h:1033
std::mutex signal_thread_ready_m_
Definition: loader.h:1003
void register_supported_app_options(const std::array< std::string_view, N > &options)
Register global configuration options supported by the application.
Definition: loader.h:840
std::function< void()> after_first_finished_
Definition: loader.h:1036
Loader & operator=(const Loader &)=delete
std::string config_folder_
Definition: loader.h:996
std::condition_variable signal_thread_ready_cond_
Definition: loader.h:1004
Loader(const Loader &)=delete
std::vector< std::string > & waitable_services()
service names to wait on.
Definition: loader.h:804
Loader(std::string program, LoaderConfig &config)
Constructor for Loader.
Definition: loader.h:755
std::map< std::string, PluginInfo > PluginMap
Definition: loader.h:957
std::string program_
Definition: loader.h:998
void after_first_finished(std::function< void()> &&func)
set a function that's called after the first plugin exited.
Definition: loader.h:829
std::string plugin_folder_
Definition: loader.h:994
AppInfo appinfo_
Definition: loader.h:999
std::vector< std::string > supported_app_options_
Definition: loader.h:1008
Status
Definition: loader.h:849
void spawn_signal_handler_thread()
PluginThreads plugin_threads_
active plugin threads.
Definition: loader.h:986
std::map< const ConfigSection *, std::shared_ptr< PluginFuncEnv > > plugin_start_env_
Map of all {plugin instance -> plugin start() PluginFuncEnv} objects.
Definition: loader.h:981
PluginMap plugins_
Map of all successfully-loaded plugins (without key name).
Definition: loader.h:969
std::string runtime_folder_
Definition: loader.h:995
PluginFuncEnv object.
Definition: loader.h:672
std::mutex mutex_
Definition: loader.h:714
const AppInfo * app_info_
Definition: loader.h:707
bool running_
Definition: loader.h:709
const ConfigSection * config_section_
Definition: loader.h:708
std::string error_message_
Definition: loader.h:710
std::condition_variable cond_
Definition: loader.h:713
size_t running() const
Definition: loader.h:729
WaitingMPSCQueue< std::exception_ptr > plugin_stopped_events_
queue of events after plugin's start() function exited.
Definition: loader.h:744
void push_exit_status(std::exception_ptr &&eptr)
Definition: loader.h:725
std::vector< std::thread > threads_
Definition: loader.h:736
provide waiting pop and push operator to thread-safe queues.
Definition: waiting_queue_adaptor.h:38
error_type
Definition: error.h:35
static void start(mysql_harness::PluginFuncEnv *env)
Definition: http_auth_backend_plugin.cc:176
static void run(mysql_harness::PluginFuncEnv *)
Definition: io_plugin.cc:194
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:307
const ConfigSection * get_config_section(const PluginFuncEnv *env) noexcept
Definition: loader.cc:195
const AppInfo * get_app_info(const PluginFuncEnv *env) noexcept
Definition: loader.cc:191
void set_error(PluginFuncEnv *env, ErrorType error_type, const char *fmt,...) noexcept
Definition: loader.cc:211
std::string join(Container cont, const std::string &delim)
join elements of an container into a string separated by a delimiter.
Definition: string.h:150
bool is_running(const PluginFuncEnv *env) noexcept
Definition: loader.cc:201
bool wait_for_stop(const PluginFuncEnv *env, uint32_t milliseconds) noexcept
Definition: loader.cc:203
void clear_running(PluginFuncEnv *env) noexcept
Definition: loader.cc:207
Definition: options.cc:56
Definition: varlen_sort.h:183
required string key
Definition: replication_asynchronous_connection_failover.proto:59
LEX_CSTRING * plugin_name(st_plugin_int **ref)
Definition: sql_plugin_ref.h:94
case opt name
Definition: sslopt-case.h:32