Skip to content

Commit 694d6ca

Browse files
committed
API extension to retrieve provider parameters
1 parent 02ed172 commit 694d6ca

File tree

1 file changed

+116
-0
lines changed

1 file changed

+116
-0
lines changed

wsrep_config_service.h

+116
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
/*
2+
* Copyright (C) 2022 Codership Oy <[email protected]>
3+
*
4+
* This file is part of wsrep-API.
5+
*
6+
* Wsrep-API is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, either version 2 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* Wsrep-API is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with wsrep-API. If not, see <https://www.gnu.org/licenses/>.
18+
*/
19+
20+
/** @file wsrep_config_service.h
21+
*
22+
* This file defines interface to retrieve a complete list of configuration
23+
* parameters accepted by the provider.
24+
* *
25+
* The provider which is capable of using the service interface v1 must
26+
* export the following functions:
27+
*
28+
* int wsrep_init_config_service_v1(wsrep_config_service_v1_t*)
29+
* void wsrep_deinit_config_service_v1()
30+
*
31+
* which can be probed by the application.
32+
*
33+
*/
34+
35+
#ifndef WSREP_CONFIG_SERVICE_H
36+
#define WSREP_CONFIG_SERVICE_H
37+
38+
#include "wsrep_api.h"
39+
40+
#ifdef __cplusplus
41+
extern "C" {
42+
#endif
43+
44+
/**
45+
* Flags to describe parameters.
46+
* By default, a parameter is dynamic and of type string,
47+
* unless flagged otherwise.
48+
*/
49+
#define WSREP_PARAM_DEPRECATED (1 << 0)
50+
#define WSREP_PARAM_READONLY (1 << 1)
51+
#define WSREP_PARAM_TYPE_BOOL (1 << 2)
52+
#define WSREP_PARAM_TYPE_INTEGER (1 << 3)
53+
#define WSREP_PARAM_TYPE_DOUBLE (1 << 4)
54+
55+
#define WSREP_PARAM_TYPE_MASK ( \
56+
WSREP_PARAM_TYPE_BOOL | \
57+
WSREP_PARAM_TYPE_INTEGER | \
58+
WSREP_PARAM_TYPE_DOUBLE \
59+
)
60+
61+
typedef struct wsrep_parameter
62+
{
63+
int flags;
64+
const char* name;
65+
union {
66+
bool as_bool;
67+
int64_t as_integer;
68+
double as_double;
69+
const char* as_string;
70+
} value;
71+
} wsrep_parameter_t;
72+
73+
/**
74+
* Callback called once for each parameter exposed by provider.
75+
* The callback should return WSREP_OK on success. Any other
76+
* return value causes get_parameters() to return WSREP_FATAL.
77+
*
78+
* @param p parameter
79+
* @param context application context
80+
*
81+
* @return WSREP_OK on success, otherwise application failure
82+
*/
83+
typedef wsrep_status_t (*wsrep_get_parameters_cb) (const wsrep_parameter_t* p,
84+
void* context);
85+
86+
/**
87+
* Get configuration parameters exposed by the provider.
88+
*
89+
* @param wsrep pointer to provider handle
90+
* @param cb function pointer for callback
91+
* @param context application context passed to callback
92+
*
93+
* @return WSREP_OK on success, WSREP_FATAL on failure
94+
*/
95+
typedef wsrep_status_t (*wsrep_get_parameters_fn) (wsrep_t* wsrep,
96+
wsrep_get_parameters_cb cb,
97+
void* context);
98+
99+
/**
100+
* Config service struct.
101+
*
102+
* A pointer to this struct must be passed to the call to
103+
* wsrep_init_config_service_v1.
104+
*/
105+
typedef struct wsrep_config_service_v1_st {
106+
wsrep_get_parameters_fn get_parameters;
107+
} wsrep_config_service_v1_t;
108+
109+
#ifdef __cplusplus
110+
}
111+
#endif
112+
113+
#define WSREP_CONFIG_SERVICE_INIT_FUNC_V1 "wsrep_init_config_service_v1"
114+
#define WSREP_CONFIG_SERVICE_DEINIT_FUNC_V1 "wsrep_deinit_config_service_v1"
115+
116+
#endif /* WSREP_CONFIG_SERVICE */

0 commit comments

Comments
 (0)