/
bstar.h
51 lines (37 loc) · 1.38 KB
/
bstar.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
/* =====================================================================
* bstar - Binary Star reactor
* ===================================================================== */
#ifndef __BSTAR_H_INCLUDED__
#define __BSTAR_H_INCLUDED__
#include "czmq.h"
// Arguments for constructor
#define BSTAR_PRIMARY 1
#define BSTAR_BACKUP 0
#ifdef __cplusplus
extern "C" {
#endif
// Opaque class structure
typedef struct _bstar_t bstar_t;
// Create a new Binary Star instance, using local (bind) and
// remote (connect) endpoints to set-up the server peering.
bstar_t *bstar_new (int primary, char *local, char *remote);
// Destroy a Binary Star instance
void bstar_destroy (bstar_t **self_p);
// Return underlying zloop reactor, for timer and reader
// registration and cancelation.
zloop_t *bstar_zloop (bstar_t *self);
// Register voting reader
int bstar_voter (bstar_t *self, char *endpoint, int type,
zloop_fn handler, void *arg);
// Register main state change handlers
void bstar_new_master (bstar_t *self, zloop_fn handler, void *arg);
void bstar_new_slave (bstar_t *self, zloop_fn handler, void *arg);
// Enable/disable verbose tracing
void bstar_set_verbose (bstar_t *self, Bool verbose);
// Start the reactor, ends if a callback function returns -1, or the
// process received SIGINT or SIGTERM.
int bstar_start (bstar_t *self);
#ifdef __cplusplus
}
#endif
#endif