MySQL 9.3.0
Source Code Documentation
option_tracker_usage.h
Go to the documentation of this file.
1/* Copyright (c) 2024, 2025, Oracle and/or its affiliates.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License, version 2.0,
5 as published by the Free Software Foundation.
6
7 This program is designed to work with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have either included with
13 the program or referenced in the documentation.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#ifndef OPTION_TRACKER_USAGE_H
25#define OPTION_TRACKER_USAGE_H
26
30
31/**
32 @brief A helper function to read the current value of a option usage counter
33
34 Fetches a reference to the option_tracker service.
35 Retrieves the usage JSON for the option, parses it, fetches
36 the usedCounter field and stores it into the pointer passed.
37 Then disposes of the reference.
38
39 Returns true if there's any error.
40
41 @retval true failure
42 @retval false success
43 @param option_name the name of the option to retrieve data for
44 @param[out] pCounter the buffer to return the value into
45 @param registry A reference to the registry service to use
46*/
47extern bool option_usage_read_counter(const char *option_name,
48 unsigned long long *pCounter,
49 SERVICE_TYPE(registry) * registry);
50/**
51 @brief Registers a cache update callback
52
53 Call this to subscribe to persisted data updates
54
55 @param option_name the name of the option to register a callback for
56 @param cb the callback function
57 @param registry A reference to the registry service to use
58 @retval true failure
59 @retval false sucees
60 */
62 const char *option_name,
64 SERVICE_TYPE(registry) * registry);
65
66/**
67 @brief Unregisters a cache update callback
68
69 Call this to unsubscribe to persisted data updates
70
71 @param option_name the name of the option to unregister a callback for
72 @param cb the callback function
73 @param registry A reference to the registry service to use
74 @retval true failure
75 @retval false sucees
76 */
78 const char *option_name,
80 SERVICE_TYPE(registry) * registry);
81
82/**
83 @brief A helper function to parse a JSON string and extract the counter
84 value
85
86 Given the usage JSON for the option, parses it, fetches
87 the usedCounter field and stores it into the pointer passed.
88
89 Returns true if there's any error.
90
91 @retval true failure
92 @retval false success
93 @param registry A reference to the registry service to use to put errors
94 and warnings. can be null.
95 @param option_name the name of the option that JSON usage is for
96 @param usage_data a JSON string for the usage data
97 @param[out] pCounter the buffer to return the value into
98*/
100 registry,
101 const char *option_name,
102 char *usage_data,
103 unsigned long long *pCounter);
104#endif /* OPTION_TRACKER_USAGE_H */
bool(* mysql_option_tracker_usage_cache_update_callback)(unsigned long long new_value)
Definition: mysql_option_tracker.h:127
static bool cb(unsigned long long new_value)
Definition: option_usage.cc:45
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.
Definition: option_tracker_usage.cc:144
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.
Definition: option_tracker_usage.cc:116
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.
Definition: option_tracker_usage.cc:62
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.
Definition: option_tracker_usage.cc:130
#define SERVICE_TYPE(name)
Generates the standard Service type name.
Definition: service.h:76