|
|
|
|
@ -3,78 +3,77 @@
|
|
|
|
|
|
|
|
|
|
#include <cstdint>
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
enum ProxySQL_PluginDBKind {
|
|
|
|
|
admin_db,
|
|
|
|
|
config_db,
|
|
|
|
|
stats_db,
|
|
|
|
|
class SQLite3DB;
|
|
|
|
|
class SQLite3_result;
|
|
|
|
|
|
|
|
|
|
enum class ProxySQL_PluginDBKind : uint8_t {
|
|
|
|
|
admin_db = 0,
|
|
|
|
|
config_db = 1,
|
|
|
|
|
stats_db = 2
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct ProxySQL_PluginTableDef {
|
|
|
|
|
ProxySQL_PluginDBKind db_kind{admin_db};
|
|
|
|
|
const char *schema_name{nullptr};
|
|
|
|
|
const char *table_name{nullptr};
|
|
|
|
|
const char *create_statement{nullptr};
|
|
|
|
|
ProxySQL_PluginDBKind db_kind;
|
|
|
|
|
const char *table_name;
|
|
|
|
|
const char *table_def;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct ProxySQL_PluginCommandContext {
|
|
|
|
|
const char *command_name{nullptr};
|
|
|
|
|
std::vector<std::string> arguments;
|
|
|
|
|
SQLite3DB *admindb;
|
|
|
|
|
SQLite3DB *configdb;
|
|
|
|
|
SQLite3DB *statsdb;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct ProxySQL_PluginCommandResult {
|
|
|
|
|
bool success{true};
|
|
|
|
|
int error_code;
|
|
|
|
|
uint64_t rows_affected;
|
|
|
|
|
std::string message;
|
|
|
|
|
std::vector<std::vector<std::string>> rows;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class ProxySQL_PluginServices;
|
|
|
|
|
|
|
|
|
|
using proxysql_plugin_admin_command_cb =
|
|
|
|
|
bool (*)(const ProxySQL_PluginCommandContext &, ProxySQL_PluginCommandResult &, void *);
|
|
|
|
|
ProxySQL_PluginCommandResult (*)(const ProxySQL_PluginCommandContext &, const char *);
|
|
|
|
|
|
|
|
|
|
using proxysql_plugin_register_table_cb =
|
|
|
|
|
bool (*)(void *, const ProxySQL_PluginTableDef &);
|
|
|
|
|
void (*)(const ProxySQL_PluginTableDef &);
|
|
|
|
|
|
|
|
|
|
using proxysql_plugin_register_command_cb =
|
|
|
|
|
bool (*)(void *, const char *, proxysql_plugin_admin_command_cb, void *);
|
|
|
|
|
void (*)(const char *, proxysql_plugin_admin_command_cb);
|
|
|
|
|
|
|
|
|
|
using proxysql_plugin_snapshot_cb =
|
|
|
|
|
bool (*)(void *, std::vector<std::vector<std::string>> &);
|
|
|
|
|
SQLite3_result *(*)();
|
|
|
|
|
|
|
|
|
|
using proxysql_plugin_log_message_cb =
|
|
|
|
|
void (*)(void *, int, const char *);
|
|
|
|
|
void (*)(int, const char *);
|
|
|
|
|
|
|
|
|
|
struct ProxySQL_PluginServices {
|
|
|
|
|
proxysql_plugin_register_table_cb register_table{nullptr};
|
|
|
|
|
proxysql_plugin_register_command_cb register_command{nullptr};
|
|
|
|
|
proxysql_plugin_snapshot_cb get_mysql_users_snapshot{nullptr};
|
|
|
|
|
proxysql_plugin_snapshot_cb get_mysql_servers_snapshot{nullptr};
|
|
|
|
|
proxysql_plugin_snapshot_cb get_mysql_group_replication_hostgroups_snapshot{nullptr};
|
|
|
|
|
proxysql_plugin_log_message_cb log_message{nullptr};
|
|
|
|
|
void *context{nullptr};
|
|
|
|
|
proxysql_plugin_register_table_cb register_table;
|
|
|
|
|
proxysql_plugin_register_command_cb register_command;
|
|
|
|
|
proxysql_plugin_snapshot_cb get_mysql_users_snapshot;
|
|
|
|
|
proxysql_plugin_snapshot_cb get_mysql_servers_snapshot;
|
|
|
|
|
proxysql_plugin_snapshot_cb get_mysql_group_replication_hostgroups_snapshot;
|
|
|
|
|
proxysql_plugin_log_message_cb log_message;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
using proxysql_plugin_init_cb =
|
|
|
|
|
bool (*)(ProxySQL_PluginServices *, std::string &);
|
|
|
|
|
bool (*)(ProxySQL_PluginServices *);
|
|
|
|
|
|
|
|
|
|
using proxysql_plugin_start_cb =
|
|
|
|
|
bool (*)(std::string &);
|
|
|
|
|
bool (*)();
|
|
|
|
|
|
|
|
|
|
using proxysql_plugin_stop_cb =
|
|
|
|
|
bool (*)();
|
|
|
|
|
|
|
|
|
|
using proxysql_plugin_status_cb =
|
|
|
|
|
bool (*)(std::string &);
|
|
|
|
|
using proxysql_plugin_status_json_cb =
|
|
|
|
|
const char *(*)();
|
|
|
|
|
|
|
|
|
|
struct ProxySQL_PluginDescriptor {
|
|
|
|
|
uint32_t abi_version{0};
|
|
|
|
|
const char *name{nullptr};
|
|
|
|
|
proxysql_plugin_init_cb init{nullptr};
|
|
|
|
|
proxysql_plugin_start_cb start{nullptr};
|
|
|
|
|
proxysql_plugin_stop_cb stop{nullptr};
|
|
|
|
|
proxysql_plugin_status_cb status{nullptr};
|
|
|
|
|
const char *name;
|
|
|
|
|
uint32_t abi_version;
|
|
|
|
|
proxysql_plugin_init_cb init;
|
|
|
|
|
proxysql_plugin_start_cb start;
|
|
|
|
|
proxysql_plugin_stop_cb stop;
|
|
|
|
|
proxysql_plugin_status_json_cb status_json;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
using proxysql_plugin_descriptor_v1_t = const ProxySQL_PluginDescriptor *(*)();
|
|
|
|
|
|