-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathfuzzylog.h
115 lines (98 loc) · 3.35 KB
/
fuzzylog.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#ifndef FuzzyLog_C_bindings_h
#define FuzzyLog_C_bindings_h
/* Generated with cbindgen:0.6.3 */
/* Warning, this file is autogenerated by cbindgen. Don't modify this manually. */
#include <stdint.h>
#include <stdlib.h>
#include <stdbool.h>
typedef struct DAG DAG;
typedef struct HashMap_order__entry HashMap_order__entry;
typedef HashMap_order__entry SnapBody;
typedef SnapBody *SnapId;
typedef DAG *FLPtr;
/*
* A `ColorSpec` describes the layout of a color.
*
* members:
* local_chain: the local chain for this color
* num_remote_chains: The number of remote chains which make up the color
* retmote_chains: an array of size `numchains` consisting of the chains for a
* color.
*
* NOTE `local_chain` _may_ be included in `remote_chains` as well,
* though it is not necessary to do so.
*/
typedef struct {
uint64_t local_chain;
uintptr_t num_remote_chains;
uint64_t *remote_chains;
} ColorSpec;
/*
* The specification for a static FuzzyLog server configuration.
* Since we're using chain-replication, in a replicated setup the client
* needs to know of both the head and tail of each replication chain. In an
* non-replicated setup tail_ips should be NULL. Each element of an ip
* array should be in the form `<ip-addr>:<port>`. Currently only ipv4 is
* supported.
*
* members:
* num_ips: the number of IP addresses in each array
* head_ips: an array of `"<ip-addr>:<port>"` describing the heads of the
* FuzzyLog replication chain.
* tail_ips: an array of `"<ip-addr>:<port>"` describing the heads of the
* FuzzyLog replication chain, or `NULL` if the FuzzyLog is not
* replicated/
*/
typedef struct {
uintptr_t num_ips;
char **head_ips;
char **tail_ips;
} ServerSpec;
void delete_snap_id(SnapId snap);
/*
* Append a node to the FuzzyLog
*
* args:
* handle: the client handle which will perform the append
*
* data: the data to be contained in the new node
* data_size: the number of bytes in `data`
*
* colors: the colors the new node should inhabit. Note that only
* `local_color` will be read from these colors.
* num_colors: the number of colors in `colors`
*/
int32_t fuzzylog_append(FLPtr handle,
const char *data,
uintptr_t data_size,
const ColorSpec *colors,
uintptr_t num_colors);
void fuzzylog_close(FLPtr handle);
/*
* Sync a local view with the FuzzyLog.
*
* args:
* handle: the client handle which will perform the sync
* callback: a callback which will be called on every new event.
* args are: the passed in `callback_state`, the event's `data`,
* the events `data_size`
* callback_state: a pointer passed as the first argument to callback.
* May be `NULL`.
*/
SnapId fuzzylog_sync(FLPtr handle,
void (*callback)(void*, const char*, uintptr_t),
void *callback_state);
void fuzzylog_trim(FLPtr handle, SnapId snap);
/*
* Start a new FuzzyLog client instance, and connect it so the supplied
* server(s).
*
* args:
* servers: a `ServerSpec` describing the servers to connect to.
* color: a `ColorSpec` for the color this client reads.
* snap: a SnapId that the client should start `sync`ing from,
* or NULL if the client should start from the beginning of its
* color
*/
FLPtr new_fuzzylog_instance(ServerSpec servers, ColorSpec color, SnapId snap);
#endif /* FuzzyLog_C_bindings_h */