MySQL 26.10.0
Source Code Documentation
tls_reload_component.h
Go to the documentation of this file.
1/*
2Copyright (c) 2026, Oracle and/or its affiliates.
3
4This program is free software; you can redistribute it and/or modify
5it under the terms of the GNU General Public License, version 2.0,
6as published by the Free Software Foundation.
7
8This program is designed to work with certain software (including
9but not limited to OpenSSL) that is licensed under separate terms,
10as designated in a particular file or component or in included license
11documentation. The authors of MySQL hereby grant you an additional
12permission to link the program and your derivative works with the
13separately licensed software that they have either included with
14the program or referenced in the documentation.
15
16This program is distributed in the hope that it will be useful,
17but WITHOUT ANY WARRANTY; without even the implied warranty of
18MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19GNU General Public License for more details.
20
21You should have received a copy of the GNU General Public License
22along with this program; if not, write to the Free Software
23Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24*/
25
26#ifndef MYSQL_HARNESS_TLS_RELOAD_COMPONENT_INCLUDED
27#define MYSQL_HARNESS_TLS_RELOAD_COMPONENT_INCLUDED
28
29#include <cstddef>
30#include <functional>
31#include <memory>
32#include <mutex>
33#include <string>
34
35#include "harness_export.h"
37
38namespace mysql_harness {
39
40/** Coordinates asynchronous reloads of TLS material owned by Router plugins. */
41class HARNESS_EXPORT TlsReloadComponent {
42 public:
44
45 using Callback = std::function<Result()>;
46 using RegistrationId = std::size_t;
47 static constexpr RegistrationId kInvalidRegistrationId{0};
48
49 static TlsReloadComponent &get_instance();
50
53
54 /** Starts the worker. */
55 void init();
56 /** Stops and joins the worker before plugin TLS state is destroyed. */
57 void stop();
58
59 RegistrationId register_callback(std::string owner, Callback callback);
60 void unregister_callback(RegistrationId id);
61
62 /** Queues a reload without performing TLS I/O in the caller's context. */
63 void request_reload();
64
65 private:
68
69 class Impl;
70 std::mutex impl_mtx_;
71 std::shared_ptr<Impl> impl_;
72 RegistrationId next_id_{kInvalidRegistrationId + 1};
73};
74
75} // namespace mysql_harness
76
77#endif // MYSQL_HARNESS_TLS_RELOAD_COMPONENT_INCLUDED
static mysql_service_status_t init()
Component initialization.
Definition: audit_api_message_emit.cc:575
Class that stores callback function reference as well as the result of the callback function call (in...
Definition: keyring_service.cc:44
Definition: tls_reload_component.cc:42
Coordinates asynchronous reloads of TLS material owned by Router plugins.
Definition: tls_reload_component.h:41
TlsReloadComponent(const TlsReloadComponent &)=delete
std::size_t RegistrationId
Definition: tls_reload_component.h:46
TlsReloadComponent & operator=(const TlsReloadComponent &)=delete
std::mutex impl_mtx_
Definition: tls_reload_component.h:69
std::shared_ptr< Impl > impl_
Definition: tls_reload_component.h:71
Definition: expected.h:286
static void stop(mysql_harness::PluginFuncEnv *)
Definition: mysql_rest_service_plugin.cc:413
Singleton class that stores the application type.
Definition: component_application_type_name.h:31
Result
Definition: result.h:34