![]() |
MySQL 9.3.0
Source Code Documentation
|
#include "mysql/components/library_mysys/option_tracker_usage.h"
#include <atomic>
#include <ctime>
#include <string>
#include "my_rapidjson_size_t.h"
#include "mysql/components/my_service.h"
#include "mysql/components/service.h"
#include "mysql/components/services/mysql_option_tracker.h"
#include "mysql/components/services/mysql_simple_error_log.h"
#include "mysql/components/services/registry.h"
#include "mysqld_error.h"
#include "rapidjson/document.h"
#include "rapidjson/rapidjson.h"
#include "rapidjson/stringbuffer.h"
#include "rapidjson/writer.h"
Macros | |
#define | report_warning(registry, option_name, reason) report_warning_func(registry, option_name, reason, __FILE__, __LINE__) |
Functions | |
static bool | report_warning_func (const mysql_service_registry_t *registry, const char *option_name, const char *reason, const char *file, unsigned long line) |
bool | option_usage_set_counter_from_json (const mysql_service_registry_t *registry, const char *option_name, char *usage_data, unsigned long long *pCounter) |
A helper function to parse a JSON string and extract the counter value. More... | |
bool | option_usage_register_callback (const char *option_name, mysql_option_tracker_usage_cache_update_callback cb, const mysql_service_registry_t *registry) |
Registers a cache update callback. More... | |
bool | option_usage_unregister_callback (const char *option_name, mysql_option_tracker_usage_cache_update_callback cb, const mysql_service_registry_t *registry) |
Unregisters a cache update callback. More... | |
bool | option_usage_read_counter (const char *option_name, unsigned long long *pCounter, const mysql_service_registry_t *registry) |
A helper function to read the current value of a option usage counter. More... | |
Variables | |
const size_t | small_usage_data_size = 8192 |
const size_t | max_usage_data_size = 65536 |
#define report_warning | ( | registry, | |
option_name, | |||
reason | |||
) | report_warning_func(registry, option_name, reason, __FILE__, __LINE__) |
bool option_usage_read_counter | ( | const char * | option_name, |
unsigned long long * | pCounter, | ||
const mysql_service_registry_t * | registry | ||
) |
A helper function to read the current value of a option usage counter.
Fetches a reference to the option_tracker service. Retrieves the usage JSON for the option, parses it, fetches the usedCounter field and stores it into the pointer passed. Then disposes of the reference.
Returns true if there's any error.
true | failure |
false | success |
option_name | the name of the option to retrieve data for | |
[out] | pCounter | the buffer to return the value into |
registry | A reference to the registry service to use |
bool option_usage_register_callback | ( | const char * | option_name, |
mysql_option_tracker_usage_cache_update_callback | cb, | ||
const mysql_service_registry_t * | registry | ||
) |
Registers a cache update callback.
Call this to subscribe to persisted data updates
option_name | the name of the option to register a callback for |
cb | the callback function |
registry | A reference to the registry service to use |
true | failure |
false | sucees |
bool option_usage_set_counter_from_json | ( | const mysql_service_registry_t * | registry, |
const char * | option_name, | ||
char * | usage_data, | ||
unsigned long long * | pCounter | ||
) |
A helper function to parse a JSON string and extract the counter value.
Given the usage JSON for the option, parses it, fetches the usedCounter field and stores it into the pointer passed.
Returns true if there's any error.
true | failure |
false | success |
registry | A reference to the registry service to use to put errors and warnings. can be null. | |
option_name | the name of the option that JSON usage is for | |
usage_data | a JSON string for the usage data | |
[out] | pCounter | the buffer to return the value into |
bool option_usage_unregister_callback | ( | const char * | option_name, |
mysql_option_tracker_usage_cache_update_callback | cb, | ||
const mysql_service_registry_t * | registry | ||
) |
Unregisters a cache update callback.
Call this to unsubscribe to persisted data updates
option_name | the name of the option to unregister a callback for |
cb | the callback function |
registry | A reference to the registry service to use |
true | failure |
false | sucees |
|
static |
const size_t max_usage_data_size = 65536 |
const size_t small_usage_data_size = 8192 |