-
Notifications
You must be signed in to change notification settings - Fork 8
/
raft.h
75 lines (62 loc) · 1.36 KB
/
raft.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#ifndef INCLUDED_RAFT_H
#define INCLUDED_RAFT_H
#include <boost/any.hpp>
/**
* Copyright (c) 2013, Willem-Hendrik Thiart
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*
* @file
* @author Willem Thiart [email protected]
* @version 0.1
*/
typedef struct {
/** The ID that this node used to have.
* So that we can tell which nodes were removed/added when the
* configuration changes */
int old_id;
/** User data for addressing.
* Examples of what this could be:
* - void* pointing to implementor's networking data
* - a (IP,Port) tuple */
boost::any userData;
} raft_node_configuration_t;
typedef int (
*func_send_f
) (
void *cb_ctx,
void *udata,
int node,
int msg_type,
const unsigned char *send_data,
const int d_len
);
#ifndef HAVE_FUNC_LOG
#define HAVE_FUNC_LOG
typedef void (
*func_log_f
) (
void *cb_ctx,
void *src,
const char *buf,
...
);
#endif
/**
* Apply this log to the state macine */
typedef int (
*func_applylog_f
) (
void *cb_ctx,
void *udata,
const unsigned char *d_data,
const int d_len
);
typedef struct {
func_send_f send;
func_log_f log;
func_applylog_f applylog;
} raft_cbs_t;
typedef void* raft_server_t;
typedef int* raft_node_t;
#endif //INCLUDED_RAFT_H