Update ctdb_remove_message_handler to provide a nonblocking async version
[sahlberg/ctdb.git] / include / ctdb.h
1 /* 
2    ctdb database library
3
4    Copyright (C) Ronnie sahlberg 2010
5
6    This program 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 3 of the License, or
9    (at your option) any later version.
10    
11    This program 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 this program; if not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #ifndef _CTDB_H
21 #define _CTDB_H
22
23 struct ctdb_context *ctdb_connect(const char *addr);
24
25 int ctdb_get_fd(struct ctdb_context *ctdb);
26
27 int ctdb_which_events(struct ctdb_context *ctdb);
28
29 int ctdb_service(struct ctdb_context *ctdb);
30
31
32
33 typedef void ctdb_handle;
34
35
36 /*
37  * function to cancel a request/call
38  */
39 int ctdb_cancel(ctdb_handle *);
40
41
42
43 /*
44  * messaging functions 
45  */
46 typedef void (*ctdb_message_fn_t)(struct ctdb_context *, uint64_t srvid, TDB_DATA data, void *);
47
48 typedef void (*ctdb_set_message_handler_cb)(int32_t status, void *private_data);
49
50 ctdb_handle *
51 ctdb_set_message_handler_send(struct ctdb_context *ctdb, uint64_t srvid,
52                               ctdb_set_message_handler_cb callback,
53                               ctdb_message_fn_t handler, void *private_data);
54
55 int ctdb_set_message_handler_recv(struct ctdb_context *ctdb,
56                                   ctdb_handle *handle);
57
58 int ctdb_set_message_handler(struct ctdb_context *ctdb, uint64_t srvid,
59                              ctdb_message_fn_t handler, void *private_data);
60
61
62 typedef void (*ctdb_remove_message_handler_cb)(int32_t status, void *private_data);
63
64 ctdb_handle *
65 ctdb_remove_message_handler_send(struct ctdb_context *ctdb, uint64_t srvid,
66                                  ctdb_remove_message_handler_cb callback,
67                                  void *private_data);
68
69 int ctdb_remove_message_handler_recv(struct ctdb_context *ctdb,
70                                   ctdb_handle *handle);
71
72 int ctdb_remove_message_handler(struct ctdb_context *ctdb, uint64_t srvid,
73                                 void *private_data);
74
75 int ctdb_send_message(struct ctdb_context *ctdb, uint32_t pnn, uint64_t srvid, TDB_DATA data);
76
77
78
79
80 /*
81  * functions to read the recovery master of a node
82  */
83 typedef void (*ctdb_get_recmaster_cb)(int32_t status, int32_t recmaster, void *private_data);
84
85 ctdb_handle *
86 ctdb_getrecmaster_send(struct ctdb_context *ctdb,
87                         uint32_t destnode,
88                         ctdb_get_recmaster_cb callback,
89                         void *private_data);
90 int ctdb_getrecmaster_recv(struct ctdb_context *ctdb,
91                         ctdb_handle *handle,
92                         uint32_t *recmaster);
93 int ctdb_getrecmaster(struct ctdb_context *ctdb,
94                         uint32_t destnode,
95                         uint32_t *recmaster);
96
97
98 #endif