26#ifndef MYSQL_HARNESS_PROCESS_STATE_COMPONENT_INCLUDED
27#define MYSQL_HARNESS_PROCESS_STATE_COMPONENT_INCLUDED
33#include "harness_export.h"
44 enum class Reason { NONE, REQUESTED, FATAL_ERROR };
46 [[nodiscard]] std::string
message()
const {
return message_; }
47 void message(
const std::string &msg) { message_ = msg; }
97 void request_application_shutdown(
99 const std::string &msg = {});
111 on_shutdown_request_callbacks_.push_back(callback);
121 return shutdown_pending_;
Monitor can be waited for.
Definition: monitor.h:62
manages the state of the process.
Definition: process_state_component.h:74
void register_on_shutdown_request_callback(on_shutdown_request_callback callback)
register a callback that will get exectued whenever the component gets the shutdown request
Definition: process_state_component.h:109
std::vector< on_shutdown_request_callback > on_shutdown_request_callbacks_
Definition: process_state_component.h:129
void operator=(ProcessStateComponent &&)=delete
WaitableMonitor< ShutdownPending > & shutdown_pending()
pending shutdown state.
Definition: process_state_component.h:120
ProcessStateComponent(ProcessStateComponent const &)=delete
std::function< void(ShutdownPending::Reason reason, const std::string &msg)> on_shutdown_request_callback
Definition: process_state_component.h:102
ProcessStateComponent()=default
ProcessStateComponent(ProcessStateComponent &&)=delete
void operator=(ProcessStateComponent const &)=delete
std::string key_type
Definition: process_state_component.h:78
Definition: process_state_component.h:39
void message(const std::string &msg)
Definition: process_state_component.h:47
Reason
Reason for shutdown.
Definition: process_state_component.h:44
std::string message_
Definition: process_state_component.h:54
std::string message() const
Definition: process_state_component.h:46
void reason(Reason r)
Definition: process_state_component.h:50
Reason reason() const
Definition: process_state_component.h:49
@ NONE
Definition: base.h:45
std::string HARNESS_EXPORT to_string(const ShutdownPending::Reason &reason)
Definition: process_state_component.cc:60
const mysql_service_registry_t * r
Definition: pfs_example_plugin_employee.cc:86