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);
760 bool can_run_only_on_builtins =
false);
772 std::list<Config::SectionKey> available()
const;
808 return waitable_services_;
817 after_all_started_ = std::move(func);
826 after_first_finished_ = std::move(func);
837 const std::array<std::string_view, N> &
options) {
838 supported_app_options_.clear();
839 for (
const auto &option :
options) {
840 supported_app_options_.emplace_back(std::string(option));
856 std::function<
void(
const bool,
const ConfigSection &)> clb) {
857 expose_app_config_clb_ = clb;
872 void expose_config_all(
const bool initial);
882 enum class Status { UNVISITED, ONGOING, VISITED };
911 const std::string &library_name);
933 std::exception_ptr init_all();
942 std::exception_ptr stop_and_wait_all();
944 std::exception_ptr stop_all();
950 size_t external_plugins_to_load_count();
959 bool visit(
const std::string &name, std::map<std::string, Status> *seen,
960 std::list<std::string> *order);
969 PluginInfo(
const std::string &folder,
const std::string &libname);
972 void load_plugin_descriptor(
const std::string &name);
1009 std::map<const ConfigSection *, std::shared_ptr<PluginFuncEnv>>
1034 bool signal_thread_ready_{
false};
1045 void check_config_options_supported();
1054 void check_default_config_options_supported();
1073 friend class ::TestLoader;
1076 bool can_run_only_on_builtins_{
false};
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:967
const Plugin * plugin() const
Definition: loader.h:974
DynamicLibrary module_
Definition: loader.h:982
void unload_library()
Definition: loader.h:978
const DynamicLibrary & library() const
Definition: loader.h:976
PluginInfo(const Plugin *const plugin)
Definition: loader.h:970
std::list< std::string > order_
Initialization order.
Definition: loader.h:1020
Stage
Flags progress of Loader.
Definition: loader.h:888
std::string logging_folder_
Definition: loader.h:1022
const std::vector< std::string > & waitable_services() const
service names to wait on.
Definition: loader.h:807
std::vector< std::string > waitable_services_
Definition: loader.h:1061
std::string data_folder_
Definition: loader.h:1026
std::thread signal_thread_
Definition: loader.h:1035
LoaderConfig & config_
Configuration sections for all plugins.
Definition: loader.h:993
LoaderConfig & get_config()
Get reference to configuration object.
Definition: loader.h:791
void after_all_started(std::function< void()> &&func)
set a function that's called after all plugins have been started.
Definition: loader.h:816
std::function< void(const bool, const ConfigSection &)> expose_app_config_clb_
Definition: loader.h:1070
std::function< void()> after_all_started_
Definition: loader.h:1064
std::mutex signal_thread_ready_m_
Definition: loader.h:1032
void register_supported_app_options(const std::array< std::string_view, N > &options)
Register global configuration options supported by the application.
Definition: loader.h:836
std::function< void()> after_first_finished_
Definition: loader.h:1067
Loader & operator=(const Loader &)=delete
std::string config_folder_
Definition: loader.h:1025
std::condition_variable signal_thread_ready_cond_
Definition: loader.h:1033
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:855
Loader(const Loader &)=delete
std::vector< std::string > & waitable_services()
service names to wait on.
Definition: loader.h:800
std::map< std::string, PluginInfo > PluginMap
Definition: loader.h:986
std::string program_
Definition: loader.h:1027
void after_first_finished(std::function< void()> &&func)
set a function that's called after the first plugin exited.
Definition: loader.h:825
std::string plugin_folder_
Definition: loader.h:1023
AppInfo appinfo_
Definition: loader.h:1028
std::vector< std::string > supported_app_options_
Definition: loader.h:1037
std::vector< std::shared_ptr< PluginStateObserver > > default_observers_
Definition: loader.h:1056
Status
Definition: loader.h:882
void spawn_signal_handler_thread()
PluginThreads plugin_threads_
active plugin threads.
Definition: loader.h:1015
std::map< const ConfigSection *, std::shared_ptr< PluginFuncEnv > > plugin_start_env_
Map of all {plugin instance -> plugin start() PluginFuncEnv} objects.
Definition: loader.h:1010
PluginMap plugins_
Map of all successfully-loaded plugins (without key name).
Definition: loader.h:998
std::string runtime_folder_
Definition: loader.h:1024
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:70
Singleton class that stores the application type.
Definition: component_application_type_name.h:31
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