MySQL 8.0.39
Source Code Documentation
registry.h
Go to the documentation of this file.
1/* Copyright (c) 2016, 2024, Oracle and/or its affiliates.
2
3This program is free software; you can redistribute it and/or modify
4it under the terms of the GNU General Public License, version 2.0,
5as published by the Free Software Foundation.
6
7This program is designed to work with certain software (including
8but not limited to OpenSSL) that is licensed under separate terms,
9as designated in a particular file or component or in included license
10documentation. The authors of MySQL hereby grant you an additional
11permission to link the program and your derivative works with the
12separately licensed software that they have either included with
13the program or referenced in the documentation.
14
15This program is distributed in the hope that it will be useful,
16but WITHOUT ANY WARRANTY; without even the implied warranty of
17MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18GNU General Public License, version 2.0, for more details.
19
20You should have received a copy of the GNU General Public License
21along with this program; if not, write to the Free Software
22Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#ifndef MYSQL_REGISTRY_H
25#define MYSQL_REGISTRY_H
26
28#include <stdint.h>
29
30/**
31 A handle type for acquired Service.
32*/
34
35/**
36 A handle type for a iterator to a Service Implementation.
37*/
39/**
40 A handle type for a iterator to metadata of some Service Implementation.
41*/
43
44/**
45 Service for acquiring and releasing references to all registered Service
46 Implementations.
47*/
49/**
50 Finds and acquires a Service by name. A name of the Service or the Service
51 Implementation can be specified. In case of the Service name, the default
52 Service Implementation for Service specified will be returned.
53
54 @param service_name Name of Service or Service Implementation to acquire.
55 @param [out] out_service Pointer to Service handle to set acquired Service.
56 @return Status of performed operation
57 @retval false success
58 @retval true failure
59*/
61 (const char *service_name, my_h_service *out_service));
62/**
63 Finds a Service by name. If there is a Service Implementation with the same
64 Component part of name as the input Service then the found Service is
65 returned.
66
67 @param service_name Name of Service or Service Implementation to acquire.
68 @param service Service handle already acquired Service Implementation.
69 @param [out] out_service Pointer to Service Implementation handle to set
70 acquired Service Implementation.
71 @return Status of performed operation
72 @retval false success
73 @retval true failure
74*/
75DECLARE_BOOL_METHOD(acquire_related,
76 (const char *service_name, my_h_service service,
77 my_h_service *out_service));
78/**
79 Releases the Service Implementation previously acquired. After the call to
80 this method the usage of the Service Implementation handle will lead to
81 unpredicted results.
82
83 @param service Service Implementation handle of already acquired Service.
84 @return Status of performed operation
85 @retval false success
86 @retval true failure
87*/
90
91/**
92 Service for managing list of registered Service Implementations.
93*/
94BEGIN_SERVICE_DEFINITION(registry_registration)
95/**
96 Registers a new Service Implementation. If it is the first Service
97 Implementation for the specified Service then it is made a default one.
98
99 @param service_implementation_name Name of the Service Implementation to
100 register.
101 @param ptr Pointer to the Service Implementation structure.
102 @return Status of performed operation
103 @retval false success
104 @retval true failure
105*/
106DECLARE_BOOL_METHOD(register_service, (const char *service_implementation_name,
108/**
109 Removes previously registered Service Implementation from registry. If it is
110 the default one for specified Service then any one still registered is made
111 default. If there is no other, the default entry is removed from the
112 Registry too.
113
114 @param service_implementation_name Name of the Service Implementation to
115 unregister.
116 @return Status of performed operation
117 @retval false success
118 @retval true Failure. May happen when Service is still being referenced.
119*/
120DECLARE_BOOL_METHOD(unregister, (const char *service_implementation_name));
121/**
122 Sets new default Service Implementation for corresponding Service name.
123
124 @param service_implementation_name Name of the Service Implementation to
125 set as default one.
126 @return Status of performed operation
127 @retval false success
128 @retval true failure
129*/
130DECLARE_BOOL_METHOD(set_default, (const char *service_implementation_name));
131END_SERVICE_DEFINITION(registry_registration)
132
133/**
134 Service for listing all Service Implementations by iterator.
135*/
137/**
138 Creates iterator that iterates through all registered Service
139 Implementations. If successful it leaves read lock on the Registry until
140 iterator is released. The starting point of iteration may be specified
141 to be on one particular Service Implementation. The iterator will move
142 through all Service Implementations and additionally through all default
143 Service Implementation additionally, i.e. the default Service Implementation
144 will be returned twice. If no name is specified for search, iterator will be
145 positioned on the first Service Implementation.
146
147 @warning Takes and keeps a lock on the registry until the iterator is closed!
148
149 @param service_name_pattern Name of Service or Service Implementation to
150 start iteration from. May be empty string or NULL pointer, in which case
151 iteration starts from the first Service Implementation.
152 @param [out] out_iterator Pointer to the Service Implementation iterator
153 handle.
154 @return Status of performed operation
155 @retval false success
156 @retval true failure
157*/
158DECLARE_BOOL_METHOD(create, (const char *service_name_pattern,
159 my_h_service_iterator *out_iterator));
160/**
161 Gets name of Service pointed to by iterator. The pointer returned will last
162 at least up to the moment of call to the release() method on the iterator.
163
164 @param iterator Service Implementation iterator handle.
165 @param [out] out_name Pointer to string with name to set result pointer to.
166 @return Status of performed operation
167 @retval false success
168 @retval true Failure, may be caused when called on iterator that went
169 through all values already.
170*/
171DECLARE_BOOL_METHOD(get, (my_h_service_iterator iter, const char **out_name));
172/**
173 Advances specified iterator to next element. Will succeed but return true if
174 it reaches one-past-last element.
175
176 @note You should collect the service names in a local cache, close the
177 iterator and only then try to resolve the names using the other registry
178 services.
179
180 @warning Make sure to close the iterator before looking up the name into
181 the registry! Otherwise undefined behavior will ensure. Most probably a
182 deadlock.
183
184 @param iterator Service Implementation iterator handle.
185 @return Status of performed operation and validity of iterator after
186 operation.
187 @retval false success
188 @retval true Failure or called on iterator that was on last element.
189*/
191/**
192 Checks if specified iterator is valid, i.e. have not reached one-past-last
193 element.
194
195 @param iterator Service Implementation iterator handle.
196 @return Validity of iterator
197 @retval false Valid
198 @retval true Invalid or reached one-past-last element.
199*/
201/**
202 Releases the Service Implementations iterator. Releases read lock on the
203 Registry.
204
205 @param iterator Service Implementation iterator handle.
206 @return Status of performed operation
207 @retval false success
208 @retval true failure
209*/
212
213/**
214 Service for listing all metadata for a Service Implementation specified by
215 the given iterator.
216*/
217BEGIN_SERVICE_DEFINITION(registry_metadata_enumerate)
218/**
219 Creates a iterator that iterates through all metadata for the object pointed
220 by the specified iterator. If successful it leaves read lock on the registry
221 until the iterator is released.
222
223 @param iterator A iterator that points to object to get the metadata
224 iterator for.
225 @param [out] out_iterator Pointer to metadata iterator handle.
226 @return Status of performed operation
227 @retval false success
228 @retval true failure
229*/
232/**
233 Gets the key and value of the metadata pointed to by the specified iterator.
234 The pointers returned will last at least up to the moment of call to the
235 release() method on the iterator.
236
237 @param iterator Metadata iterator handle.
238 @param [out] out_name A pointer to the string with the key to set the result
239 pointer to.
240 @param [out] out_value A pointer to the string with the metadata value to
241 set the result pointer to.
242 @return Status of performed operation
243 @retval false success
244 @retval true Failure, may be caused when called on the iterator that went
245 through all values already.
246*/
248 const char **name, const char **value));
249/**
250 Advances specified iterator to next element. Will fail if it reaches
251 one-past-last element.
252
253 @param iterator Metadata iterator handle.
254 @return Status of performed operation
255 @retval false success
256 @retval true Failure, may be caused when called on iterator that was on last
257 element.
258*/
260/**
261 Checks if specified iterator is valid, i.e. have not reached one-past-last
262 element.
263
264 @param iterator Metadata iterator handle.
265 @return Validity of iterator
266 @retval false Valid
267 @retval true Invalid or reached one-past-last element.
268*/
270/**
271 Releases the specified iterator. Releases read lock on the registry.
272
273 @param iterator Metadata iterator handle.
274 @return Status of performed operation
275 @retval false success
276 @retval true failure
277*/
279END_SERVICE_DEFINITION(registry_metadata_enumerate)
280
281/**
282 Service to query specified metadata key directly for the specified Service
283 Implementation by iterator to it.
284*/
285BEGIN_SERVICE_DEFINITION(registry_metadata_query)
286/**
287 Gets the key and value of the metadata pointed to by the specified object
288 iterator. The pointer returned will last at least up to the moment of call
289 to the release() method on the iterator.
290
291 @param iterator A iterator that points to object to get the metadata
292 iterator for.
293 @param name A pointer to the string with the key to set the result
294 pointer to.
295 @param [out] out_value A pointer to the string with the metadata value to
296 set the result pointer to.
297 @return Status of performed operation
298 @retval false success
299 @retval true Failure, may be caused when called on the iterator that went
300 through all values already.
301*/
302DECLARE_BOOL_METHOD(get_value, (my_h_service_iterator iterator,
303 const char *name, const char **value));
304END_SERVICE_DEFINITION(registry_metadata_query)
305
306#endif /* MYSQL_REGISTRY_H */
struct my_h_service_imp * my_h_service
A handle type for acquired Service.
Definition: registry.h:33
bool is_valid(const dd::Spatial_reference_system *srs, const Geometry *g, const char *func_name, bool *is_valid) noexcept
Decides if a geometry is valid.
Definition: is_valid.cc:95
void get(PSI_field *, PSI_longlong *) noexcept
Definition: pfs_plugin_column_bigint_v1_all_empty.cc:32
static mysql_service_status_t create(const char *service_names[], reference_caching_channel *out_channel) noexcept
Definition: component.cc:36
#define DECLARE_METHOD(retval, name, args)
Declares a method as a part of the Service definition.
Definition: service.h:103
#define END_SERVICE_DEFINITION(name)
A macro to end the last Service definition started with the BEGIN_SERVICE_DEFINITION macro.
Definition: service.h:91
#define BEGIN_SERVICE_DEFINITION(name)
Declares a new Service.
Definition: service.h:86
#define DEFINE_SERVICE_HANDLE(name)
Defines an object type that is meant for carrying handles to the implementation-specific objects used...
Definition: service.h:129
#define DECLARE_BOOL_METHOD(name, args)
Declares a method that returns bool as a part of the Service definition.
Definition: service.h:112
case opt name
Definition: sslopt-case.h:33
Definition: registry.cc:58
Definition: registry.cc:63