MySQL 9.3.0
Source Code Documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
option_tracker_usage.cc File Reference
#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
 

Macro Definition Documentation

◆ report_warning

#define report_warning (   registry,
  option_name,
  reason 
)     report_warning_func(registry, option_name, reason, __FILE__, __LINE__)

Function Documentation

◆ option_usage_read_counter()

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.

Return values
truefailure
falsesuccess
Parameters
option_namethe name of the option to retrieve data for
[out]pCounterthe buffer to return the value into
registryA reference to the registry service to use

◆ option_usage_register_callback()

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

Parameters
option_namethe name of the option to register a callback for
cbthe callback function
registryA reference to the registry service to use
Return values
truefailure
falsesucees

◆ option_usage_set_counter_from_json()

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.

Return values
truefailure
falsesuccess
Parameters
registryA reference to the registry service to use to put errors and warnings. can be null.
option_namethe name of the option that JSON usage is for
usage_dataa JSON string for the usage data
[out]pCounterthe buffer to return the value into

◆ option_usage_unregister_callback()

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

Parameters
option_namethe name of the option to unregister a callback for
cbthe callback function
registryA reference to the registry service to use
Return values
truefailure
falsesucees

◆ report_warning_func()

static bool report_warning_func ( const mysql_service_registry_t registry,
const char *  option_name,
const char *  reason,
const char *  file,
unsigned long  line 
)
static

Variable Documentation

◆ max_usage_data_size

const size_t max_usage_data_size = 65536

◆ small_usage_data_size

const size_t small_usage_data_size = 8192