skip to content
==> include/mesh/cluster_conf.h <==
1/* @ajax/mesh-cluster-conf: the cluster config (`meshd --cluster FILE --system K`): one key = value
2 * file describing every member, shared with the cluster scripts. meshd reads `systems`, every
3 * `k.peer` and its own `k.listen`, and the timing keys; other keys (ssh host, dirs, ...) are the
4 * scripts' and are ignored here.
5 *
6 *     systems = 3
7 *     0.peer = 192.168.177.11:27800     # what the others dial (system k > 0 listens on it)
8 *     1.peer = 192.168.177.11:27801
9 *     1.listen = 0.0.0.0:27801          # optional bind address (default: k.peer)
10 *     2.peer = 192.168.177.12:27802
11 *     dead_ms = 3000                    # optional: a member silent this long is gone
12 *     ping_ms = 250                     # optional: the beat period
13 *     sched_hold_ms = 6000              # optional: the scheduler's policy (mesh-sched-weights)
14 */
15#ifndef MESH_CLUSTER_CONF_H
16#define MESH_CLUSTER_CONF_H
17
18#include "mesh/abi/base.h"
19#include "mesh/sched_weights.h"
20#include "mesh/strmap.h"
21
22#include <stdbool.h>
23#include <stdint.h>
24
25/* Liveness and election timing, and the scheduler's policy. */
26typedef struct {
27    uint64_t ping_ms, dead_ms;
28    msw_weights sched;
29} mcc_tunables;
30
31/* One machine's view of the cluster's links: system k dials every j > k and (k > 0) listens for
32 * the systems below it. */
33typedef struct {
34    uint32_t me, n;
35    char *listen; /* where it accepts the lower systems' links; NULL for system 0 */
36    size_t ndial;
37    uint32_t dial_k[MESH_MAX_SYSTEMS];      /* every j > me ... */
38    char *dial_addr[MESH_MAX_SYSTEMS];     /* ... and its address */
39    mcc_tunables tun;
40} mcc_topology;
41
42mcc_tunables mcc_tunables_default(void);
43/* key -> value of a config file (comments `#`, blank lines, `key = value`, values unquoted). */
44bool mcc_keys(const char *text, ms_map *out, char **err);
45/* System me's topology from the config text. On error *err is the Rust's message. */
46bool mcc_topology_parse(const char *text, uint32_t me, mcc_topology *out, char **err);
47/* The 2-system shorthands: system 0 dials peer; system 1 listens on addr. */
48mcc_topology mcc_pair_dialer(const char *peer);
49mcc_topology mcc_pair_listener(const char *addr);
50bool mcc_topology_eq(const mcc_topology *a, const mcc_topology *b);
51void mcc_topology_free(mcc_topology *t);
52
53#endif