Skip to content

Commit 65608d3

Browse files
committed
MDEV-26851 : Interface to monitor connections in Galera
1 parent 12c02f5 commit 65608d3

File tree

2 files changed

+135
-0
lines changed

2 files changed

+135
-0
lines changed

CONTRIBUTORS.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Authors from Codership Oy:
2121
* Alexey Yurchenko <[email protected]>, Codership Oy
2222
* Mario Karuza <[email protected]>, Codership Oy
2323
* Daniele Sciascia <[email protected]>, Codership Oy
24+
* Jan Lindström <[email protected]>, Codership Oy
2425
[Codership employees, add name and email/username above this line, but leave this line intact]
2526

2627
Other contributors:

wsrep_connection_monitor_service.h

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
/*
2+
* Copyright (C) 2024-2025 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_connection_monitor_service.h
21+
*
22+
* This file defines interface for connection monitor service
23+
*
24+
* The provider which is capable of using the service interface v1 must
25+
* export the following functions.
26+
*
27+
* int wsrep_init_connection_monitor_service_v1(wsrep_connection_monitor_service_v1_t*)
28+
* void wsrep_deinit_connection_monitor_service_v1()
29+
*
30+
* which can be probed by the application.
31+
*
32+
* The application must initialize the service via above init function
33+
* before the provider is initialized via wsrep->init(). The deinit
34+
* function must be called after the provider side resources have been
35+
* released via wsrep->free().
36+
*/
37+
38+
#ifndef WSREP_CONNECTION_MONITOR_SERVICE_H
39+
#define WSREP_CONNECTION_MONITOR_SERVICE_H
40+
41+
#include "wsrep_api.h"
42+
43+
#ifdef __cplusplus
44+
extern "C"
45+
{
46+
#endif /* __cplusplus */
47+
48+
/**
49+
* Type tag for application defined connection monitoring processing context.
50+
*
51+
* Application may pass pointer to the context when initializing
52+
* the connection monitor service. This pointer is passed a first parameter for
53+
* each service call.
54+
*/
55+
typedef struct wsrep_connection_monitor_context wsrep_connection_monitor_context_t;
56+
57+
typedef const void* wsrep_connection_key_t;
58+
59+
/*
60+
* Connection monitor connection update callbacks.
61+
*
62+
*/
63+
64+
/*
65+
* Connection connect callback.
66+
*
67+
* @param id connection identifier
68+
* @param scheme connection scheme (tcp, ssl)
69+
* @param local_address local address string
70+
* @param remote_address remote address string
71+
*/
72+
typedef void (*wsrep_connection_monitor_connect_cb_t)(
73+
wsrep_connection_monitor_context_t*,
74+
wsrep_connection_key_t id,
75+
const wsrep_buf_t* scheme,
76+
const wsrep_buf_t* local_address,
77+
const wsrep_buf_t* remote_address);
78+
79+
/*
80+
* Connection disconnect callback.
81+
*
82+
* @param id connection identifier
83+
*/
84+
typedef void (*wsrep_connection_monitor_disconnect_cb_t)(
85+
wsrep_connection_monitor_context_t*,
86+
wsrep_connection_key_t id);
87+
88+
/*
89+
* Connection SSL/TLS info callback.
90+
*
91+
* @param id connection identifier
92+
* @param cipher cipher suite name
93+
* @param certificate_subject certificate subject name
94+
* @param certificate_issuer certificate issuer name
95+
* @param version SSL/TLS version string
96+
*/
97+
typedef void (*wsrep_connection_monitor_ssl_info_cb_t)(
98+
wsrep_connection_monitor_context_t*,
99+
wsrep_connection_key_t id,
100+
const wsrep_buf_t* cipher,
101+
const wsrep_buf_t* certificate_subject,
102+
const wsrep_buf_t* certificate_issuer,
103+
const wsrep_buf_t* version);
104+
105+
/**
106+
* Connection monitor service struct.
107+
*
108+
* A pointer to this struct must be passed to the call to
109+
* wsrep_init_connection_monitor_service_v1.
110+
*
111+
* The application must provide implementation to all functions defined
112+
* in this struct.
113+
*/
114+
typedef struct wsrep_connection_monitor_service_v1_st
115+
{
116+
/* Connection monitor connect callback */
117+
wsrep_connection_monitor_connect_cb_t connection_monitor_connect_cb;
118+
/* Connection monitor disconnect callback */
119+
wsrep_connection_monitor_disconnect_cb_t connection_monitor_disconnect_cb;
120+
/* Connection monitor ssl info callback */
121+
wsrep_connection_monitor_ssl_info_cb_t connection_monitor_ssl_info_cb;
122+
/* Pointer to application defined connection monitor context. */
123+
wsrep_connection_monitor_context_t* context;
124+
} wsrep_connection_monitor_service_v1_t;
125+
126+
#ifdef __cplusplus
127+
}
128+
#endif /* __cplusplus */
129+
130+
131+
#define WSREP_CONNECTION_MONITOR_SERVICE_INIT_FUNC_V1 "wsrep_init_connection_monitor_service_v1"
132+
#define WSREP_CONNECTION_MONITOR_SERVICE_DEINIT_FUNC_V1 "wsrep_deinit_connection_monitor_service_v1"
133+
134+
#endif /* WSREP_CONNECTION_MONITOR_SERVICE_H */

0 commit comments

Comments
 (0)